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

Re: [PATCH v3] worktree: add: introduce --checkout option

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 27, 2016, 19:49 UTC
Message-ID
<20160327194948.GA9295@flurp.local>
In-Reply-To
<01020153ad85c135-8ca8cff0-9e6f-48ea-89f3-4036814feeca-000000@eu-west-1.amazonses.com>
On Fri, Mar 25, 2016 at 11:25:37AM +0000, Ray Zhang wrote:
Show 9 quoted lines
> By adding this option which defaults to true, we can use the
> corresponding --no-checkout to make some customizations before
> the checkout, like sparse checkout, etc.
> 
> Signed-off-by: Ray Zhang <zhanglei002@gmail.com>
> ---
> 1. reword on `--no-checkout` in Documentation/git-worktree.txt
> 2. update the test for `--no-checkout`
> 3. add a test for `--checkout`
Thanks, this version of the patch looks good and is:
    Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>

with or without the minor suggestions below. (If you do re-roll, feel free to add my Reviewed-by: if you include these suggestions but not if you make other major changes.)

Show 5 quoted lines
> ---
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> @@ -87,6 +87,12 @@ OPTIONS
> +--[no-]checkout::
> +	By default, `add` checks out HEAD, however, `--no-checkout` can

I realize that this description is just a verbatim copy of what I suggested during review[1], but in retrospect, I think s/HEAD/`<branch>`/ would be clearer and more consistent:

    By default, `add` checks out `<branch>`, however, ...
[1]: http://article.gmane.org/gmane.comp.version-control.git/289840
Show 8 quoted lines
> +	be used to suppress checkout in order to make customizations,
> +	such as configuring sparse-checkout. See "Sparse checkout"
> +	in linkgit:git-read-tree[1].
> diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
> @@ -213,4 +213,18 @@ test_expect_success 'local clone from linked checkout' '
> +test_expect_success '"add" worktree with --no-checkout' '
> +	git worktree add --no-checkout -b swamp swamp &&
> +	ls swamp >actual && test_line_count = 0 actual &&
Style: One statement per line, so this should be split over two
lines.
> +	(
> +		cd swamp && git reset --hard &&
> +		test_cmp ../init.t init.t
> +	)
No need for the subshell. This can be written more simply as:
    git -C swamp reset --hard &&
    test_cmp init.t swamp/init.t
Show 5 quoted lines
> +'
> +
> +test_expect_success '"add" worktree with --checkout' '
> +	git worktree add --checkout -b swmap2 swamp2 &&
> +	( cd swamp2 && test_cmp ../init.t init.t )
Likewise, you can drop the subshell:
    test_cmp init.t swamp2/init.t
> +'
> +
>  test_done

For convenience, the above suggestions would look like this (applied atop your patch). Feel free to fold them in if you re-roll.

--- 8< ---
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index c2796bb..c622345 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -88,7 +88,7 @@ OPTIONS
 	in linkgit:git-checkout[1].
 
 --[no-]checkout::
-	By default, `add` checks out HEAD, however, `--no-checkout` can
+	By default, `add` checks out `<branch>`, however, `--no-checkout` can
 	be used to suppress checkout in order to make customizations,
 	such as configuring sparse-checkout. See "Sparse checkout"
 	in linkgit:git-read-tree[1].
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 1ff96af..472b811 100755
--- a/t/t2025-worktree-add.sh
+++ b/t/t2025-worktree-add.sh
@@ -215,16 +215,15 @@ test_expect_success 'local clone from linked checkout' '
 
 test_expect_success '"add" worktree with --no-checkout' '
 	git worktree add --no-checkout -b swamp swamp &&
-	ls swamp >actual && test_line_count = 0 actual &&
-	(
-		cd swamp && git reset --hard &&
-		test_cmp ../init.t init.t
-	)
+	ls swamp >actual &&
+	test_line_count = 0 actual &&
+	git -C swamp reset --hard &&
+	test_cmp init.t swamp/init.t
 '
 
 test_expect_success '"add" worktree with --checkout' '
 	git worktree add --checkout -b swmap2 swamp2 &&
-	( cd swamp2 && test_cmp ../init.t init.t )
+	test_cmp init.t swamp2/init.t
 '
 
 test_done
--- 8< ---
Previous: Ray ZhangNext: Ray Zhang
Message 18 of 29 in “add option -n (--no-checkout) to git-worktree add”
  1. add option -n (--no-checkout) to git-worktree addRay Zhang, Mar 23, 2016
  2. Eric SunshineMar 23, 2016
  3. Junio C HamanoMar 23, 2016
  4. Eric SunshineMar 23, 2016
  5. worktree: add: introduce --checkout optionRay Zhang, Mar 24, 2016
  6. Duy NguyenMar 24, 2016
  7. Zhang LeiMar 24, 2016
  8. Eric SunshineMar 25, 2016
  9. Eric SunshineMar 25, 2016
  10. Duy NguyenMar 25, 2016
  11. Zhang LeiMar 25, 2016
  12. Duy NguyenMar 25, 2016
  13. Zhang LeiMar 25, 2016
  14. Duy NguyenMar 25, 2016
  15. Mike RappazzoMar 25, 2016
  16. Eric SunshineMar 25, 2016
  17. worktree: add: introduce --checkout optionRay Zhang, Mar 25, 2016
  18. Eric SunshineMar 27, 2016
  19. worktree: add: introduce --checkout optionRay Zhang, Mar 28, 2016
  20. Junio C HamanoMar 28, 2016
  21. worktree: add: introduce --checkout optionRay Zhang, Mar 29, 2016
  22. John KeepingMar 29, 2016
  23. Eric SunshineMar 29, 2016
  24. John KeepingMar 29, 2016
  25. Junio C HamanoMar 29, 2016
  26. Eric SunshineMar 29, 2016
  27. Zhang LeiMar 30, 2016
  28. Eric SunshineMar 30, 2016
  29. Eric SunshineMar 29, 2016

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.