Skip to content

Commit

Permalink
Merge branch 'jk/maint-diff-grep-textconv' into maint
Browse files Browse the repository at this point in the history
"git diff -G<pattern>" did not honor textconv filter when looking
for changes.

* jk/maint-diff-grep-textconv:
  diff_grep: use textconv buffers for add/deleted files
  • Loading branch information
Junio C Hamano committed Nov 20, 2012
2 parents fd778c0 + b1c2f57 commit 35cae74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions diffcore-pickaxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
if (!mf2.ptr)
return 0; /* ignore unmerged */
/* created "two" -- does it have what we are looking for? */
hit = !regexec(regexp, p->two->data, 1, &regmatch, 0);
hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
} else if (!mf2.ptr) {
/* removed "one" -- did it have what we are looking for? */
hit = !regexec(regexp, p->one->data, 1, &regmatch, 0);
hit = !regexec(regexp, mf1.ptr, 1, &regmatch, 0);
} else {
/*
* We have both sides; need to run textual diff and see if
Expand Down
12 changes: 12 additions & 0 deletions t/t4030-diff-textconv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ test_expect_success 'status -v produces text' '
git reset --soft HEAD@{1}
'

test_expect_success 'grep-diff (-G) operates on textconv data (add)' '
echo one >expect &&
git log --root --format=%s -G0 >actual &&
test_cmp expect actual
'

test_expect_success 'grep-diff (-G) operates on textconv data (modification)' '
echo two >expect &&
git log --root --format=%s -G1 >actual &&
test_cmp expect actual
'

cat >expect.stat <<'EOF'
file | Bin 2 -> 4 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
Expand Down

0 comments on commit 35cae74

Please sign in to comment.