diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2020-10-27 10:41:36 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-10-27 11:40:33 -0700 |
commit | 9144ba4cf52bb0e891d7c10a331fc32c1d3e8f64 (patch) | |
tree | 5ca271ed926731c68c5a72fd323feeafe3d19bd9 /sh-i18n--envsubst.c | |
parent | Sync with Git 2.29.1 (diff) | |
download | tgif-9144ba4cf52bb0e891d7c10a331fc32c1d3e8f64.tar.xz |
remote: add meaningful exit code on missing/existing
Change the exit code for the likes of "git remote add/rename" to exit
with 2 if the remote in question doesn't exist, and 3 if it
does. Before we'd just die() and exit with the general 128 exit code.
This changes the output message from e.g.:
fatal: remote origin already exists.
To:
error: remote origin already exists.
Which I believe is a feature, since we generally use "fatal" for the
generic errors, and "error" for the more specific ones with a custom
exit code, but this part of the change may break code that already
relies on stderr parsing (not that we ever supported that...).
The motivation for this is a discussion around some code in GitLab's
gitaly which wanted to check this, and had to parse stderr to do so:
https://gitlab.com/gitlab-org/gitaly/-/merge_requests/2695
It's worth noting as an aside that a method of checking this that
doesn't rely on that is to check with "git config" whether the value
in question does or doesn't exist. That introduces a TOCTOU race
condition, but on the other hand this code (e.g. "git remote add")
already has a TOCTOU race.
We go through the config.lock for the actual setting of the config,
but the pseudocode logic is:
read_config();
check_config_and_arg_sanity();
save_config();
So e.g. if a sleep() is added right after the remote_is_configured()
check in add() we'll clobber remote.NAME.url, and add another (usually
duplicate) remote.NAME.fetch entry (and other values, depending on
invocation).
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sh-i18n--envsubst.c')
0 files changed, 0 insertions, 0 deletions