From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Cc: "Jonathan Niedier" <jrnieder@gmail.com>,
"Kevin Ballard" <kevin@sb.org>, "Yann Dirson" <dirson@bertin.fr>,
"Jeff King" <peff@peff.net>, "Jakub Narebski" <jnareb@gmail.com>,
"Thiago Farina" <tfransosi@gmail.com>,
"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH] get_sha1: handle special case $commit^{/}
Date: Wed, 15 Dec 2010 16:02:54 +0700 [thread overview]
Message-ID: <1292403774-361-1-git-send-email-pclouds@gmail.com> (raw)
In-Reply-To: <AANLkTimy5MVkxDzXqzA8T4DHJmzsSAvwqVVzRvWw5KA0@mail.gmail.com>
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
next prev parent reply other threads:[~2010-12-15 9:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-13 3:01 [PATCH 1/3] get_sha1_oneline: do not leak or double free Nguyễn Thái Ngọc Duy
2010-12-13 3:01 ` [PATCH 2/3] get_sha1_oneline: let callers initialize the commit tips for traverse Nguyễn Thái Ngọc Duy
2010-12-13 3:01 ` [PATCH 3/3] get_sha1: support ref^{/regex} syntax Nguyễn Thái Ngọc Duy
2010-12-13 3:10 ` Nguyen Thai Ngoc Duy
2010-12-13 4:40 ` Jonathan Nieder
2010-12-15 0:50 ` Junio C Hamano
2010-12-15 1:58 ` Nguyen Thai Ngoc Duy
2010-12-15 2:56 ` Junio C Hamano
2010-12-15 3:12 ` Nguyen Thai Ngoc Duy
2010-12-15 9:02 ` Nguyễn Thái Ngọc Duy [this message]
2010-12-15 23:44 ` [PATCH] get_sha1: handle special case $commit^{/} Junio C Hamano
2010-12-16 0:23 ` Nguyen Thai Ngoc Duy
2010-12-13 6:12 ` [PATCH 1/3] get_sha1_oneline: do not leak or double free Junio C Hamano
2010-12-13 6:19 ` Junio C Hamano
2010-12-13 6:27 ` Nguyen Thai Ngoc Duy
2010-12-13 6:31 ` Junio C Hamano
2010-12-13 6:43 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292403774-361-1-git-send-email-pclouds@gmail.com \
--to=pclouds@gmail.com \
--cc=dirson@bertin.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=jrnieder@gmail.com \
--cc=kevin@sb.org \
--cc=peff@peff.net \
--cc=tfransosi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.