git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [BUG] git config --unset is not idempotent

From
Jeff King <peff@peff.net>
Date
Aug 25, 2022, 09:40 UTC
Message-ID
<YwdDo0yMAaJsCquk@coredump.intra.peff.net>
In-Reply-To
<CAHckPJS6ibtxbU+VKwDaU6pFMtJ5SMcWnBi6D2pY+ekqpWsqXg@mail.gmail.com>
On Thu, Aug 25, 2022 at 10:52:16AM +0200, Arturo Seijas Fernandez wrote:
Show 7 quoted lines
> 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
Previous: Arturo Seijas FernandezNext: Junio C Hamano
Message 2 of 3 in “[BUG] git config --unset is not idempotent”
  1. Arturo Seijas FernandezAug 25, 2022
  2. Jeff KingAug 25, 2022
  3. Junio C HamanoAug 25, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.