From: Nguyễn Thái Ngọc Duy Date: Wed, 15 Dec 2010 09:02:54 +0000 (+0700) Subject: get_sha1: handle special case $commit^{/} X-Git-Tag: v1.7.4-rc0~19^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4322842acfaace812308f8aec0fe39a358f3c6f2;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/sha1_name.c b/sha1_name.c index 1ba4bc3b6..c5c59ced7 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);