Skip to content

Commit 35cae74

Browse files
committed
Merge branch 'jk/maint-diff-grep-textconv' into maint
"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
2 parents fd778c0 + b1c2f57 commit 35cae74

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

diffcore-pickaxe.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
104104
if (!mf2.ptr)
105105
return 0; /* ignore unmerged */
106106
/* created "two" -- does it have what we are looking for? */
107-
hit = !regexec(regexp, p->two->data, 1, &regmatch, 0);
107+
hit = !regexec(regexp, mf2.ptr, 1, &regmatch, 0);
108108
} else if (!mf2.ptr) {
109109
/* removed "one" -- did it have what we are looking for? */
110-
hit = !regexec(regexp, p->one->data, 1, &regmatch, 0);
110+
hit = !regexec(regexp, mf1.ptr, 1, &regmatch, 0);
111111
} else {
112112
/*
113113
* We have both sides; need to run textual diff and see if

t/t4030-diff-textconv.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,18 @@ test_expect_success 'status -v produces text' '
8484
git reset --soft HEAD@{1}
8585
'
8686

87+
test_expect_success 'grep-diff (-G) operates on textconv data (add)' '
88+
echo one >expect &&
89+
git log --root --format=%s -G0 >actual &&
90+
test_cmp expect actual
91+
'
92+
93+
test_expect_success 'grep-diff (-G) operates on textconv data (modification)' '
94+
echo two >expect &&
95+
git log --root --format=%s -G1 >actual &&
96+
test_cmp expect actual
97+
'
98+
8799
cat >expect.stat <<'EOF'
88100
file | Bin 2 -> 4 bytes
89101
1 file changed, 0 insertions(+), 0 deletions(-)

0 commit comments

Comments
 (0)