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

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

From
Jeff King <peff@peff.net>
Date
Oct 5, 2012, 00:29 UTC
Message-ID
<20121005002942.GB17586@sigill.intra.peff.net>
In-Reply-To
<7v391uyr2w.fsf@alter.siamese.dyndns.org>
On Thu, Oct 04, 2012 at 12:28:39PM -0700, Junio C Hamano wrote:
Show 14 quoted lines
> Ben Olive <sionide21@gmail.com> writes:
> 
> > 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:
> 
> Don't do that, then ;-)
> 
> I think we have a change that is already cooking.
> 
> Ben (Walton), want to add a test for your 0971e99 (Remove the hard
> coded length limit on variable names in config files, 2012-09-30)
> before it hits 'next', perhaps?
I came up with this test earlier today when responding in this thread:
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index be9672e..a32ecd9 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -454,6 +454,11 @@ test_expect_success \
     'checkout with --track, but without -b, fails with too short tracked name' '
     test_must_fail git checkout --track renamer'
 
+test_expect_success 'checkout tracking with long branch name' '
+	z200=$_z40$_z40$_z40$_z40$_z40
+	git checkout --track -b foo-$z200
+'
+
 setup_conflicting_index () {
 	rm -f .git/index &&
 	O=$(echo original | git hash-object -w --stdin) &&

but it feels a little fake. Why 200? Because that will test the config
limit, but will not overflow the NAME_MAX limit (at least not on
Linux! No clue on other platforms) when we try to create
refs/heads/foo-$z200.

So while this is a nice concrete user-visible impact of Ben's patch, I
think it is a little flaky to be testing. We should probably have a
straight config test in t1303, though.

-Peff
Previous: Junio C HamanoNext: Andrew Ardill
Message 4 of 6 in “Super long branch names corrupt `.git/config`”
  1. Ben OliveOct 4, 2012
  2. Jeff KingOct 4, 2012
  3. Junio C HamanoOct 4, 2012
  4. Jeff KingOct 5, 2012
  5. Andrew ArdillOct 5, 2012
  6. Jeff KingOct 5, 2012

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.