summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-12-19 14:45:33 -0800
committerJunio C Hamano <gitster@pobox.com>2016-12-19 14:45:33 -0800
commitc89606fa9043910c5f467eb0d152df1c463710be (patch)
tree7781a35a4fb051dedbe77f642223da20d117dc7a /diff.c
parent0a45050a1456ed18a0b886f60b1b217b4db165ae (diff)
parent43d1948b7b84abc744227259dd1a3e8dfbb60358 (diff)
downloadgit-c89606fa9043910c5f467eb0d152df1c463710be.tar.gz
Merge branch 'jb/diff-no-index-no-abbrev'
"git diff --no-index" did not take "--no-abbrev" option. * jb/diff-no-index-no-abbrev: diff: handle --no-abbrev in no-index case
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index ec8728362d..84dba60c40 100644
--- a/diff.c
+++ b/diff.c
@@ -3106,7 +3106,8 @@ static const char *diff_abbrev_oid(const struct object_id *oid, int abbrev)
abbrev = FALLBACK_DEFAULT_ABBREV;
if (abbrev > GIT_SHA1_HEXSZ)
die("BUG: oid abbreviation out of range: %d", abbrev);
- hex[abbrev] = '\0';
+ if (abbrev)
+ hex[abbrev] = '\0';
return hex;
}
}
@@ -3364,6 +3365,7 @@ void diff_setup(struct diff_options *options)
options->file = stdout;
+ options->abbrev = DEFAULT_ABBREV;
options->line_termination = '\n';
options->break_opt = -1;
options->rename_limit = -1;
@@ -4024,6 +4026,8 @@ int diff_opt_parse(struct diff_options *options,
offending, optarg);
return argcount;
}
+ else if (!strcmp(arg, "--no-abbrev"))
+ options->abbrev = 0;
else if (!strcmp(arg, "--abbrev"))
options->abbrev = DEFAULT_ABBREV;
else if (skip_prefix(arg, "--abbrev=", &arg)) {