From: Sam Vilain <sam.vilain@catalyst.net.nz>
To: git@vger.kernel.org
Cc: Sam Vilain <sam.vilain@catalyst.net.nz>
Subject: [PATCH] setup/rev-parse: allow HEAD to be spelled 'head'
Date: Fri, 5 Oct 2007 16:09:10 +1300 [thread overview]
Message-ID: <1191553750-25562-1-git-send-email-sam.vilain@catalyst.net.nz> (raw)
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
next reply other threads:[~2007-10-05 3:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-05 3:09 Sam Vilain [this message]
2007-10-05 3:16 ` [PATCH] setup/rev-parse: allow HEAD to be spelled 'head' 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1191553750-25562-1-git-send-email-sam.vilain@catalyst.net.nz \
--to=sam.vilain@catalyst.net.nz \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).