]> git.ipfire.org Git - thirdparty/git.git/blobdiff - t/t4208-log-magic-pathspec.sh
Merge branch 'en/ort-perf-batch-9'
[thirdparty/git.git] / t / t4208-log-magic-pathspec.sh
index 62f335b2d9fe7268f8f6cd878067de8528b5cb75..7f0c1dcc0f0bfbfd746648f4fee1b7588a8f31b8 100755 (executable)
@@ -2,6 +2,9 @@
 
 test_description='magic pathspec tests using git-log'
 
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
 . ./test-lib.sh
 
 test_expect_success 'setup' '
@@ -25,10 +28,35 @@ test_expect_success '"git log :/a -- " should not be ambiguous' '
        git log :/a --
 '
 
+test_expect_success '"git log :/detached -- " should find a commit only in HEAD' '
+       test_when_finished "git checkout main" &&
+       git checkout --detach &&
+       test_commit --no-tag detached &&
+       test_commit --no-tag something-else &&
+       git log :/detached --
+'
+
+test_expect_success '"git log :/detached -- " should not find an orphaned commit' '
+       test_must_fail git log :/detached --
+'
+
+test_expect_success '"git log :/detached -- " should find HEAD only of own worktree' '
+       git worktree add other-tree HEAD &&
+       git -C other-tree checkout --detach &&
+       test_tick &&
+       git -C other-tree commit --allow-empty -m other-detached &&
+       git -C other-tree log :/other-detached -- &&
+       test_must_fail git log :/other-detached --
+'
+
 test_expect_success '"git log -- :/a" should not be ambiguous' '
        git log -- :/a
 '
 
+test_expect_success '"git log :/any/path/" should not segfault' '
+       test_must_fail git log :/any/path/
+'
+
 # This differs from the ":/a" check above in that :/in looks like a pathspec,
 # but doesn't match an actual file.
 test_expect_success '"git log :/in" should not be ambiguous' '
@@ -89,7 +117,7 @@ test_expect_success 'command line pathspec parsing for "git log"' '
        git checkout HEAD^ &&
        echo 2 >a &&
        git commit -a -m "update a to 2" &&
-       test_must_fail git merge master &&
+       test_must_fail git merge main &&
        git add a &&
        git log --merge -- a
 '