summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-09-11 20:17:35 -0700
committerJunio C Hamano <junkio@cox.net>2006-09-17 19:09:11 -0700
commited378ec7e85fd2c5cfcc7bd64b454236357fdd97 (patch)
tree76a1666618aff73fd9184a533273b1e083858a6d /sha1_name.c
parentb37a562a1097af7403c649a5f903a93acaf279e8 (diff)
downloadgit-ed378ec7e85fd2c5cfcc7bd64b454236357fdd97.tar.gz
Make ref resolution saner
The old code used to totally mix up the notion of a ref-name and the path that that ref was associated with. That was not only horribly ugly (a number of users got the path, and then wanted to try to turn it back into a ref-name again), but it fundamnetally doesn't work at all once we do any setup where a ref doesn't have a 1:1 relationship with a particular pathname. This fixes things up so that we use the ref-name throughout, and only turn it into a pathname once we actually look it up in the filesystem. That makes a lot of things much clearer and more straightforward. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 1fbc443805..b4975289d5 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -247,8 +247,8 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
NULL
};
static const char *warning = "warning: refname '%.*s' is ambiguous.\n";
- const char **p, *pathname;
- char *real_path = NULL;
+ const char **p, *ref;
+ char *real_ref = NULL;
int refs_found = 0, am;
unsigned long at_time = (unsigned long)-1;
unsigned char *this_result;
@@ -276,10 +276,10 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
for (p = fmt; *p; p++) {
this_result = refs_found ? sha1_from_ref : sha1;
- pathname = resolve_ref(git_path(*p, len, str), this_result, 1);
- if (pathname) {
+ ref = resolve_ref(mkpath(*p, len, str), this_result, 1);
+ if (ref) {
if (!refs_found++)
- real_path = xstrdup(pathname);
+ real_ref = xstrdup(ref);
if (!warn_ambiguous_refs)
break;
}
@@ -293,12 +293,12 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
if (at_time != (unsigned long)-1) {
read_ref_at(
- real_path + strlen(git_path(".")) - 1,
+ real_ref,
at_time,
sha1);
}
- free(real_path);
+ free(real_ref);
return 0;
}