1
0
mirror of https://github.com/git/git.git synced 2024-10-22 15:58:13 +02:00
git/builtin
Jeff King 91229834c2 blame: fix alignment with --abbrev=40
The blame command internally adds 1 to any requested sha1
abbreviation length, and then subtracts it when outputting a
boundary commit. This lets regular and boundary sha1s line
up visually, but it misses one corner case.

When the requested length is 40, we bump the value to 41.
But since we only have 40 characters, that's all we can show
(fortunately the truncation is done by a printf precision
field, so it never tries to read past the end of the
buffer).  So a normal sha1 shows 40 hex characters, and a
boundary sha1 shows "^" plus 40 hex characters. The result
is misaligned.

The "-l" option to show long sha1s gets around this by
skipping the "abbrev" variable entirely and just always
using GIT_SHA1_HEXSZ.  This avoids the "+1" issue, but it
does mean that boundary commits only have 39 characters
printed.  This is somewhat odd, but it does look good
visually: the results are aligned and left-justified. The
alternative would be to allocate an extra column that would
contain either an extra space or the "^" boundary marker.

As this is by definition the human-readable view, it's
probably not that big a deal either way (and of course
--porcelain, etc, correctly produce correct 40-hex sha1s).
But for consistency, this patch teaches --abbrev=40 to
produce the same output as "-l" (always left-aligned, with
40-hex for normal sha1s, and "^" plus 39-hex for
boundaries).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-01-07 19:34:54 -08:00
..
add.c add: modify already added files when --chmod is given 2016-09-15 12:13:54 -07:00
am.c Merge branch 'jc/am-read-author-file' into maint 2016-11-29 13:27:53 -08:00
annotate.c
apply.c
archive.c
bisect--helper.c
blame.c blame: fix alignment with --abbrev=40 2017-01-07 19:34:54 -08:00
branch.c Merge branch 'jk/create-branch-remove-unused-param' into maint 2016-11-29 13:28:02 -08:00
bundle.c
cat-file.c cat-file: put spaces around pipes in usage string 2016-09-08 12:16:38 -07:00
check-attr.c
check-ignore.c
check-mailmap.c
check-ref-format.c
checkout-index.c
checkout.c Merge branch 'jk/create-branch-remove-unused-param' into maint 2016-11-29 13:28:02 -08:00
clean.c
clone.c Merge branch 'jk/clone-copy-alternates-fix' into maint 2016-10-28 09:01:14 -07:00
column.c
commit-tree.c
commit.c Merge branch 'rs/commit-pptr-simplify' into maint 2016-11-29 13:27:59 -08:00
config.c
count-objects.c
credential.c
describe.c
diff-files.c
diff-index.c
diff-tree.c
diff.c
fast-export.c
fetch-pack.c
fetch.c Merge branch 'jk/fetch-quick-tag-following' into maint 2016-10-28 09:01:17 -07:00
fmt-merge-msg.c use strbuf_addstr() for adding constant strings to a strbuf, part 2 2016-09-15 12:23:38 -07:00
for-each-ref.c
fsck.c
gc.c Merge branch 'jk/reduce-gc-aggressive-depth' into maint 2016-09-29 16:49:42 -07:00
get-tar-commit-id.c
grep.c
hash-object.c
help.c Merge branch 'js/no-html-bypass-on-windows' into maint 2016-09-08 21:35:55 -07:00
index-pack.c
init-db.c
interpret-trailers.c
log.c format-patch: show base info before email signature 2016-09-15 10:07:10 -07:00
ls-files.c
ls-remote.c
ls-tree.c
mailinfo.c
mailsplit.c
merge-base.c merge-base: handle --fork-point without reflog 2016-10-12 14:30:16 -07:00
merge-file.c
merge-index.c
merge-ours.c
merge-recursive.c
merge-tree.c
merge.c use strbuf_addstr() for adding constant strings to a strbuf, part 2 2016-09-15 12:23:38 -07:00
mktag.c
mktree.c
mv.c Merge branch 'rs/copy-array' into maint 2016-10-11 14:18:32 -07:00
name-rev.c
notes.c
pack-objects.c Merge branch 'jk/pack-tag-of-tag' into maint 2016-10-03 13:22:13 -07:00
pack-redundant.c
pack-refs.c
patch-id.c
prune-packed.c
prune.c
pull.c
push.c
read-tree.c
receive-pack.c Merge branch 'jk/tighten-alloc' into maint 2016-09-08 21:36:00 -07:00
reflog.c
remote-ext.c
remote-fd.c
remote.c
repack.c
replace.c
rerere.c
reset.c Merge branch 'js/reset-usage' into maint 2016-10-28 09:01:22 -07:00
rev-list.c
rev-parse.c
revert.c
rm.c
send-pack.c
shortlog.c
show-branch.c
show-ref.c
stripspace.c
submodule--helper.c use strbuf_addstr() instead of strbuf_addf() with "%s", part 2 2016-09-27 14:02:40 -07:00
symbolic-ref.c symbolic-ref -d: do not allow removal of HEAD 2016-09-02 09:01:38 -07:00
tag.c
unpack-file.c
unpack-objects.c
update-index.c Merge branch 'tg/add-chmod+x-fix' into maint 2016-09-29 16:49:47 -07:00
update-ref.c
update-server-info.c
upload-archive.c
var.c
verify-commit.c
verify-pack.c
verify-tag.c
worktree.c worktree: honor configuration variables 2016-09-27 10:51:33 -07:00
write-tree.c