[PATCH] get_sha1: handle special case $commit^{/}

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?=
Date: Wednesday, December 15, 2010 - 2:02 am

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>
---
 On top of nd/oneline-sha1-name-from-specific-ref

 sha1_name.c |    7 +++++++
 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);
-- 
1.7.3.3.476.g10a82

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/3] get_sha1_oneline: do not leak or double free, =?UTF-8?q?Nguy=E1=BB ..., (Sun Dec 12, 8:01 pm)
[PATCH 2/3] get_sha1_oneline: let callers initialize the c ..., =?UTF-8?q?Nguy=E1=BB ..., (Sun Dec 12, 8:01 pm)
[PATCH 3/3] get_sha1: support ref^{/regex} syntax, =?UTF-8?q?Nguy=E1=BB ..., (Sun Dec 12, 8:01 pm)
Re: [PATCH 3/3] get_sha1: support ref^{/regex} syntax, Nguyen Thai Ngoc Duy, (Sun Dec 12, 8:10 pm)
Re: [PATCH 3/3] get_sha1: support ref^{/regex} syntax, Jonathan Nieder, (Sun Dec 12, 9:40 pm)
Re: [PATCH 1/3] get_sha1_oneline: do not leak or double free, Junio C Hamano, (Sun Dec 12, 11:12 pm)
Re: [PATCH 1/3] get_sha1_oneline: do not leak or double free, Junio C Hamano, (Sun Dec 12, 11:19 pm)
Re: [PATCH 1/3] get_sha1_oneline: do not leak or double free, Nguyen Thai Ngoc Duy, (Sun Dec 12, 11:27 pm)
Re: [PATCH 1/3] get_sha1_oneline: do not leak or double free, Junio C Hamano, (Sun Dec 12, 11:31 pm)
Re: [PATCH 1/3] get_sha1_oneline: do not leak or double free, Junio C Hamano, (Sun Dec 12, 11:43 pm)
Re: [PATCH 3/3] get_sha1: support ref^{/regex} syntax, Junio C Hamano, (Tue Dec 14, 5:50 pm)
Re: [PATCH 3/3] get_sha1: support ref^{/regex} syntax, Nguyen Thai Ngoc Duy, (Tue Dec 14, 6:58 pm)
Re: [PATCH 3/3] get_sha1: support ref^{/regex} syntax, Junio C Hamano, (Tue Dec 14, 7:56 pm)
Re: [PATCH 3/3] get_sha1: support ref^{/regex} syntax, Nguyen Thai Ngoc Duy, (Tue Dec 14, 8:12 pm)
[PATCH] get_sha1: handle special case $commit^{/}, =?UTF-8?q?Nguy=E1=BB ..., (Wed Dec 15, 2:02 am)
Re: [PATCH] get_sha1: handle special case $commit^{/}, Junio C Hamano, (Wed Dec 15, 4:44 pm)
Re: [PATCH] get_sha1: handle special case $commit^{/}, Nguyen Thai Ngoc Duy, (Wed Dec 15, 5:23 pm)