pretty: implement 'reference' format
The standard format for referencing other commits within some projects
(such as git.git) is the reference format. This is described in
Documentation/SubmittingPatches as
If you want to reference a previous commit in the history of a stable
branch, use the format "abbreviated hash (subject, date)", like this:
....
Commit f86a374
(pack-bitmap.c: fix a memleak, 2015-03-30)
noticed that ...
....
Since this format is so commonly used, standardize it as a pretty
format.
The tests that are implemented essentially show that the format-string
does not change in response to various log options. This is useful
because, for future developers, it shows that we've considered the
limitations of the "canned format-string" approach and we are fine with
them.
Based-on-a-patch-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
618a855083
commit
1f0fc1db85
@ -824,4 +824,47 @@ test_expect_success '%S in git log --format works with other placeholders (part
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference' '
|
||||
git log --pretty="tformat:%h (%s, %as)" >expect &&
|
||||
git log --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference with log.date is overridden by short date' '
|
||||
git log --pretty="tformat:%h (%s, %as)" >expect &&
|
||||
test_config log.date rfc &&
|
||||
git log --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference with explicit date overrides short date' '
|
||||
git log --date=rfc --pretty="tformat:%h (%s, %ad)" >expect &&
|
||||
git log --date=rfc --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference is never unabbreviated' '
|
||||
git log --pretty="tformat:%h (%s, %as)" >expect &&
|
||||
git log --no-abbrev-commit --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference is never decorated' '
|
||||
git log --pretty="tformat:%h (%s, %as)" >expect &&
|
||||
git log --decorate=short --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference does not output reflog info' '
|
||||
git log --walk-reflogs --pretty="tformat:%h (%s, %as)" >expect &&
|
||||
git log --walk-reflogs --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'log --pretty=reference is colored appropriately' '
|
||||
git log --color=always --pretty="tformat:%C(auto)%h (%s, %as)" >expect &&
|
||||
git log --color=always --pretty=reference >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user