summaryrefslogtreecommitdiff
path: root/t/t7004-tag.sh
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2012-02-06 10:13:27 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-02-08 20:44:39 -0800
commit31fd8d72f2eb82c2b6d8d450ee4e13a3925291c3 (patch)
tree4cee9e7f699ac08f014a4659bd5ae690fdfb3d92 /t/t7004-tag.sh
parenttag: die when listing missing or corrupt objects (diff)
downloadtgif-31fd8d72f2eb82c2b6d8d450ee4e13a3925291c3.tar.xz
tag: do not show non-tag contents with "-n"
"git tag -n" did not check the type of the object it is reading the top n lines from. At least, avoid showing the beginning of trees and blobs when dealing with lightweight tags that point at them. As the payload of a tag and a commit look similar in that they both start with a header block, which is skipped for the purpose of "-n" output, followed by human readable text, allow the message of commit objects to be shown just like the contents of tag objects. This avoids regression for people who have been using "tag -n" to show the log messages of commits that are pointed at by lightweight tags. Test script is from Jeff King. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7004-tag.sh')
-rwxr-xr-xt/t7004-tag.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/t/t7004-tag.sh b/t/t7004-tag.sh
index 097ce2bc83..7687e62cc5 100755
--- a/t/t7004-tag.sh
+++ b/t/t7004-tag.sh
@@ -585,6 +585,19 @@ test_expect_success \
test_cmp expect actual
'
+test_expect_success 'annotations for blobs are empty' '
+ blob=$(git hash-object -w --stdin <<-\EOF
+ Blob paragraph 1.
+
+ Blob paragraph 2.
+ EOF
+ ) &&
+ git tag tag-blob $blob &&
+ echo "tag-blob " >expect &&
+ git tag -n1 -l tag-blob >actual &&
+ test_cmp expect actual
+'
+
# subsequent tests require gpg; check if it is available
gpg --version >/dev/null 2>/dev/null
if [ $? -eq 127 ]; then