diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2020-08-31 08:57:59 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-08-31 20:47:45 +0200 |
commit | 42264bc841d416aab5a980cb4eeedf687f1190a5 (patch) | |
tree | 637581d0c237af428efb6b6bb110e7dc663e6d70 /t/t0001-init.sh | |
parent | worktree: teach "repair" to fix outgoing links to worktrees (diff) | |
download | git-42264bc841d416aab5a980cb4eeedf687f1190a5.tar.xz git-42264bc841d416aab5a980cb4eeedf687f1190a5.zip |
init: teach --separate-git-dir to repair linked worktrees
A linked worktree's .git file is a "gitfile" pointing at the
.git/worktrees/<id> directory within the repository. When `git init
--separate-git-dir=<path>` is used on an existing repository to relocate
the repository's .git/ directory to a different location, it neglects to
update the .git files of linked worktrees, thus breaking the worktrees
by making it impossible for them to locate the repository. Fix this by
teaching --separate-git-dir to repair the .git file of each linked
worktree to point at the new repository location.
Reported-by: Henré Botha <henrebotha@gmail.com>
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to '')
-rwxr-xr-x | t/t0001-init.sh | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 50222a10c5..e489eb4ddb 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh @@ -405,6 +405,17 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' ' test_path_is_dir realgitdir/refs ' +test_expect_success 're-init to move gitdir with linked worktrees' ' + test_when_finished "rm -rf mainwt linkwt seprepo" && + git init mainwt && + test_commit -C mainwt gumby && + git -C mainwt worktree add --detach ../linkwt && + git -C mainwt init --separate-git-dir ../seprepo && + git -C mainwt rev-parse --git-common-dir >expect && + git -C linkwt rev-parse --git-common-dir >actual && + test_cmp expect actual +' + test_expect_success MINGW '.git hidden' ' rm -rf newdir && ( |