diff.c: Ensure "index $from..$to" line contains unambiguous SHA1s
[gitweb.git] / diff.c
diff --git a/diff.c b/diff.c
index 494f5601e97e7395e647296bc7f8090331a47c43..1aefa663752965169c8cc5e0e40147c956bc4917 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -2419,9 +2419,9 @@ static void fill_metainfo(struct strbuf *msg,
                            (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
                                abbrev = 40;
                }
-               strbuf_addf(msg, "index %.*s..%.*s",
-                           abbrev, sha1_to_hex(one->sha1),
-                           abbrev, sha1_to_hex(two->sha1));
+               strbuf_addf(msg, "index %s..",
+                           find_unique_abbrev(one->sha1, abbrev));
+               strbuf_addstr(msg, find_unique_abbrev(two->sha1, abbrev));
                if (one->mode == two->mode)
                        strbuf_addf(msg, " %06o", one->mode);
                strbuf_addch(msg, '\n');