]> git.ipfire.org Git - thirdparty/git.git/commitdiff
last-modified: rewrite error message when more than one commit given
authorToon Claes <toon@iotcl.com>
Fri, 30 Jan 2026 14:26:35 +0000 (15:26 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 30 Jan 2026 16:57:00 +0000 (08:57 -0800)
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>
builtin/last-modified.c
t/t8020-last-modified.sh

index c80f0535f6a5033af6c7cd27dfc4dd5af2b5c1ab..1219f6802e62a96681ccae063bc4c2e4620b430c 100644 (file)
@@ -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);
index 50f4312f715f41ffeb091d6d7f9da7ec8b63e65c..d1aad1231938f6832378fdda9068c54063bb897e 100755 (executable)
@@ -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