Browse Source

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>
maint
Nguyễn Thái Ngọc Duy 14 years ago committed by Junio C Hamano
parent
commit
4322842acf
  1. 7
      sha1_name.c

7
sha1_name.c

@ -599,6 +599,13 @@ static int peel_onion(const char *name, int len, unsigned char *sha1) @@ -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);

Loading…
Cancel
Save