diff --git a/datalad_core/repo/tests/test_worktree.py b/datalad_core/repo/tests/test_worktree.py index 9d31714..c832603 100644 --- a/datalad_core/repo/tests/test_worktree.py +++ b/datalad_core/repo/tests/test_worktree.py @@ -1,7 +1,7 @@ import pytest from datalad_core.config import ConfigItem -from datalad_core.runners import call_git +from datalad_core.runners import call_git_success from ..worktree import Worktree @@ -51,7 +51,7 @@ def test_secondary_worktree(tmp_path, gitrepo): test_key2 = 'other.brand.new.key' branch = 'dummy' wt_path = tmp_path / branch - call_git( + call_git_success( [ '-C', str(gitrepo), @@ -159,3 +159,35 @@ def test_worktree_init_at(tmp_path): # we got a new instance for the repo assert sep_wt.repo is not sep_repo_old assert sep_wt.repo.path == sep_repo_path_new + + +def test_secondary_worktree_w_annex(tmp_path, annexrepo): + wt1 = Worktree(annexrepo) + test_content = 'mycontent' + test_file_name = 'myfile.dat' + test_file = wt1.path / test_file_name + test_file.write_text(test_content) + call_git_success(['-C', str(wt1.path), 'annex', 'add', str(test_file)]) + call_git_success(['-C', str(wt1.path), 'commit', '-m', 'annexed file']) + + branch = 'dummy' + wt2_path = tmp_path / branch + call_git_success( + [ + '-C', + str(annexrepo), + 'worktree', + 'add', + str(wt2_path), + ] + ) + wt2 = Worktree(wt2_path) + assert wt2.annex is not None + # verifies implicitly that git-annex-info work in both worktrees + assert wt1.annex.uuid == wt2.annex.uuid + + for wt in (wt1, wt2): + # annex-getting the content is needed for robustness, not all + # platforms have immediately usable symlinks to the annex + call_git_success(['-C', wt.annex.path, 'annex', 'get', test_file_name]) + assert (wt.path / test_file_name).read_text() == test_content