All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Arturo Seijas Fernandez <arturo.seijas@canonical.com>
Cc: git@vger.kernel.org
Subject: Re: [BUG] git config --unset is not idempotent
Date: Thu, 25 Aug 2022 05:40:51 -0400	[thread overview]
Message-ID: <YwdDo0yMAaJsCquk@coredump.intra.peff.net> (raw)
In-Reply-To: <CAHckPJS6ibtxbU+VKwDaU6pFMtJ5SMcWnBi6D2pY+ekqpWsqXg@mail.gmail.com>

On Thu, Aug 25, 2022 at 10:52:16AM +0200, Arturo Seijas Fernandez wrote:

> The command "git config --unset [option]" is not idempotent. It is
> currently returning a success  code when the property had already been
> set and a 5 error code otherwise.
> 
> I would expect the error code to be set according to the current state
> when compared to the target state, regardless of the previous state of
> the option.

You can get what you want in the shell with:

  # passes "set -e", but could also be used in an "if"
  git config --unset ... || test $? = 5

That's obviously not as convenient. The flip side is that returning 0
would make it very hard for callers to tell if they removed something
(if they care).

If we were designing the tool now, I could definitely see an argument
for returning 0 in this case. But we have over a decade with the "5"
exit code documented for a plumbing tool. We won't change it now without
a good reason and without a deprecation schedule, and IMHO this doesn't
rise to that level.

-Peff

  reply	other threads:[~2022-08-25  9:41 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-25  8:52 [BUG] git config --unset is not idempotent Arturo Seijas Fernandez
2022-08-25  9:40 ` Jeff King [this message]
2022-08-25 16:25 ` Junio C Hamano

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=YwdDo0yMAaJsCquk@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=arturo.seijas@canonical.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.