From cc9f8f66c8e675bf5955a6de7ce824955d5c8886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 6 Aug 2021 13:23:21 +0200 Subject: [PATCH] Add a case test for get_git_dir() and get_git_common_dir() --- tests/git_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/git_test.py b/tests/git_test.py index 51d5f8c4..0dfadfa9 100644 --- a/tests/git_test.py +++ b/tests/git_test.py @@ -38,6 +38,22 @@ def test_get_root_bare_worktree(tmpdir): assert git.get_root() == os.path.abspath('.') +def test_get_git_dir(tmpdir): + """Regression test for #1972""" + src = tmpdir.join('src').ensure_dir() + cmd_output('git', 'init', str(src)) + git_commit(cwd=str(src)) + + worktree = tmpdir.join('worktree').ensure_dir() + cmd_output('git', 'worktree', 'add', '../worktree', cwd=src) + + with worktree.as_cwd(): + assert git.get_git_dir() == src.ensure_dir( + '.git/worktrees/worktree', + ) + assert git.get_git_common_dir() == src.ensure_dir('.git') + + def test_get_root_worktree_in_git(tmpdir): src = tmpdir.join('src').ensure_dir() cmd_output('git', 'init', str(src))