diff options
author | Junio C Hamano <junkio@cox.net> | 2006-09-20 16:11:08 -0700 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-09-20 16:11:08 -0700 |
commit | 7dd45e15c259e44b1c8b5ffdfc0c3d002c7f642c (patch) | |
tree | c2cce44e68f5bb1c87d345785911c2cf80bf3d28 /sha1_name.c | |
parent | e49521b56d8715f46b93ee6bc95f7de9c6858365 (diff) | |
download | git-7dd45e15c259e44b1c8b5ffdfc0c3d002c7f642c.tar.gz |
sha1_name.c: understand "describe" output as a valid object name
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'sha1_name.c')
-rw-r--r-- | sha1_name.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/sha1_name.c b/sha1_name.c index 1fbc443805..9b226e3579 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -431,6 +431,26 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) return 0; } +static int get_describe_name(const char *name, int len, unsigned char *sha1) +{ + const char *cp; + + for (cp = name + len - 1; name + 2 <= cp; cp--) { + char ch = *cp; + if (hexval(ch) & ~0377) { + /* We must be looking at g in "SOMETHING-g" + * for it to be describe output. + */ + if (ch == 'g' && cp[-1] == '-') { + cp++; + len -= cp - name; + return get_short_sha1(cp, len, sha1, 1); + } + } + } + return -1; +} + static int get_sha1_1(const char *name, int len, unsigned char *sha1) { int ret, has_suffix; @@ -472,6 +492,12 @@ static int get_sha1_1(const char *name, int len, unsigned char *sha1) ret = get_sha1_basic(name, len, sha1); if (!ret) return 0; + + /* It could be describe output that is "SOMETHING-gXXXX" */ + ret = get_describe_name(name, len, sha1); + if (!ret) + return 0; + return get_short_sha1(name, len, sha1, 0); } |