git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] git config --unset is not idempotent
@ 2022-08-25  8:52 Arturo Seijas Fernandez
  2022-08-25  9:40 ` Jeff King
  2022-08-25 16:25 ` Junio C Hamano
  0 siblings, 2 replies; 3+ messages in thread
From: Arturo Seijas Fernandez @ 2022-08-25  8:52 UTC (permalink / raw)
  To: git

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.

Thank you,

Arturo Seijas

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] git config --unset is not idempotent
  2022-08-25  8:52 [BUG] git config --unset is not idempotent Arturo Seijas Fernandez
@ 2022-08-25  9:40 ` Jeff King
  2022-08-25 16:25 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2022-08-25  9:40 UTC (permalink / raw)
  To: Arturo Seijas Fernandez; +Cc: git

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] git config --unset is not idempotent
  2022-08-25  8:52 [BUG] git config --unset is not idempotent Arturo Seijas Fernandez
  2022-08-25  9:40 ` Jeff King
@ 2022-08-25 16:25 ` Junio C Hamano
  1 sibling, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2022-08-25 16:25 UTC (permalink / raw)
  To: Arturo Seijas Fernandez; +Cc: git

Arturo Seijas Fernandez <arturo.seijas@canonical.com> writes:

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

"rm" is not "idempotent", either.

    echo >file
    rm file ; echo $?
    rm file ; echo $?

The "git config --unset" command signals the inability to unset a
variable when the variable to be unset does not even exist.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-25 16:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-25  8:52 [BUG] git config --unset is not idempotent Arturo Seijas Fernandez
2022-08-25  9:40 ` Jeff King
2022-08-25 16:25 ` Junio C Hamano

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