{"thread":{"id":"58358","subject":"[BUG] git config --unset is not idempotent","startedAt":"2022-08-25T08:52:32Z","lastAt":"2022-08-25T16:25:32Z","messageCount":3,"participants":["Arturo Seijas Fernandez","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"461938","messageId":"CAHckPJS6ibtxbU+VKwDaU6pFMtJ5SMcWnBi6D2pY+ekqpWsqXg@mail.gmail.com","threadId":"58358","inReplyTo":null,"subject":"[BUG] git config --unset is not idempotent","fromName":"Arturo Seijas Fernandez","fromEmail":"arturo.seijas@canonical.com","sentAt":"2022-08-25T08:52:16Z","receivedAt":"2022-08-25T08:52:32Z","isPatch":false,"sender":{"key":"arturo.seijas@canonical.com","avatar":null},"body":"The command \"git config --unset [option]\" is not idempotent. It is\ncurrently returning a success  code when the property had already been\nset and a 5 error code otherwise.\n\nI would expect the error code to be set according to the current state\nwhen compared to the target state, regardless of the previous state of\nthe option.\n\nThank you,\n\nArturo Seijas\n"},{"id":"461939","messageId":"YwdDo0yMAaJsCquk@coredump.intra.peff.net","threadId":"58358","inReplyTo":"CAHckPJS6ibtxbU+VKwDaU6pFMtJ5SMcWnBi6D2pY+ekqpWsqXg@mail.gmail.com","subject":"Re: [BUG] git config --unset is not idempotent","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2022-08-25T09:40:51Z","receivedAt":"2022-08-25T09:41:03Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Aug 25, 2022 at 10:52:16AM +0200, Arturo Seijas Fernandez wrote:\n\n> The command \"git config --unset [option]\" is not idempotent. It is\n> currently returning a success  code when the property had already been\n> set and a 5 error code otherwise.\n> \n> I would expect the error code to be set according to the current state\n> when compared to the target state, regardless of the previous state of\n> the option.\n\nYou can get what you want in the shell with:\n\n  # passes \"set -e\", but could also be used in an \"if\"\n  git config --unset ... || test $? = 5\n\nThat's obviously not as convenient. The flip side is that returning 0\nwould make it very hard for callers to tell if they removed something\n(if they care).\n\nIf we were designing the tool now, I could definitely see an argument\nfor returning 0 in this case. But we have over a decade with the \"5\"\nexit code documented for a plumbing tool. We won't change it now without\na good reason and without a deprecation schedule, and IMHO this doesn't\nrise to that level.\n\n-Peff\n"},{"id":"461962","messageId":"xmqqk06w2sui.fsf@gitster.g","threadId":"58358","inReplyTo":"CAHckPJS6ibtxbU+VKwDaU6pFMtJ5SMcWnBi6D2pY+ekqpWsqXg@mail.gmail.com","subject":"Re: [BUG] git config --unset is not idempotent","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-08-25T16:25:25Z","receivedAt":"2022-08-25T16:25:32Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Arturo Seijas Fernandez <arturo.seijas@canonical.com> writes:\n\n> The command \"git config --unset [option]\" is not idempotent. It is\n> currently returning a success  code when the property had already been\n> set and a 5 error code otherwise.\n\n\"rm\" is not \"idempotent\", either.\n\n    echo >file\n    rm file ; echo $?\n    rm file ; echo $?\n\nThe \"git config --unset\" command signals the inability to unset a\nvariable when the variable to be unset does not even exist.\n"}]}