-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checkout: support checking out into a new working directory
"git checkout --to" sets up a new working directory with a .git file pointing to $GIT_DIR/worktrees/<id>. It then executes "git checkout" again on the new worktree with the same arguments except "--to" is taken out. The second checkout execution, which is not contaminated with any info from the current repository, will actually check out and everything that normal "git checkout" does. Helped-by: Marc Branchaud <marcnarc@xiplink.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
- Loading branch information
Nguyễn Thái Ngọc Duy
authored and
Junio C Hamano
committed
Dec 1, 2014
1 parent
91aacda
commit 529fef2
Showing
6 changed files
with
212 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/sh | ||
|
||
test_description='test git checkout --to' | ||
|
||
. ./test-lib.sh | ||
|
||
test_expect_success 'setup' ' | ||
test_commit init | ||
' | ||
|
||
test_expect_success 'checkout --to not updating paths' ' | ||
test_must_fail git checkout --to -- init.t | ||
' | ||
|
||
test_expect_success 'checkout --to an existing worktree' ' | ||
mkdir existing && | ||
test_must_fail git checkout --detach --to existing master | ||
' | ||
|
||
test_expect_success 'checkout --to a new worktree' ' | ||
git checkout --to here master && | ||
( | ||
cd here && | ||
test_cmp ../init.t init.t && | ||
git symbolic-ref HEAD >actual && | ||
echo refs/heads/master >expect && | ||
test_cmp expect actual && | ||
git fsck | ||
) | ||
' | ||
|
||
test_expect_success 'checkout --to a new worktree from a subdir' ' | ||
( | ||
mkdir sub && | ||
cd sub && | ||
git checkout --detach --to here master && | ||
cd here && | ||
test_cmp ../../init.t init.t | ||
) | ||
' | ||
|
||
test_expect_success 'checkout --to from a linked checkout' ' | ||
( | ||
cd here && | ||
git checkout --to nested-here master && | ||
cd nested-here && | ||
git fsck | ||
) | ||
' | ||
|
||
test_expect_success 'checkout --to a new worktree creating new branch' ' | ||
git checkout --to there -b newmaster master && | ||
( | ||
cd there && | ||
test_cmp ../init.t init.t && | ||
git symbolic-ref HEAD >actual && | ||
echo refs/heads/newmaster >expect && | ||
test_cmp expect actual && | ||
git fsck | ||
) | ||
' | ||
|
||
test_done |