diff --git a/test/test_alt.py b/test/test_alt.py index ed66bf4..704e0aa 100644 --- a/test/test_alt.py +++ b/test/test_alt.py @@ -56,10 +56,14 @@ def test_alt_source(runner, paths, tracked, encrypt, exclude, yadm_alt): @pytest.mark.usefixtures("ds1_copy") @pytest.mark.parametrize("yadm_alt", [True, False], ids=["alt", "worktree"]) -def test_relative_link(runner, paths, yadm_alt): +@pytest.mark.parametrize("rel_worktree", [True, False], ids=["relative_work", "absolute_work"]) +def test_relative_link(runner, paths, yadm_alt, yadm_cmd, rel_worktree): """Confirm links created are relative""" yadm_dir, yadm_data = setup_standard_yadm_dir(paths) + if rel_worktree: + runner(yadm_cmd("gitconfig", "core.worktree", "../../../..")) + utils.create_alt_files( paths, "##default", tracked=True, encrypt=False, exclude=False, yadm_alt=yadm_alt, yadm_dir=yadm_dir ) diff --git a/yadm b/yadm index 9757345..48ec757 100755 --- a/yadm +++ b/yadm @@ -1785,7 +1785,12 @@ function configure_paths() { # obtain YADM_WORK from repo if it exists if [ -d "$GIT_DIR" ]; then local work + # It's possible this is a relative path, in which case it's relative to $GIT_DIR: + # https://git-scm.com/docs/git-config#Documentation/git-config.txt-coreworktree work=$(unix_path "$("$GIT_PROGRAM" config core.worktree)") + if [[ "$work" != /* ]]; then + work="$(cd "$GIT_DIR/$work" && pwd)" + fi [ -n "$work" ] && YADM_WORK="$work" fi