aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-13 13:39:25 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-13 13:39:25 -0800
commit70cc3bca87abdfbc941e98d1c0d3199f758f0990 (patch)
tree059e3fd5c87ea206059faed65a490c21d33aa469 /t
parentf036245819e5981910ee39f72be6122c0ffbea2f (diff)
parent525ef52301be231c73393da5af4a4071f060eb20 (diff)
downloadgit-70cc3bca87abdfbc941e98d1c0d3199f758f0990.tar.xz
Merge branch 'tc/last-modified-not-a-tree'
Giving "git last-modified" a tree (not a commit-ish) died an uncontrolled death, which has been corrected. * tc/last-modified-not-a-tree: last-modified: verify revision argument is a commit-ish last-modified: remove double error message last-modified: fix memory leak when more than one commit is given last-modified: rewrite error message when more than one commit given
Diffstat (limited to 't')
-rwxr-xr-xt/t8020-last-modified.sh26
1 files changed, 20 insertions, 6 deletions
diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh
index 3944d2e153..9dba4b9d90 100755
--- a/t/t8020-last-modified.sh
+++ b/t/t8020-last-modified.sh
@@ -8,14 +8,11 @@ test_expect_success 'setup' '
test_commit 1 file &&
mkdir a &&
test_commit 2 a/file &&
+ git tag -mA t2 2 &&
mkdir a/b &&
test_commit 3 a/b/file
'
-test_expect_success 'cannot run last-modified on two trees' '
- test_must_fail git last-modified HEAD HEAD~1
-'
-
check_last_modified() {
local indir= &&
while test $# != 0
@@ -34,7 +31,7 @@ check_last_modified() {
cat >expect &&
git ${indir:+-C "$indir"} last-modified "$@" >tmp.1 &&
- git name-rev --annotate-stdin --name-only --tags \
+ git name-rev --annotate-stdin --name-only --tags --exclude=t2 \
<tmp.1 >tmp.2 &&
tr '\t' ' ' <tmp.2 >actual &&
test_cmp expect actual
@@ -55,6 +52,13 @@ test_expect_success 'last-modified recursive' '
EOF
'
+test_expect_success 'last-modified on annotated tag' '
+ check_last_modified t2 <<-\EOF
+ 2 a
+ 1 file
+ EOF
+'
+
test_expect_success 'last-modified recursive with show-trees' '
check_last_modified -r -t <<-\EOF
3 a/b
@@ -265,9 +269,19 @@ test_expect_success 'last-modified merge undoes changes' '
EOF
'
+test_expect_success 'cannot run last-modified on two commits' '
+ test_must_fail git last-modified HEAD HEAD~1 2>err &&
+ test_grep "last-modified can only operate on one commit at a time" err
+'
+
test_expect_success 'last-modified complains about unknown arguments' '
test_must_fail git last-modified --foo 2>err &&
- grep "unknown last-modified argument: --foo" err
+ test_grep "unknown last-modified argument: --foo" err
+'
+
+test_expect_success 'last-modified expects commit-ish' '
+ test_must_fail git last-modified HEAD^{tree} 2>err &&
+ test_grep "revision argument ${SQ}HEAD^{tree}${SQ} is a tree, not a commit-ish" err
'
test_done