tag: generate useful reflog message
When tags are created with `--create-reflog` or with the option `core.logAllRefUpdates` set to 'always', a reflog is created for them. So far, the description of reflog entries for tags was empty, making the reflog hard to understand. For example:6e3a7b3
refs/tags/test@{0}: Now, a reflog message is generated when creating a tag, following the pattern "tag: tagging <short-sha1> (<description>)". If GIT_REFLOG_ACTION is set, the message becomes "$GIT_REFLOG_ACTION (<description>)" instead. If the tag references a commit object, the description is set to the subject line of the commit, followed by its commit date. For example:6e3a7b3
refs/tags/test@{0}: tag: tagging6e3a7b3398
(Git 2.12-rc0, 2017-02-03) If the tag points to a tree/blob/tag objects, the following static strings are taken as description: - "tree object" - "blob object" - "other tag object" Signed-off-by: Cornelius Weig <cornelius.weig@tngtech.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
3b9e3c2ced
commit
df8512ede8
@ -56,9 +56,25 @@ test_expect_success 'creating a tag using default HEAD should succeed' '
|
||||
'
|
||||
|
||||
test_expect_success 'creating a tag with --create-reflog should create reflog' '
|
||||
git log -1 \
|
||||
--format="format:tag: tagging %h (%s, %cd)%n" \
|
||||
--date=format:%Y-%m-%d >expected &&
|
||||
test_when_finished "git tag -d tag_with_reflog" &&
|
||||
git tag --create-reflog tag_with_reflog &&
|
||||
git reflog exists refs/tags/tag_with_reflog
|
||||
git reflog exists refs/tags/tag_with_reflog &&
|
||||
sed -e "s/^.* //" .git/logs/refs/tags/tag_with_reflog >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'annotated tag with --create-reflog has correct message' '
|
||||
git log -1 \
|
||||
--format="format:tag: tagging %h (%s, %cd)%n" \
|
||||
--date=format:%Y-%m-%d >expected &&
|
||||
test_when_finished "git tag -d tag_with_reflog" &&
|
||||
git tag -m "annotated tag" --create-reflog tag_with_reflog &&
|
||||
git reflog exists refs/tags/tag_with_reflog &&
|
||||
sed -e "s/^.* //" .git/logs/refs/tags/tag_with_reflog >actual &&
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success '--create-reflog does not create reflog on failure' '
|
||||
|
Reference in New Issue
Block a user