summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2010-12-15 09:02:54 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-12-16 21:11:42 (GMT)
commit4322842acfaace812308f8aec0fe39a358f3c6f2 (patch)
tree31cb3e55eccfa2f4aa3d58985866a3870f85faf0 /sha1_name.c
parent32574b68c57f3b34e58216a4c9c6d570d11ec47b (diff)
downloadgit-4322842acfaace812308f8aec0fe39a358f3c6f2.zip
git-4322842acfaace812308f8aec0fe39a358f3c6f2.tar.gz
git-4322842acfaace812308f8aec0fe39a358f3c6f2.tar.bz2
get_sha1: handle special case $commit^{/}
Empty regex pattern should always match. But the exact behavior of regexec() may vary. Because it always matches anyway, we can just return 'matched' without calling regex machinery. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 1ba4bc3..c5c59ce 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -599,6 +599,13 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
int ret;
struct commit_list *list = NULL;
+ /*
+ * $commit^{/}. Some regex implementation may reject.
+ * We don't need regex anyway. '' pattern always matches.
+ */
+ if (sp[1] == '}')
+ return 0;
+
prefix = xstrndup(sp + 1, name + len - 1 - (sp + 1));
commit_list_insert((struct commit *)o, &list);
ret = get_sha1_oneline(prefix, sha1, list);