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

Re: Minor bug in git branch --set-upstream-to adding superfluous branch section to config

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 29, 2013, 17:27 UTC
Message-ID
<7v4nfup14c.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAD7mMPW=jr6PaAc50h-Wpf42-UPrn0A5KmisqXNXqqLv78AEgg@mail.gmail.com>
Phil Haack <haacked@gmail.com> writes:
Show 5 quoted lines
> Hello there! Please /cc me with responses as I'm not on the mailing list.
>
> I'm using git version 1.8.1.msysgit.1 and I ran into a very minor issue. It
> doesn't actually seem to affect operations, but I thought I'd report it in case
> someone felt it was worth cleaning up.
I do not think this is limited to "branch --set-whatever".
Show 6 quoted lines
> If you run the following set of commands:
>
>     git checkout -b some-branch
>     git push origin some-branch
>     git branch --set-upstream-to origin/some-branch
>     git branch --unset-upstream some-branch

This step causes the removal of the last variable in a configuration section, which leaves an empty section. As the code to add a new variable to the configuration, trying to reuse an existing section header, does not pay attention to an empty section, you end up with an empty section, followed by a new one.

Either removal of configuration variable should be taught to remove the section header when a section becomes empty, or addition of configuration variable should be taught to notice an empty section header.

Show 8 quoted lines
>     git branch --set-upstream-to origin/some-branch
>
> You get the following result in the .git\config file
>
>     [branch "some-branch"]
>     [branch "some-branch"]
>         remote = origin
>         merge = refs/heads/some-branch
Previous: Junio C Hamano
Message 13 of 13 in “Minor bug in git branch --set-upstream-to adding superfluous branch section to config”
  1. Phil HaackMar 29, 2013
  2. Jeff KingMar 29, 2013
  3. Thomas RastMar 29, 2013
  4. Jeff KingMar 29, 2013
  5. t1300: document some aesthetic failures of the config editorJeff King, Mar 29, 2013
  6. Junio C HamanoMar 29, 2013
  7. Jeff KingMar 29, 2013
  8. Junio C HamanoMar 29, 2013
  9. Jeff KingMar 30, 2013
  10. Johannes SchindelinMar 28, 2018
  11. Jeff KingMar 28, 2018
  12. Junio C HamanoMar 29, 2013
  13. Junio C HamanoMar 29, 2013

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.