Subject: Re: [PATCH] remote: add meaningful exit code on missing/existing

From: Junio C Hamano <[email-masked]>
Date: Mon, 26 Oct 2020 11:29:30 -0700

Ævar Arnfjörð Bjarmason  <[email-masked]> writes:

> 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...).

Sounds like a worthy goal.  One thing that disturbs me somewhat,
which the time will solve without any of our effort, is how the
calling scripts and machinery decides when they can start relying on
the exit codes.  A "git remote tell-me-what-you-can-do" command that
may or may not say "exitcode" to its standard output is added?
"test $(git version) -ge 2.30 || old_way"?

The changes to the code all looked quite straight-forward and 
the tests look sensible, too.

Thanks.