Skip to content

Commit

Permalink
diff --binary generates full index on binary files.
Browse files Browse the repository at this point in the history
... without --full-index.

Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Junio C Hamano committed Sep 7, 2006
1 parent 2b6eef9 commit 82793c5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,6 +1588,12 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
if (hashcmp(one->sha1, two->sha1)) {
int abbrev = o->full_index ? 40 : DEFAULT_ABBREV;

if (o->binary) {
mmfile_t mf;
if ((!fill_mmfile(&mf, one) && mmfile_is_binary(&mf)) ||
(!fill_mmfile(&mf, two) && mmfile_is_binary(&mf)))
abbrev = 40;
}
len += snprintf(msg + len, sizeof(msg) - len,
"index %.*s..%.*s",
abbrev, sha1_to_hex(one->sha1),
Expand Down Expand Up @@ -1818,7 +1824,7 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
options->full_index = 1;
else if (!strcmp(arg, "--binary")) {
options->output_format |= DIFF_FORMAT_PATCH;
options->full_index = options->binary = 1;
options->binary = 1;
}
else if (!strcmp(arg, "-a") || !strcmp(arg, "--text")) {
options->text = 1;
Expand Down

0 comments on commit 82793c5

Please sign in to comment.