{"thread":{"id":"10152","subject":"[PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","startedAt":"2007-10-05T03:09:10Z","lastAt":"2007-10-07T22:23:07Z","messageCount":6,"participants":["Sam Vilain","Johannes Schindelin","Alex Riesen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"54901","messageId":"1191553750-25562-1-git-send-email-sam.vilain@catalyst.net.nz","threadId":"10152","inReplyTo":null,"subject":"[PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-10-05T03:09:10Z","receivedAt":"2007-10-05T03:09:10Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"If the repository got mangled by FAT capitalization rules, then a ref\nsuch as \"HEAD\" will become \"head\" once it is back on a non-FAT FS.\nCheck for this condition in resolve_refs and in the setup code.\n\nSuggested-by: Francois Marier <francois@debian.org>\nSigned-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>\n---\n  This should probably help people putting their git repos on\n  FAT USB sticks.\n\n refs.c  |   28 ++++++++++++++++++++++++----\n setup.c |    7 +++++--\n 2 files changed, 29 insertions(+), 6 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex 09a2c87..89ffb15 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -400,10 +400,30 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *\n \t\t\t\t}\n \t\t\t\tlist = list->next;\n \t\t\t}\n-\t\t\tif (reading || errno != ENOENT)\n-\t\t\t\treturn NULL;\n-\t\t\thashclr(sha1);\n-\t\t\treturn ref;\n+\t\t\tif (reading || errno != ENOENT) {\n+\t\t\t\t/*\n+\t\t\t\t * Hack for FAT-mangled ref filenames\n+\t\t\t\t */\n+\t\t\t\tif (strlen(ref) <= 8) {\n+\t\t\t\t\tchar lc_name[9];\n+\t\t\t\t\tchar* i;\n+\t\t\t\t\tstrncpy(&lc_name, ref, 9);\n+\t\t\t\t\tfor (i = lc_name; *i; i++) {\n+\t\t\t\t\t\t*i = tolower(*i);\n+\t\t\t\t\t}\n+\t\t\t\t\tpath = git_path(\"%s\", lc_name);\n+\t\t\t\t\tif (lstat(path, &st) < 0) {\n+\t\t\t\t\t\treturn NULL;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\telse {\n+\t\t\t\t\treturn NULL;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\telse {\n+\t\t\t\thashclr(sha1);\n+\t\t\t\treturn ref;\n+\t\t\t}\n \t\t}\n \n \t\t/* Follow \"normalized\" - ie \"refs/..\" symlinks by hand */\ndiff --git a/setup.c b/setup.c\nindex 06004f1..284d7b9 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -168,8 +168,11 @@ static int is_git_directory(const char *suspect)\n \t\treturn 0;\n \n \tstrcpy(path + len, \"/HEAD\");\n-\tif (validate_headref(path))\n-\t\treturn 0;\n+\tif (validate_headref(path)) {\n+\t\tstrcpy(path + len, \"/head\");\n+\t\tif (validate_headref(path))\n+\t\t\treturn 0;\n+\t}\n \n \treturn 1;\n }\n-- \n1.5.3.2.3.g2f2dcc-dirty\n"},{"id":"54903","messageId":"Pine.LNX.4.64.0710050415080.4174@racer.site","threadId":"10152","inReplyTo":"1191553750-25562-1-git-send-email-sam.vilain@catalyst.net.nz","subject":"Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-05T03:16:18Z","receivedAt":"2007-10-05T03:16:18Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 5 Oct 2007, Sam Vilain wrote:\n\n> If the repository got mangled by FAT capitalization rules, then a ref \n> such as \"HEAD\" will become \"head\" once it is back on a non-FAT FS.\n\nCan we have that optionally, please?  I.e. triggered by something like \n\"core.caseChallengedFS = true\"?\n\nCiao,\nDscho\n"},{"id":"54909","messageId":"20071005065139.GA2623@steel.home","threadId":"10152","inReplyTo":"1191553750-25562-1-git-send-email-sam.vilain@catalyst.net.nz","subject":"Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-10-05T06:51:39Z","receivedAt":"2007-10-05T06:51:39Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"Sam Vilain, Fri, Oct 05, 2007 05:09:10 +0200:\n> If the repository got mangled by FAT capitalization rules, then a ref\n> such as \"HEAD\" will become \"head\" once it is back on a non-FAT FS.\n> Check for this condition in resolve_refs and in the setup code.\n> \n> Suggested-by: Francois Marier <francois@debian.org>\n> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>\n> ---\n>   This should probably help people putting their git repos on\n>   FAT USB sticks.\n\nCan the people just mount FAT partitions with shortname=mixed?\n"},{"id":"55030","messageId":"47080AC4.3040902@catalyst.net.nz","threadId":"10152","inReplyTo":"20071005065139.GA2623@steel.home","subject":"Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-10-06T22:23:00Z","receivedAt":"2007-10-06T22:23:00Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Alex Riesen wrote:\n> Sam Vilain, Fri, Oct 05, 2007 05:09:10 +0200:\n>> If the repository got mangled by FAT capitalization rules, then a ref\n>> such as \"HEAD\" will become \"head\" once it is back on a non-FAT FS.\n>> Check for this condition in resolve_refs and in the setup code.\n>>\n>> Suggested-by: Francois Marier <francois@debian.org>\n>> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>\n>> ---\n>>   This should probably help people putting their git repos on\n>>   FAT USB sticks.\n> \n> Can the people just mount FAT partitions with shortname=mixed?\n\nOf course, that is probably a solution to the problem, whereas my patch\nis a workaround.\n\nNow, I realise that this might open a can of worms ... would we also\nwant to go looking for files called \"pack-ab~1.pac\" ?  Almost certainly\nnot - but this solves the most immediate problem experienced by people\nputting their git repositories onto FAT filesystems mounted with the\ndefault options, which will say \"FATAL: not a git repository\" otherwise.\n\nSam.\n"},{"id":"55068","messageId":"Pine.LNX.4.64.0710071747340.4174@racer.site","threadId":"10152","inReplyTo":"47080AC4.3040902@catalyst.net.nz","subject":"Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-07T16:49:09Z","receivedAt":"2007-10-07T16:49:09Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 7 Oct 2007, Sam Vilain wrote:\n\n> Alex Riesen wrote:\n> > Sam Vilain, Fri, Oct 05, 2007 05:09:10 +0200:\n> >> If the repository got mangled by FAT capitalization rules, then a ref\n> >> such as \"HEAD\" will become \"head\" once it is back on a non-FAT FS.\n> >> Check for this condition in resolve_refs and in the setup code.\n> >>\n> >> Suggested-by: Francois Marier <francois@debian.org>\n> >> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>\n> >> ---\n> >>   This should probably help people putting their git repos on\n> >>   FAT USB sticks.\n> > \n> > Can the people just mount FAT partitions with shortname=mixed?\n> \n> Of course, that is probably a solution to the problem, whereas my patch\n> is a workaround.\n> \n> Now, I realise that this might open a can of worms ... would we also\n> want to go looking for files called \"pack-ab~1.pac\" ?\n\nHell, no.\n\n> Almost certainly not - but this solves the most immediate problem \n> experienced by people putting their git repositories onto FAT \n> filesystems mounted with the default options, which will say \"FATAL: not \n> a git repository\" otherwise.\n\nYou certainly mean the issue of capitalization; yes, that is my \nexperience, too.  Somehow, \"HEAD\" is the culprit.\n\nCiao,\nDscho\n\nP.S.: seems you have quite cute coworkers.\n"},{"id":"55101","messageId":"47095C4B.6030209@catalyst.net.nz","threadId":"10152","inReplyTo":"Pine.LNX.4.64.0710071747340.4174@racer.site","subject":"Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'","fromName":"Sam Vilain","fromEmail":"sam.vilain@catalyst.net.nz","sentAt":"2007-10-07T22:23:07Z","receivedAt":"2007-10-07T22:23:07Z","isPatch":true,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> P.S.: seems you have quite cute coworkers.\n\nhttp://xkcd.com/322/\n"}]}