summaryrefslogtreecommitdiff
path: root/range-diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-02-27 10:08:56 -0800
committerJunio C Hamano <gitster@pobox.com>2023-02-27 10:08:56 -0800
commit63f74cfbcc608fc2b379680ba4f9181792996081 (patch)
tree5eb94bd2fc8bbe26bbbbd05f477b1951909b6d01 /range-diff.c
parent93c12724f1eb4f6a165623ed468d7c0241c58730 (diff)
parent2b15969f61425afb2f1e67aa48ea73d2f10d8eb9 (diff)
downloadgit-63f74cfbcc608fc2b379680ba4f9181792996081.tar.xz
Merge branch 'tl/range-diff-custom-abbrev'
"git range-diff" learned --abbrev=<num> option. * tl/range-diff-custom-abbrev: range-diff: let '--abbrev' option takes effect
Diffstat (limited to 'range-diff.c')
-rw-r--r--range-diff.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/range-diff.c b/range-diff.c
index 8255ab4349..086365dffb 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -383,11 +383,14 @@ static void output_pair_header(struct diff_options *diffopt,
const char *color_new = diff_get_color_opt(diffopt, DIFF_FILE_NEW);
const char *color_commit = diff_get_color_opt(diffopt, DIFF_COMMIT);
const char *color;
+ char abbrev = diffopt->abbrev;
+
+ if (abbrev < 0)
+ abbrev = DEFAULT_ABBREV;
if (!dashes->len)
strbuf_addchars(dashes, '-',
- strlen(find_unique_abbrev(oid,
- DEFAULT_ABBREV)));
+ strlen(find_unique_abbrev(oid, abbrev)));
if (!b_util) {
color = color_old;
@@ -409,7 +412,7 @@ static void output_pair_header(struct diff_options *diffopt,
strbuf_addf(buf, "%*s: %s ", patch_no_width, "-", dashes->buf);
else
strbuf_addf(buf, "%*d: %s ", patch_no_width, a_util->i + 1,
- find_unique_abbrev(&a_util->oid, DEFAULT_ABBREV));
+ find_unique_abbrev(&a_util->oid, abbrev));
if (status == '!')
strbuf_addf(buf, "%s%s", color_reset, color);
@@ -421,7 +424,7 @@ static void output_pair_header(struct diff_options *diffopt,
strbuf_addf(buf, " %*s: %s", patch_no_width, "-", dashes->buf);
else
strbuf_addf(buf, " %*d: %s", patch_no_width, b_util->i + 1,
- find_unique_abbrev(&b_util->oid, DEFAULT_ABBREV));
+ find_unique_abbrev(&b_util->oid, abbrev));
commit = lookup_commit_reference(the_repository, oid);
if (commit) {