* [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
@ 2007-10-05 3:09 Sam Vilain
2007-10-05 3:16 ` Johannes Schindelin
2007-10-05 6:51 ` Alex Riesen
0 siblings, 2 replies; 6+ messages in thread
From: Sam Vilain @ 2007-10-05 3:09 UTC (permalink / raw)
To: git; +Cc: Sam Vilain
If the repository got mangled by FAT capitalization rules, then a ref
such as "HEAD" will become "head" once it is back on a non-FAT FS.
Check for this condition in resolve_refs and in the setup code.
Suggested-by: Francois Marier <francois@debian.org>
Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
---
This should probably help people putting their git repos on
FAT USB sticks.
refs.c | 28 ++++++++++++++++++++++++----
setup.c | 7 +++++--
2 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/refs.c b/refs.c
index 09a2c87..89ffb15 100644
--- a/refs.c
+++ b/refs.c
@@ -400,10 +400,30 @@ const char *resolve_ref(const char *ref, unsigned char *sha1, int reading, int *
}
list = list->next;
}
- if (reading || errno != ENOENT)
- return NULL;
- hashclr(sha1);
- return ref;
+ if (reading || errno != ENOENT) {
+ /*
+ * Hack for FAT-mangled ref filenames
+ */
+ if (strlen(ref) <= 8) {
+ char lc_name[9];
+ char* i;
+ strncpy(&lc_name, ref, 9);
+ for (i = lc_name; *i; i++) {
+ *i = tolower(*i);
+ }
+ path = git_path("%s", lc_name);
+ if (lstat(path, &st) < 0) {
+ return NULL;
+ }
+ }
+ else {
+ return NULL;
+ }
+ }
+ else {
+ hashclr(sha1);
+ return ref;
+ }
}
/* Follow "normalized" - ie "refs/.." symlinks by hand */
diff --git a/setup.c b/setup.c
index 06004f1..284d7b9 100644
--- a/setup.c
+++ b/setup.c
@@ -168,8 +168,11 @@ static int is_git_directory(const char *suspect)
return 0;
strcpy(path + len, "/HEAD");
- if (validate_headref(path))
- return 0;
+ if (validate_headref(path)) {
+ strcpy(path + len, "/head");
+ if (validate_headref(path))
+ return 0;
+ }
return 1;
}
--
1.5.3.2.3.g2f2dcc-dirty
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
2007-10-05 3:09 [PATCH] setup/rev-parse: allow HEAD to be spelled 'head' Sam Vilain
@ 2007-10-05 3:16 ` Johannes Schindelin
2007-10-05 6:51 ` Alex Riesen
1 sibling, 0 replies; 6+ messages in thread
From: Johannes Schindelin @ 2007-10-05 3:16 UTC (permalink / raw)
To: Sam Vilain; +Cc: git
Hi,
On Fri, 5 Oct 2007, Sam Vilain wrote:
> If the repository got mangled by FAT capitalization rules, then a ref
> such as "HEAD" will become "head" once it is back on a non-FAT FS.
Can we have that optionally, please? I.e. triggered by something like
"core.caseChallengedFS = true"?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
2007-10-05 3:09 [PATCH] setup/rev-parse: allow HEAD to be spelled 'head' Sam Vilain
2007-10-05 3:16 ` Johannes Schindelin
@ 2007-10-05 6:51 ` Alex Riesen
2007-10-06 22:23 ` Sam Vilain
1 sibling, 1 reply; 6+ messages in thread
From: Alex Riesen @ 2007-10-05 6:51 UTC (permalink / raw)
To: Sam Vilain; +Cc: git
Sam Vilain, Fri, Oct 05, 2007 05:09:10 +0200:
> If the repository got mangled by FAT capitalization rules, then a ref
> such as "HEAD" will become "head" once it is back on a non-FAT FS.
> Check for this condition in resolve_refs and in the setup code.
>
> Suggested-by: Francois Marier <francois@debian.org>
> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
> ---
> This should probably help people putting their git repos on
> FAT USB sticks.
Can the people just mount FAT partitions with shortname=mixed?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
2007-10-05 6:51 ` Alex Riesen
@ 2007-10-06 22:23 ` Sam Vilain
2007-10-07 16:49 ` Johannes Schindelin
0 siblings, 1 reply; 6+ messages in thread
From: Sam Vilain @ 2007-10-06 22:23 UTC (permalink / raw)
To: Alex Riesen; +Cc: git, Johannes Schindelin
Alex Riesen wrote:
> Sam Vilain, Fri, Oct 05, 2007 05:09:10 +0200:
>> If the repository got mangled by FAT capitalization rules, then a ref
>> such as "HEAD" will become "head" once it is back on a non-FAT FS.
>> Check for this condition in resolve_refs and in the setup code.
>>
>> Suggested-by: Francois Marier <francois@debian.org>
>> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
>> ---
>> This should probably help people putting their git repos on
>> FAT USB sticks.
>
> Can the people just mount FAT partitions with shortname=mixed?
Of course, that is probably a solution to the problem, whereas my patch
is a workaround.
Now, I realise that this might open a can of worms ... would we also
want to go looking for files called "pack-ab~1.pac" ? Almost certainly
not - but this solves the most immediate problem experienced by people
putting their git repositories onto FAT filesystems mounted with the
default options, which will say "FATAL: not a git repository" otherwise.
Sam.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
2007-10-06 22:23 ` Sam Vilain
@ 2007-10-07 16:49 ` Johannes Schindelin
2007-10-07 22:23 ` Sam Vilain
0 siblings, 1 reply; 6+ messages in thread
From: Johannes Schindelin @ 2007-10-07 16:49 UTC (permalink / raw)
To: Sam Vilain; +Cc: Alex Riesen, git
Hi,
On Sun, 7 Oct 2007, Sam Vilain wrote:
> Alex Riesen wrote:
> > Sam Vilain, Fri, Oct 05, 2007 05:09:10 +0200:
> >> If the repository got mangled by FAT capitalization rules, then a ref
> >> such as "HEAD" will become "head" once it is back on a non-FAT FS.
> >> Check for this condition in resolve_refs and in the setup code.
> >>
> >> Suggested-by: Francois Marier <francois@debian.org>
> >> Signed-off-by: Sam Vilain <sam.vilain@catalyst.net.nz>
> >> ---
> >> This should probably help people putting their git repos on
> >> FAT USB sticks.
> >
> > Can the people just mount FAT partitions with shortname=mixed?
>
> Of course, that is probably a solution to the problem, whereas my patch
> is a workaround.
>
> Now, I realise that this might open a can of worms ... would we also
> want to go looking for files called "pack-ab~1.pac" ?
Hell, no.
> Almost certainly not - but this solves the most immediate problem
> experienced by people putting their git repositories onto FAT
> filesystems mounted with the default options, which will say "FATAL: not
> a git repository" otherwise.
You certainly mean the issue of capitalization; yes, that is my
experience, too. Somehow, "HEAD" is the culprit.
Ciao,
Dscho
P.S.: seems you have quite cute coworkers.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
2007-10-07 16:49 ` Johannes Schindelin
@ 2007-10-07 22:23 ` Sam Vilain
0 siblings, 0 replies; 6+ messages in thread
From: Sam Vilain @ 2007-10-07 22:23 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
Johannes Schindelin wrote:
> P.S.: seems you have quite cute coworkers.
http://xkcd.com/322/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-10-07 22:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-05 3:09 [PATCH] setup/rev-parse: allow HEAD to be spelled 'head' Sam Vilain
2007-10-05 3:16 ` Johannes Schindelin
2007-10-05 6:51 ` Alex Riesen
2007-10-06 22:23 ` Sam Vilain
2007-10-07 16:49 ` Johannes Schindelin
2007-10-07 22:23 ` Sam Vilain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).