git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>,
	Bert Wesarg <bert.wesarg@googlemail.com>,
	Christian Couder <chriscool@tuxfamily.org>
Subject: Re: [PATCH] remote: add meaningful exit code on missing/existing
Date: Mon, 26 Oct 2020 15:45:19 -0400	[thread overview]
Message-ID: <20201026194519.GB16150@coredump.intra.peff.net> (raw)
In-Reply-To: <20201026144825.26537-1-avarab@gmail.com>

On Mon, Oct 26, 2020 at 03:48:25PM +0100, Ævar Arnfjörð Bjarmason wrote:

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

I can't think of a particular reason not to do this. Though I suspect
anything scripting may generally be better off using git-config directly
for more flexibility and power.

> 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

I didn't immediately see there the use cases you'd put this to. If it's
something like "add an origin remote for fetching from a mirror", then
that it is probably reasonable. But if you're thinking of something that
may grow without bound (e.g., one remote per fork of the repository),
keep in mind that modifying the config file is linear to its size (so
creating or deleting N remotes is N^2).

>  Documentation/git-remote.txt | 11 ++++++++++
>  builtin/remote.c             | 42 ++++++++++++++++++++++++------------
>  t/t5505-remote.sh            | 16 +++++++-------
>  3 files changed, 47 insertions(+), 22 deletions(-)

The patch itself looks good to me, with one minor nit:

> +EXIT STATUS
> +-----------
> +
> +On success, the exit status is `0`.
> +
> +When subcommands such as 'add', 'rename' and 'remove' can't find the
> +remote in question the exit status is `2`, when the remote already
> +exists the exit status is `3`.

This is a run-on sentence; the comma after `2` should be a period.

I'd also put an Oxford comma after `rename`, but that's a stylistic
choice. :)

-Peff

  parent reply	other threads:[~2020-10-26 19:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 14:48 [PATCH] remote: add meaningful exit code on missing/existing Ævar Arnfjörð Bjarmason
2020-10-26 14:52 ` Eric Sunshine
2020-10-26 18:29 ` Junio C Hamano
2020-10-26 19:45 ` Jeff King [this message]
2020-10-26 21:00   ` Junio C Hamano
2020-10-27  9:41     ` [PATCH v2] " Ævar Arnfjörð Bjarmason
2020-10-26 19:55 ` [PATCH] " Bert Wesarg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201026194519.GB16150@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=avarab@gmail.com \
    --cc=bert.wesarg@googlemail.com \
    --cc=chriscool@tuxfamily.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).