summaryrefslogtreecommitdiff
path: root/builtin/blame.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-01-06 04:18:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-08 03:34:54 (GMT)
commited58d8088b570e7629bfc94b87e433f05229ef3c (patch)
treeeb096878c25f190d13ce80c35f3e03d74c727c12 /builtin/blame.c
parent91229834c293302c4456e732ddef7ace0df6e471 (diff)
downloadgit-ed58d8088b570e7629bfc94b87e433f05229ef3c.zip
git-ed58d8088b570e7629bfc94b87e433f05229ef3c.tar.gz
git-ed58d8088b570e7629bfc94b87e433f05229ef3c.tar.bz2
blame: handle --no-abbrev
You can already ask blame for full sha1s with "-l" or with "--abbrev=40". But for consistency with other parts of Git, we should support "--no-abbrev". Worse, blame already accepts --no-abbrev, but it's totally broken. When we see --no-abbrev, the abbrev variable is set to 0, which is then used as a printf precision. For regular sha1s, that means we print nothing at all (which is very wrong). For boundary commits we decrement it to "-1", which printf interprets as "no limit" (which is almost correct, except it misses the 39-length magic explained in the previous commit). Let's detect --no-abbrev and behave as if --abbrev=40 was given. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/blame.c')
-rw-r--r--builtin/blame.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index cbb7dc2..1fccbe6 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -2609,6 +2609,8 @@ parse_done:
if (0 < abbrev && abbrev < GIT_SHA1_HEXSZ)
/* one more abbrev length is needed for the boundary commit */
abbrev++;
+ else if (!abbrev)
+ abbrev = GIT_SHA1_HEXSZ;
if (revs_file && read_ancestry(revs_file))
die_errno("reading graft file '%s' failed", revs_file);