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
This commit is contained in:
Junio C Hamano 2024-02-13 14:44:48 -08:00
commit 5071cb78a3
2 changed files with 14 additions and 1 deletions

3
diff.c
View file

@ -4384,7 +4384,8 @@ static void run_external_diff(const char *pgm,
add_external_diff_name(o->repo, &cmd.args, two);
if (other) {
strvec_push(&cmd.args, other);
strvec_push(&cmd.args, xfrm_msg);
if (xfrm_msg)
strvec_push(&cmd.args, xfrm_msg);
}
}

View file

@ -205,6 +205,18 @@ test_expect_success POSIXPERM,SYMLINKS 'diff --no-index normalizes: mode not lik
test_cmp expected actual
'
test_expect_success POSIXPERM 'external diff with mode-only change' '
echo content >not-executable &&
echo content >executable &&
chmod +x executable &&
echo executable executable $(test_oid zero) 100755 \
not-executable $(test_oid zero) 100644 not-executable \
>expect &&
test_expect_code 1 git -c diff.external=echo diff \
--no-index executable not-executable >actual &&
test_cmp expect actual
'
test_expect_success "diff --no-index treats '-' as stdin" '
cat >expect <<-EOF &&
diff --git a/- b/a/1