Skip to content

Commit 4322842

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent 32574b6 commit 4322842

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

sha1_name.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,13 @@ static int peel_onion(const char *name, int len, unsigned char *sha1)
599599
int ret;
600600
struct commit_list *list = NULL;
601601

602+
/*
603+
* $commit^{/}. Some regex implementation may reject.
604+
* We don't need regex anyway. '' pattern always matches.
605+
*/
606+
if (sp[1] == '}')
607+
return 0;
608+
602609
prefix = xstrndup(sp + 1, name + len - 1 - (sp + 1));
603610
commit_list_insert((struct commit *)o, &list);
604611
ret = get_sha1_oneline(prefix, sha1, list);

0 commit comments

Comments
 (0)