Super long branch names corrupt `.git/config`

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Super long branch names corrupt `.git/config`

From: Ben Olive <hidden>
Date: 2016-06-15 22:54:56

My `.git/config` can be corrupted if I try to get a local branch with
an extremely long name to track a remote branch.

Here is a (contrived) example to reproduce the issue:


    $ cd /tmp
    $ mkdir buggyrepo otherrepo
    $ cd buggyrepo/ && git init && cd -
    $ cd otherrepo/ && git init && cd -
    $ cd buggyrepo/
    $ echo foo > MYFILE
    $ git add MYFILE && git commit -m "Initial"
    $ git remote add otherrepo ../otherrepo/
    $ git checkout -b `ruby -e "puts 'a'*200"`
    $ git push -u otherrepo `ruby -e "puts 'a'*200"`
    fatal: bad config file line 11 in .git/config
    $ git status
    fatal: bad config file line 11 in .git/config


Workaround available: Just delete the offending entry.

I tested this with 1.7.12.2

--Ben Olive

Re: Super long branch names corrupt `.git/config`

From: Jeff King <hidden>
Date: 2016-06-15 22:54:56

On Thu, Oct 04, 2012 at 01:15:25PM -0400, Ben Olive wrote:
My `.git/config` can be corrupted if I try to get a local branch with
an extremely long name to track a remote branch.

Here is a (contrived) example to reproduce the issue:


    $ cd /tmp
    $ mkdir buggyrepo otherrepo
    $ cd buggyrepo/ && git init && cd -
    $ cd otherrepo/ && git init && cd -
    $ cd buggyrepo/
    $ echo foo > MYFILE
    $ git add MYFILE && git commit -m "Initial"
    $ git remote add otherrepo ../otherrepo/
    $ git checkout -b `ruby -e "puts 'a'*200"`
    $ git push -u otherrepo `ruby -e "puts 'a'*200"`
    fatal: bad config file line 11 in .git/config
    $ git status
    fatal: bad config file line 11 in .git/config

Workaround available: Just delete the offending entry.

I tested this with 1.7.12.2
This is fixed by Ben Walton's 0971e99 (Remove the hard coded length
limit on variable names in config files, 2012-09-30). Not sure yet
whether it will make it into v1.8.0 or not.

However, note that the tracking config is only one limit to branch name
length. On many filesystems, you are limited to 256 bytes (or some other
number) per path component, and writing to "refs/heads/aaa{256}.lock"
will fail.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help