From 4322842acfaace812308f8aec0fe39a358f3c6f2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Wed, 15 Dec 2010 16:02:54 +0700 Subject: [PATCH] get_sha1: handle special case $commit^{/} MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- sha1_name.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sha1_name.c b/sha1_name.c index 1ba4bc3b68..c5c59ced7f 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); -- 2.11.4.GIT