diff: support ^! for merges
commita79c6b60817c74534815bf132f0b26aa8e325874
authorRené Scharfe <l.s.r@web.de>
Sat, 1 Oct 2022 10:28:07 +0000 (1 12:28 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 1 Oct 2022 22:58:38 +0000 (1 15:58 -0700)
tree2286856152f99d1faa6ff41bc50689277657251e
parent9f91da752fa28e405e91dfd6bd7372f897bbae8d
diff: support ^! for merges

revision.c::handle_revision_arg_1() resolves <rev>^! by first adding the
negated parents and then <rev> itself.  builtin_diff_combined() expects
the first tree to be the merge and the remaining ones to be the parents,
though.  This mismatch results in bogus diff output.

Remember the first tree that doesn't belong to a parent and use it
instead of blindly picking the first one.  This makes "git diff <rev>^!"
consistent with "git show <rev>^!".

Reported-by: Tim Jaacks <tim.jaacks@garz-fricke.com>
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-diff.txt
builtin/diff.c
t/t4038-diff-combined.sh