aboutsummaryrefslogtreecommitdiff
path: root/t/t8020-last-modified.sh
diff options
context:
space:
mode:
authorToon Claes <toon@iotcl.com>2026-01-20 22:47:11 +0100
committerJunio C Hamano <gitster@pobox.com>2026-01-20 14:13:04 -0800
commit9dcc09bed13aba0dc93d253f18ee2c7da5970c0c (patch)
tree55052106e323114eca79e2501a5de8f039a4870b /t/t8020-last-modified.sh
parent9bfaf78cb28b26ab0538e2edd2229547d6be962f (diff)
downloadgit-9dcc09bed13aba0dc93d253f18ee2c7da5970c0c.tar.xz
last-modified: change default max-depth to 0
By default git-last-modified(1) doesn't recurse into subtrees. So when the pathspec contained a path in a subtree, the command would only print the commit information about the parent tree of the path, like: $ git last-modified -- path/file aaa0aab1bbb2bcc3ccc4ddd5dde6eee7eff8fff9 path Change the default behavior to give commit information about the exact path instead: $ git last-modified -- path/file aaa0aab1bbb2bcc3ccc4ddd5dde6eee7eff8fff9 path/file To achieve this, the default max-depth is changed to 0 and recursive is always enabled. The handling of option '-r' is modified to disable a max-depth, resulting in the behavior of this option to remain unchanged. No existing tests were modified, because there didn't exist any tests covering the example above. But more tests are added to cover this now. Signed-off-by: Toon Claes <toon@iotcl.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t8020-last-modified.sh')
-rwxr-xr-xt/t8020-last-modified.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh
index a4c1114ee2..43f38937ba 100755
--- a/t/t8020-last-modified.sh
+++ b/t/t8020-last-modified.sh
@@ -85,6 +85,41 @@ test_expect_success 'last-modified subdir recursive' '
EOF
'
+test_expect_success 'last-modified subdir non-recursive' '
+ check_last_modified a <<-\EOF
+ 3 a
+ EOF
+'
+
+test_expect_success 'last-modified path in subdir non-recursive' '
+ check_last_modified a/file <<-\EOF
+ 2 a/file
+ EOF
+'
+
+test_expect_success 'last-modified subdir with wildcard non-recursive' '
+ check_last_modified a/* <<-\EOF
+ 3 a/b
+ 2 a/file
+ EOF
+'
+
+test_expect_success 'last-modified with negative max-depth' '
+ check_last_modified --max-depth=-1 <<-\EOF
+ 3 a/b/file
+ 2 a/file
+ 1 file
+ EOF
+'
+
+test_expect_success 'last-modified with max-depth of 1' '
+ check_last_modified --max-depth=1 <<-\EOF
+ 3 a/b
+ 2 a/file
+ 1 file
+ EOF
+'
+
test_expect_success 'last-modified from non-HEAD commit' '
check_last_modified HEAD^ <<-\EOF
2 a