git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 17/23] tests: worktree: retrofit "checkout --to" tests for "worktree add"

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 4, 2015, 00:17 UTC
Message-ID
<1435969052-540-18-git-send-email-sunshine@sunshineco.com>
In-Reply-To
<1435969052-540-1-git-send-email-sunshine@sunshineco.com>

With the introduction of "git worktree add", "git checkout --to" is slated for removal. Therefore, retrofit linked worktree creation tests to use "git worktree add" instead.

(The test to check exclusivity of "checkout --to" and "checkout <paths>" is dropped altogether since it becomes meaningless with retirement of "checkout --to".)

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
 t/{t2025-checkout-to.sh => t2025-worktree-add.sh} | 48 +++++++++++------------
 t/t2026-prune-linked-checkouts.sh                 |  2 +-
 t/t7410-submodule-checkout-to.sh                  |  4 +-
 3 files changed, 25 insertions(+), 29 deletions(-)
 rename t/{t2025-checkout-to.sh => t2025-worktree-add.sh} (59%)
diff --git a/t/t2025-checkout-to.sh b/t/t2025-worktree-add.sh
similarity index 59%
rename from t/t2025-checkout-to.sh
rename to t/t2025-worktree-add.sh
index 0fd731b..192c936 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,17 +125,17 @@ 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 'checkout --to from relative HEAD' '
+test_expect_success '"add" from relative HEAD' '
 	test_commit a &&
 	test_commit b &&
 	test_commit c &&
 	git rev-parse HEAD~1 >expected &&
-	git checkout --to relhead HEAD~1 &&
+	git worktree add relhead HEAD~1 &&
 	git -C relhead rev-parse HEAD >actual &&
 	test_cmp expected actual
 '
diff --git a/t/t2026-prune-linked-checkouts.sh b/t/t2026-prune-linked-checkouts.sh
index e872f02..a0f1e3b 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 8f30aed..3f609e8 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' \
-- 
2.5.0.rc1.197.g417e668
Previous: Eric SunshineNext: Eric Sunshine
Message 28 of 38 in “replace "checkout --to" with "worktree add"”
  1. 00/23 replace "checkout --to" with "worktree add"Eric Sunshine, Jul 4, 2015
  2. 01/23 Documentation/git-checkout: fix incorrect worktree prune commandEric Sunshine, Jul 4, 2015
  3. 02/23 Documentation/git-worktree: associate options with commandsEric Sunshine, Jul 4, 2015
  4. 03/23 Documentation: move linked worktree description from checkout to worktreeEric Sunshine, Jul 4, 2015
  5. 04/23 Documentation/git-worktree: add BUGS sectionEric Sunshine, Jul 4, 2015
  6. Duy NguyenJul 4, 2015
  7. Eric SunshineJul 4, 2015
  8. 05/23 Documentation/git-worktree: split technical info from general descriptionEric Sunshine, Jul 4, 2015
  9. 06/23 Documentation/git-worktree: add high-level 'lock' overviewEric Sunshine, Jul 4, 2015
  10. 07/23 Documentation/git-worktree: add EXAMPLES sectionEric Sunshine, Jul 4, 2015
  11. Eric SunshineJul 4, 2015
  12. 08/23 checkout: fix bug with --to and relative HEADEric Sunshine, Jul 4, 2015
  13. Duy NguyenJul 4, 2015
  14. Eric SunshineJul 4, 2015
  15. 09/23 checkout: relocate --to's "no branch specified" checkEric Sunshine, Jul 4, 2015
  16. 10/23 checkout: prepare_linked_checkout: drop now-unused 'new' argumentEric Sunshine, Jul 4, 2015
  17. 11/23 checkout: make --to unconditionally verboseEric Sunshine, Jul 4, 2015
  18. 12/23 checkout: drop 'checkout_opts' dependency from prepare_linked_checkoutEric Sunshine, Jul 4, 2015
  19. 13/23 worktree: introduce "add" commandEric Sunshine, Jul 4, 2015
  20. Duy NguyenJul 4, 2015
  21. Eric SunshineJul 4, 2015
  22. Duy NguyenJul 6, 2015
  23. 14/23 worktree: add --force optionEric Sunshine, Jul 4, 2015
  24. 15/23 worktree: add --detach optionEric Sunshine, Jul 4, 2015
  25. 16/23 worktree: add -b/-B optionsEric Sunshine, Jul 4, 2015
  26. Duy NguyenJul 4, 2015
  27. Eric SunshineJul 4, 2015
  28. 17/23 tests: worktree: retrofit "checkout --to" tests for "worktree add"Eric Sunshine, Jul 4, 2015
  29. 18/23 checkout: retire --to optionEric Sunshine, Jul 4, 2015
  30. Duy NguyenJul 4, 2015
  31. Eric SunshineJul 4, 2015
  32. 19/23 checkout: require worktree unconditionallyEric Sunshine, Jul 4, 2015
  33. Eric SunshineJul 4, 2015
  34. 20/23 worktree: extract basename computation to new functionEric Sunshine, Jul 4, 2015
  35. 21/23 worktree: add: make -b/-B default to HEAD when <branch> is omittedEric Sunshine, Jul 4, 2015
  36. Junio C HamanoJul 6, 2015
  37. 22/23 worktree: add: auto-vivify new branch when <branch> is omittedEric Sunshine, Jul 4, 2015
  38. 23/23 checkout: retire --ignore-other-worktrees in favor of --forceEric Sunshine, Jul 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.