diff --binary generates full index on binary files.
... without --full-index. Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Sep 7, 2006 at 00:54 UTC
82793c55e45ea1c7306ff396d8ce316241e584da
1 file changed
+7
-1
diff.c
+7
-1
@@ -1588,6 +1588,12 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
1588
if (hashcmp(one->sha1, two->sha1)) {
1589
int abbrev = o->full_index ? 40 : DEFAULT_ABBREV;
1590
1591
+ if (o->binary) {
1592
+ mmfile_t mf;
1593
+ if ((!fill_mmfile(&mf, one) && mmfile_is_binary(&mf)) ||
1594
+ (!fill_mmfile(&mf, two) && mmfile_is_binary(&mf)))
1595
+ abbrev = 40;
1596
+ }
1597
len += snprintf(msg + len, sizeof(msg) - len,
1598
"index %.*s..%.*s",
1599
abbrev, sha1_to_hex(one->sha1),
@@ -1818,7 +1824,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
1824
options->full_index = 1;
1825
else if (!strcmp(arg, "--binary")) {
1826
options->output_format |= DIFF_FORMAT_PATCH;
1821
- options->full_index = options->binary = 1;
1827
+ options->binary = 1;
1828
}
1829
else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) {
1830
options->text = 1;