Skip to content

Commit 5071cb7

Browse files
committed
Merge branch 'jk/diff-external-with-no-index' into maint-2.43
"git diff --no-index file1 file2" segfaulted while invoking the external diff driver, which has been corrected. * jk/diff-external-with-no-index: diff: handle NULL meta-info when spawning external diff
2 parents d982de5 + 85a9a63 commit 5071cb7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4384,7 +4384,8 @@ static void run_external_diff(const char *pgm,
43844384
add_external_diff_name(o->repo, &cmd.args, two);
43854385
if (other) {
43864386
strvec_push(&cmd.args, other);
4387-
strvec_push(&cmd.args, xfrm_msg);
4387+
if (xfrm_msg)
4388+
strvec_push(&cmd.args, xfrm_msg);
43884389
}
43894390
}
43904391

t/t4053-diff-no-index.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,18 @@ test_expect_success POSIXPERM,SYMLINKS 'diff --no-index normalizes: mode not lik
205205
test_cmp expected actual
206206
'
207207

208+
test_expect_success POSIXPERM 'external diff with mode-only change' '
209+
echo content >not-executable &&
210+
echo content >executable &&
211+
chmod +x executable &&
212+
echo executable executable $(test_oid zero) 100755 \
213+
not-executable $(test_oid zero) 100644 not-executable \
214+
>expect &&
215+
test_expect_code 1 git -c diff.external=echo diff \
216+
--no-index executable not-executable >actual &&
217+
test_cmp expect actual
218+
'
219+
208220
test_expect_success "diff --no-index treats '-' as stdin" '
209221
cat >expect <<-EOF &&
210222
diff --git a/- b/a/1

0 commit comments

Comments
 (0)