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>

Toon Claes committed Jan 30, 2026 at 15:26 UTC 85329e31dd4c864a5a200d0a0ded886599adc2c5
2 files changed +7 -6
builtin/last-modified.c
+1 -1
@@ -146,7 +146,7 @@ static int populate_paths_from_revs(struct last_modified *lm)
146 continue;
147
148 if (num_interesting++)
149 - return error(_("last-modified can only operate on one tree at a time"));
149 + return error(_("last-modified can only operate on one commit at a time"));
150
151 diff_tree_oid(lm->rev.repo->hash_algo->empty_tree,
152 &obj->item->oid, "", &diffopt);
t/t8020-last-modified.sh
+6 -5
@@ -12,10 +12,6 @@ test_expect_success 'setup' '
12 test_commit 3 a/b/file
13 '
14
15 -test_expect_success 'cannot run last-modified on two trees' '
16 - test_must_fail git last-modified HEAD HEAD~1
17 -'
18 -
15 check_last_modified() {
16 local indir= &&
17 while test $# != 0
@@ -230,9 +226,14 @@ test_expect_success 'last-modified merge undoes changes' '
226 EOF
227 '
228
229 +test_expect_success 'cannot run last-modified on two commits' '
230 + test_must_fail git last-modified HEAD HEAD~1 2>err &&
231 + test_grep "last-modified can only operate on one commit at a time" err
232 +'
233 +
234 test_expect_success 'last-modified complains about unknown arguments' '
235 test_must_fail git last-modified --foo 2>err &&
235 - grep "unknown last-modified argument: --foo" err
236 + test_grep "unknown last-modified argument: --foo" err
237 '
238
239 test_done