Bug: duplicate sections in .git/config after remote removal
- From
- Jason Frey <jfrey@redhat.com>
- Date
- Mar 27, 2018, 20:41 UTC
- Message-ID
- <CAP6Vx84GRRxgMZF5P6tb6F4rJ8ozxx-d0o_LsNe=kEYVRkBTKQ@mail.gmail.com>
While the impact of this bug is minimal, and git itself is not affected, it can affect external tools that want to read the .git/config file, expecting unique section names.
To reproduce:
Given the following example .git/config file (I am leaving out the [core] section for brevity):
[remote "origin"]
url = git@github.com:Fryguy/example.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/masterRunning `git remote rm origin` will result in the following contents:
[branch "master"]
Running `git remote add origin git@github.com:Fryguy/example.git` will result in the following contents:
[branch "master"]
[remote "origin"]
url = git@github.com:Fryguy/example.git
fetch = +refs/heads/*:refs/remotes/origin/*And finally, running `git fetch origin; git branch -u origin/master` will result in the following contents:
[branch "master"]
[remote "origin"]
url = git@github.com:Fryguy/example.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/masterat which point you can see the duplicate sections (even though one is empty). Also note that if you do the steps again, you will be left with 3 sections, 2 of which are empty. This process can be repeated over and over.
Thanks, Jason