Skip to content

Commit a8f6109

Browse files
rudisgitster
authored andcommitted
diffcore-pickaxe: respect --no-textconv
git log -S doesn't respect --no-textconv: $ echo '*.txt diff=wrong' > .gitattributes $ git -c diff.wrong.textconv='xxx' log --no-textconv -Sfoo error: cannot run xxx: No such file or directory fatal: unable to read files to diff Reported-by: Matthieu Moy <[email protected]> Signed-off-by: Simon Ruderich <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7cdb9b4 commit a8f6109

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

diffcore-pickaxe.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
8686
if (diff_unmodified_pair(p))
8787
return 0;
8888

89-
textconv_one = get_textconv(p->one);
90-
textconv_two = get_textconv(p->two);
89+
if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
90+
textconv_one = get_textconv(p->one);
91+
textconv_two = get_textconv(p->two);
92+
}
9193

9294
mf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);
9395
mf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);
@@ -201,8 +203,10 @@ static int has_changes(struct diff_filepair *p, struct diff_options *o,
201203
if (!o->pickaxe[0])
202204
return 0;
203205

204-
textconv_one = get_textconv(p->one);
205-
textconv_two = get_textconv(p->two);
206+
if (DIFF_OPT_TST(o, ALLOW_TEXTCONV)) {
207+
textconv_one = get_textconv(p->one);
208+
textconv_two = get_textconv(p->two);
209+
}
206210

207211
/*
208212
* If we have an unmodified pair, we know that the count will be the

t/t4209-log-pickaxe.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ test_expect_success 'log -G -i (match)' '
8080
test_cmp expect actual
8181
'
8282

83+
test_expect_success 'log -G --textconv (missing textconv tool)' '
84+
echo "* diff=test" >.gitattributes &&
85+
test_must_fail git -c diff.test.textconv=missing log -Gfoo &&
86+
rm .gitattributes
87+
'
88+
89+
test_expect_success 'log -G --no-textconv (missing textconv tool)' '
90+
echo "* diff=test" >.gitattributes &&
91+
git -c diff.test.textconv=missing log -Gfoo --no-textconv >actual &&
92+
>expect &&
93+
test_cmp expect actual &&
94+
rm .gitattributes
95+
'
96+
8397
test_expect_success 'log -S (nomatch)' '
8498
git log -Spicked --format=%H >actual &&
8599
>expect &&
@@ -116,4 +130,18 @@ test_expect_success 'log -S -i (nomatch)' '
116130
test_cmp expect actual
117131
'
118132

133+
test_expect_success 'log -S --textconv (missing textconv tool)' '
134+
echo "* diff=test" >.gitattributes &&
135+
test_must_fail git -c diff.test.textconv=missing log -Sfoo &&
136+
rm .gitattributes
137+
'
138+
139+
test_expect_success 'log -S --no-textconv (missing textconv tool)' '
140+
echo "* diff=test" >.gitattributes &&
141+
git -c diff.test.textconv=missing log -Sfoo --no-textconv >actual &&
142+
>expect &&
143+
test_cmp expect actual &&
144+
rm .gitattributes
145+
'
146+
119147
test_done

0 commit comments

Comments
 (0)