diff.c: Ensure "index $from..$to" line contains unambiguous SHA1s
authorJohan Herland <johan@herland.net>
Sun, 30 May 2010 13:37:17 +0000 (15:37 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 1 Jun 2010 00:44:01 +0000 (17:44 -0700)
commit3e5a188f1d5b48dcc0bc73ad520925cdb846dfaf
tree126ef36605cca11b458eeee5c9e4150a4effe553
parent81fa024cd8e336ba257f13fe7724b95baacfa3ad
diff.c: Ensure "index $from..$to" line contains unambiguous SHA1s

In the metainfo section of git diffs there's an "index" line providing
abbreviated (unless --full-index is used) blob SHA1s from the
pre-/post-images used to generate the diff. These provide hints that
can be used to reconstruct a 3-way merge when applying the patch
(see the --3way option to 'git am' for more details).

In order for this to work, however, the blob SHA1s must not be
abbreviated into ambiguity.

This patch eliminates the possible ambiguity by using find_unique_abbrev()
to produce the abbreviated SHA1s (instead of blind abbreviation by way of
"%.*s").

A testcase verifying the fix is also included.

Signed-off-by: Johan Herland <johan@herland.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4044-diff-index-unique-abbrev.sh [new file with mode: 0755]