diff: use pending "path" if it is available
authorJeff King <peff@peff.net>
Fri, 19 May 2017 12:59:15 +0000 (08:59 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 24 May 2017 01:59:27 +0000 (10:59 +0900)
commit158b06caee5f9ea2987f444b8e49bd2d678b187d
treec7038b47c4392461e760b97f0d4ef0d9a766f073
parentd04ec74b17138733463c0ca1024fdbb42be6096a
diff: use pending "path" if it is available

There's a subtle distinction between "name" and "path" for a
blob that we resolve: the name is what the user told us on
the command line, and the path is what we traversed when
finding the blob within a tree (if we did so).

When we diff blobs directly, we use "name", but "path" is
more likely to be useful to the user (it will find the
correct .gitattributes, and give them a saner diff header).

We still have to fall back to using the name for some cases
(i.e., any blob reference that isn't of the form tree:path).
That's the best we can do in such a case.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/diff.c
t/t4063-diff-blobs.sh