{"thread":{"id":"32561","subject":"troublesome branch name in remote repo causes .git/config inconsistency in cloned repo","startedAt":"2013-01-08T18:30:58Z","lastAt":"2013-01-08T18:59:39Z","messageCount":2,"participants":["Pavel Pospíšil","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"206320","messageId":"CADDfn-L_VWk5Rkn_P8aTf3pwBcbbYT=PZTrG=pFvJpNjgRg-5A@mail.gmail.com","threadId":"32561","inReplyTo":null,"subject":"troublesome branch name in remote repo causes .git/config inconsistency in cloned repo","fromName":"Pavel Pospíšil","fromEmail":"pospispa@gmail.com","sentAt":"2013-01-08T18:30:58Z","receivedAt":"2013-01-08T18:30:58Z","isPatch":false,"sender":{"key":"pospispa@gmail.com","avatar":null},"body":"Hi,\nI think I came across a bug. I use git version 1.7.10.4 on Ubuntu\n12.10. I haven't tried to find out if it's a known bug.\n\nReproduction scenario:\n1. create a git repo:\n$ mkdir -p tmp/bezdek\n$ cd tmp/bezdek/\n$ echo \"*.swp\" > .gitignore\n$ git init\n$ git add .\n$ git commit -m \"Initial commit\"\n\n2. clone the \"remote\" repo:\n$ cd ../..\n$ mkdir -p tmp/cloned\n$ git clone ../bezdek/\n\n3. create the troublesome branch in the \"remote\" repo\n$ cd ../bezdek\n$ git checkout -b\nMCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\n$ echo \"*.bak\" >> .gitignore\n$ git add .\n$ git commit -m \"Some changes\"\n\n4. pull and checkout to the\nMCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\nbranch in the cloned repo\n$ cd ../cloned/bezdek\n$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = /home/pospispa/tmp/tmp/cloned/../bezdek/\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n$ git pull\nremote: Counting objects: 5, done.\nremote: Total 3 (delta 0), reused 0 (delta 0)\nUnpacking objects:  33% (1/3)\nUnpacking objects:  66% (2/3)\nUnpacking objects: 100% (3/3)\nUnpacking objects: 100% (3/3), done.\nFrom /home/pospispa/tmp/tmp/cloned/../bezdek\n * [new branch]\nMCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\n-> origin/MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\nAlready up-to-date.\n$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = /home/pospispa/tmp/tmp/cloned/../bezdek/\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n$ git checkout MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\nfatal: bad config file line 12 in .git/config\n$ cat .git/config\n[core]\n        repositoryformatversion = 0\n        filemode = true\n        bare = false\n        logallrefupdates = true\n[remote \"origin\"]\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = /home/pospispa/tmp/tmp/cloned/../bezdek/\n[branch \"master\"]\n        remote = origin\n        merge = refs/heads/master\n[branch \"MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\"]\n        remote = origin\n\nI think that the problem may be with the branch name length. I think\nthat git branch allows to created branches with very long names,\nhowever, such long name are not allowed in .git/config or the git\ncheckout <very-long-remote-branch-name> has some problems with it.\n\nI recovered from this problem in this way:\n1. deleted last two lines in tmp/cloned/bezdek/.git/config file and\ndeleted index and working tree\n$ git reset HEAD *\n$ git checkout -- *\n2. renamed the troublesome branch in \"remote\" repo:\n$ cd ../../bezdek\n$ git branch -m\nMCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\nMCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek\n3. pull from \"remote\" to cloned again\n$ cd ../cloned/bezdek\n$ git pull\nFrom /home/pospispa/tmp/tmp/cloned/../bezdek\n * [new branch]\nMCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek ->\norigin/MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek\nAlready up-to-date.\n$ git branch -r\n  origin/HEAD -> origin/master\n  origin/MCRD0106586-CR00023206-Configuration-management-of-MCO-shall-be-integrated-with-AMS-2.0-current-cm-config.xml-file-from-Peter-Bezdek\n  origin/MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek\n  origin/master\n$ git checkout MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek\nBranch MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek\nset up to track remote branch\nMCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek\nfrom origin.\nSwitched to a new branch\n'MCRD0106586-CR00023206-current-cm-config.xml-file-from-Peter-Bezdek'\n\nBest regards,\nPavel Pospisil\n"},{"id":"206324","messageId":"7v38ybec10.fsf@alter.siamese.dyndns.org","threadId":"32561","inReplyTo":"CADDfn-L_VWk5Rkn_P8aTf3pwBcbbYT=PZTrG=pFvJpNjgRg-5A@mail.gmail.com","subject":"Re: troublesome branch name in remote repo causes .git/config inconsistency in cloned repo","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-01-08T18:59:39Z","receivedAt":"2013-01-08T18:59:39Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pavel Pospíšil <pospispa@gmail.com> writes:\n\n> I think that the problem may be with the branch name length. I think\n> that git branch allows to created branches with very long names,\n> however, such long name are not allowed in .git/config ...\n\nI think we lifted this limit back in 1.8.0.1 timeframe.\n"}]}