From 84201eae771fbb1d774cf1356d89016053e56778 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Wed, 3 Jun 2009 18:19:01 +0200 Subject: [PATCH 1/2] grep: fix empty word-regexp matches The command "git grep -w ''" dies as soon as it encounters an empty line, reporting (wrongly) that "regexp returned nonsense". The first hunk of this patch relaxes the sanity check that is responsible for that, allowing matches to start at the end. The second hunk complements it by making sure that empty matches are rejected if -w was specified, as they are not really words. GNU grep does the same: $ echo foo | grep -c '' 1 $ echo foo | grep -c -w '' 0 Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- grep.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grep.c b/grep.c index 7bf4a60ac7..92a47c71e7 100644 --- a/grep.c +++ b/grep.c @@ -331,7 +331,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol, if (hit && p->word_regexp) { if ((pmatch[0].rm_so < 0) || - (eol - bol) <= pmatch[0].rm_so || + (eol - bol) < pmatch[0].rm_so || (pmatch[0].rm_eo < 0) || (eol - bol) < pmatch[0].rm_eo) die("regexp returned nonsense"); @@ -350,6 +350,10 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol, else hit = 0; + /* Words consist of at least one character. */ + if (pmatch->rm_so == pmatch->rm_eo) + hit = 0; + if (!hit && pmatch[0].rm_so + bol + 1 < eol) { /* There could be more than one match on the * line, and the first match might not be From 6c7f58d6f691c1091b90b0891e94c91e20fd6054 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 3 Jun 2009 22:42:15 -0700 Subject: [PATCH 2/2] GIT 1.6.3.2 Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.6.3.2.txt | 12 +++++------- GIT-VERSION-GEN | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Documentation/RelNotes-1.6.3.2.txt b/Documentation/RelNotes-1.6.3.2.txt index 0b48d1a1df..b2f3f0293c 100644 --- a/Documentation/RelNotes-1.6.3.2.txt +++ b/Documentation/RelNotes-1.6.3.2.txt @@ -37,13 +37,17 @@ Fixes since v1.6.3.1 the first hunk that adds a line at the top was split into two and both halves are marked to be used. + * "git blame path" misbehaved at the commit where path became file + from a directory with some files in it. + * "git for-each-ref" had a segfaulting bug when dealing with a tag object created by an ancient git. * "git format-patch -k" still added patch numbers if format.numbered configuration was set. - * "git grep --color ''" did not terminate. + * "git grep --color ''" did not terminate. The command also had + subtle bugs with its -w option. * http-push had a small use-after-free bug. @@ -55,9 +59,3 @@ Fixes since v1.6.3.1 Many other general usability updates around help text, diagnostic messages and documentation are included as well. - ---- -exec >/var/tmp/1 -O=v1.6.3.1-68-g456cb4c -echo O=$(git describe maint) -git shortlog --no-merges $O..maint diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index d292e3a2d3..0673f0db9f 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -1,7 +1,7 @@ #!/bin/sh GVF=GIT-VERSION-FILE -DEF_VER=v1.6.3.1 +DEF_VER=v1.6.3.2 LF=' '