summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e49521b)
raw | patch | inline | side by side (parent: e49521b)
author | Junio C Hamano <junkio@cox.net> | |
Wed, 20 Sep 2006 23:11:08 +0000 (16:11 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Wed, 20 Sep 2006 23:11:08 +0000 (16:11 -0700) |
Signed-off-by: Junio C Hamano <junkio@cox.net>
sha1_name.c | patch | blob | history |
diff --git a/sha1_name.c b/sha1_name.c
index 1fbc4438059b68f31aa25fb8e3b82b37a4d02819..9b226e3579b68fe8b59c7105bd926e3a0a70b0ad 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
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;
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);
}