diff options
author | Junio C Hamano <gitster@pobox.com> | 2015-07-13 23:02:18 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-07-13 23:02:19 +0200 |
commit | 799767cc98b2f8e6f82d0de4bef9b5e8fcc16e97 (patch) | |
tree | 6b4292f1c30feec0958156c66c1a724dc067be9e /t | |
parent | Merge branch 'nd/multiple-work-trees' (diff) | |
parent | Revert "checkout: retire --ignore-other-worktrees in favor of --force" (diff) | |
download | git-799767cc98b2f8e6f82d0de4bef9b5e8fcc16e97.tar.xz git-799767cc98b2f8e6f82d0de4bef9b5e8fcc16e97.zip |
Merge branch 'es/worktree-add'
Update to the "linked checkout" in 2.5.0-rc1.
Instead of "checkout --to" that does not do what "checkout"
normally does, move the functionality to "git worktree add".
* es/worktree-add: (24 commits)
Revert "checkout: retire --ignore-other-worktrees in favor of --force"
checkout: retire --ignore-other-worktrees in favor of --force
worktree: add: auto-vivify new branch when <branch> is omitted
worktree: add: make -b/-B default to HEAD when <branch> is omitted
worktree: extract basename computation to new function
checkout: require worktree unconditionally
checkout: retire --to option
tests: worktree: retrofit "checkout --to" tests for "worktree add"
worktree: add -b/-B options
worktree: add --detach option
worktree: add --force option
worktree: introduce "add" command
checkout: drop 'checkout_opts' dependency from prepare_linked_checkout
checkout: make --to unconditionally verbose
checkout: prepare_linked_checkout: drop now-unused 'new' argument
checkout: relocate --to's "no branch specified" check
checkout: fix bug with --to and relative HEAD
Documentation/git-worktree: add EXAMPLES section
Documentation/git-worktree: add high-level 'lock' overview
Documentation/git-worktree: split technical info from general description
...
Diffstat (limited to 't')
-rwxr-xr-x | t/t2025-worktree-add.sh (renamed from t/t2025-checkout-to.sh) | 73 | ||||
-rwxr-xr-x | t/t2026-prune-linked-checkouts.sh | 2 | ||||
-rwxr-xr-x | t/t7410-submodule-checkout-to.sh | 4 |
3 files changed, 52 insertions, 27 deletions
diff --git a/t/t2025-checkout-to.sh b/t/t2025-worktree-add.sh index a8d93366f6..ead8aa2a9d 100755 --- a/t/t2025-checkout-to.sh +++ b/t/t2025-worktree-add.sh @@ -1,6 +1,6 @@ #!/bin/sh -test_description='test git checkout --to' +test_description='test git worktree add' . ./test-lib.sh @@ -8,22 +8,18 @@ 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' ' +test_expect_success '"add" an existing worktree' ' mkdir -p existing/subtree && - test_must_fail git checkout --detach --to existing master + test_must_fail git worktree add --detach existing master ' -test_expect_success 'checkout --to an existing empty worktree' ' +test_expect_success '"add" an existing empty worktree' ' mkdir existing_empty && - git checkout --detach --to existing_empty master + git worktree add --detach existing_empty master ' -test_expect_success 'checkout --to refuses to checkout locked branch' ' - test_must_fail git checkout --to zere master && +test_expect_success '"add" refuses to checkout locked branch' ' + test_must_fail git worktree add zere master && ! test -d zere && ! test -d .git/worktrees/zere ' @@ -36,9 +32,9 @@ test_expect_success 'checking out paths not complaining about linked checkouts' ) ' -test_expect_success 'checkout --to a new worktree' ' +test_expect_success '"add" worktree' ' git rev-parse HEAD >expect && - git checkout --detach --to here master && + git worktree add --detach here master && ( cd here && test_cmp ../init.t init.t && @@ -49,27 +45,27 @@ test_expect_success 'checkout --to a new worktree' ' ) ' -test_expect_success 'checkout --to a new worktree from a subdir' ' +test_expect_success '"add" worktree from a subdir' ' ( mkdir sub && cd sub && - git checkout --detach --to here master && + git worktree add --detach here master && cd here && test_cmp ../../init.t init.t ) ' -test_expect_success 'checkout --to from a linked checkout' ' +test_expect_success '"add" from a linked checkout' ' ( cd here && - git checkout --detach --to nested-here master && + git worktree add --detach 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 && +test_expect_success '"add" worktree creating new branch' ' + git worktree add -b newmaster there master && ( cd there && test_cmp ../init.t init.t && @@ -90,7 +86,7 @@ test_expect_success 'die the same branch is already checked out' ' test_expect_success 'not die the same branch is already checked out' ' ( cd here && - git checkout --ignore-other-worktrees --to anothernewmaster newmaster + git worktree add --force anothernewmaster newmaster ) ' @@ -101,15 +97,15 @@ test_expect_success 'not die on re-checking out current branch' ' ) ' -test_expect_success 'checkout --to from a bare repo' ' +test_expect_success '"add" from a bare repo' ' ( git clone --bare . bare && cd bare && - git checkout --to ../there2 -b bare-master master + git worktree add -b bare-master ../there2 master ) ' -test_expect_success 'checkout from a bare repo without --to' ' +test_expect_success 'checkout from a bare repo without "add"' ' ( cd bare && test_must_fail git checkout master @@ -129,9 +125,38 @@ test_expect_success 'checkout with grafts' ' EOF git log --format=%s -2 >actual && test_cmp expected actual && - git checkout --detach --to grafted master && + git worktree add --detach grafted master && git --git-dir=grafted/.git log --format=%s -2 >actual && test_cmp expected actual ' +test_expect_success '"add" from relative HEAD' ' + test_commit a && + test_commit b && + test_commit c && + git rev-parse HEAD~1 >expected && + git worktree add relhead HEAD~1 && + git -C relhead rev-parse HEAD >actual && + test_cmp expected actual +' + +test_expect_success '"add -b" with <branch> omitted' ' + git worktree add -b burble flornk && + test_cmp_rev HEAD burble +' + +test_expect_success '"add" with <branch> omitted' ' + git worktree add wiffle/bat && + test_cmp_rev HEAD bat +' + +test_expect_success '"add" auto-vivify does not clobber existing branch' ' + test_commit c1 && + test_commit c2 && + git branch precious HEAD~1 && + test_must_fail git worktree add precious && + test_cmp_rev HEAD~1 precious && + test_path_is_missing precious +' + test_done diff --git a/t/t2026-prune-linked-checkouts.sh b/t/t2026-prune-linked-checkouts.sh index e872f02dac..a0f1e3bb80 100755 --- a/t/t2026-prune-linked-checkouts.sh +++ b/t/t2026-prune-linked-checkouts.sh @@ -88,7 +88,7 @@ test_expect_success 'not prune recent checkouts' ' test_expect_success 'not prune proper checkouts' ' test_when_finished rm -r .git/worktrees && - git checkout "--to=$PWD/nop" --detach master && + git worktree add --detach "$PWD/nop" master && git worktree prune && test -d .git/worktrees/nop ' diff --git a/t/t7410-submodule-checkout-to.sh b/t/t7410-submodule-checkout-to.sh index 8f30aed6cc..3f609e8909 100755 --- a/t/t7410-submodule-checkout-to.sh +++ b/t/t7410-submodule-checkout-to.sh @@ -33,7 +33,7 @@ rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1 test_expect_success 'checkout main' \ 'mkdir default_checkout && (cd clone/main && - git checkout --to "$base_path/default_checkout/main" "$rev1_hash_main")' + git worktree add "$base_path/default_checkout/main" "$rev1_hash_main")' test_expect_failure 'can see submodule diffs just after checkout' \ '(cd default_checkout/main && git diff --submodule master"^!" | grep "file1 updated")' @@ -41,7 +41,7 @@ test_expect_failure 'can see submodule diffs just after checkout' \ test_expect_success 'checkout main and initialize independed clones' \ 'mkdir fully_cloned_submodule && (cd clone/main && - git checkout --to "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") && + git worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") && (cd fully_cloned_submodule/main && git submodule update)' test_expect_success 'can see submodule diffs after independed cloning' \ |