aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@iotcl.com>2026-01-30 15:26:35 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-30 08:57:00 -0800
commit85329e31dd4c864a5a200d0a0ded886599adc2c5 (patch)
tree73a25a65b3f07a3bc8cdf0ab2afccf6dbdff030c
parent66ce5f8e8872f0183bb137911c52b07f1f242d13 (diff)
downloadgit-85329e31dd4c864a5a200d0a0ded886599adc2c5.tar.xz
last-modified: rewrite error message when more than one commit given
When more than one commit is passed to the git-last-modified(1) command, this error message was printed: error: last-modified can only operate on one tree at a time Calling these a "tree" is technically not correct. git-last-modified(1) expects revisions that peel to a commit. Rephrase the error message to: error: last-modified can only operate on one commit at a time While at it, modify the test to ensure the correct error message is printed. Signed-off-by: Toon Claes <toon@iotcl.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/last-modified.c2
-rwxr-xr-xt/t8020-last-modified.sh11
2 files changed, 7 insertions, 6 deletions
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index c80f0535f6..1219f6802e 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -146,7 +146,7 @@ static int populate_paths_from_revs(struct last_modified *lm)
continue;
if (num_interesting++)
- return error(_("last-modified can only operate on one tree at a time"));
+ return error(_("last-modified can only operate on one commit at a time"));
diff_tree_oid(lm->rev.repo->hash_algo->empty_tree,
&obj->item->oid, "", &diffopt);
diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh
index 50f4312f71..d1aad12319 100755
--- a/t/t8020-last-modified.sh
+++ b/t/t8020-last-modified.sh
@@ -12,10 +12,6 @@ test_expect_success 'setup' '
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
@@ -230,9 +226,14 @@ 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_done