git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] add option -n (--no-checkout) to git-worktree add
@ 2016-03-23 15:08 Ray Zhang
  2016-03-23 15:49 ` Eric Sunshine
                   ` (2 more replies)
  0 siblings, 3 replies; 29+ messages in thread
From: Ray Zhang @ 2016-03-23 15:08 UTC (permalink / raw)
  To: git

By adding option -n, we can make some customizations before checkout, like sparse checkout, etc.

Signed-off-by: Ray Zhang <zhanglei002@gmail.com>
---
 builtin/worktree.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 38b5609..14ca3d9 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -21,6 +21,7 @@ static const char * const worktree_usage[] = {
 struct add_opts {
 	int force;
 	int detach;
+	int no_checkout;
 	const char *new_branch;
 	int force_new_branch;
 };
@@ -284,11 +285,13 @@ static int add_worktree(const char *path, const char *refname,
 	if (ret)
 		goto done;
 
-	cp.argv = NULL;
-	argv_array_clear(&cp.args);
-	argv_array_pushl(&cp.args, "reset", "--hard", NULL);
-	cp.env = child_env.argv;
-	ret = run_command(&cp);
+	if (!opts->no_checkout) {
+		cp.argv = NULL;
+		argv_array_clear(&cp.args);
+		argv_array_pushl(&cp.args, "reset", "--hard", NULL);
+		cp.env = child_env.argv;
+		ret = run_command(&cp);
+	}
 	if (!ret) {
 		is_junk = 0;
 		free(junk_work_tree);
@@ -320,6 +323,7 @@ static int add(int ac, const char **av, const char *prefix)
 		OPT_STRING('B', NULL, &new_branch_force, N_("branch"),
 			   N_("create or reset a branch")),
 		OPT_BOOL(0, "detach", &opts.detach, N_("detach HEAD at named commit")),
+		OPT_BOOL('n', "no-checkout", &opts.no_checkout, N_("don't create a checkout")),
 		OPT_END()
 	};
 

--
https://github.com/git/git/pull/217

^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2016-03-30 17:59 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-23 15:08 [PATCH] add option -n (--no-checkout) to git-worktree add Ray Zhang
2016-03-23 15:49 ` Eric Sunshine
2016-03-23 15:51 ` Junio C Hamano
2016-03-23 17:43   ` Eric Sunshine
2016-03-24  6:07 ` [PATCH v2] worktree: add: introduce --checkout option Ray Zhang
2016-03-24  9:16   ` Duy Nguyen
2016-03-24  9:52     ` Zhang Lei
2016-03-25  1:22       ` Eric Sunshine
2016-03-25  1:29         ` Eric Sunshine
2016-03-25  1:49           ` Duy Nguyen
2016-03-25 11:31             ` Zhang Lei
2016-03-25 11:41               ` Duy Nguyen
2016-03-25 12:06                 ` Zhang Lei
2016-03-25 12:15                   ` Duy Nguyen
2016-03-25 13:02                 ` Mike Rappazzo
2016-03-25  1:18   ` Eric Sunshine
2016-03-25 11:25   ` [PATCH v3] " Ray Zhang
2016-03-27 19:49     ` Eric Sunshine
2016-03-28 10:52     ` [PATCH v4] " Ray Zhang
2016-03-28 17:40       ` Junio C Hamano
2016-03-29 10:11       ` [PATCH v5] " Ray Zhang
2016-03-29 10:54         ` John Keeping
2016-03-29 18:04           ` Eric Sunshine
2016-03-29 20:15             ` John Keeping
2016-03-29 20:28               ` Junio C Hamano
2016-03-29 19:20         ` Eric Sunshine
2016-03-30  3:11           ` Zhang Lei
2016-03-30 17:59             ` Eric Sunshine
     [not found]       ` <CAPig+cSkE-xoaXnXHZHB4xz=ehCR973PaKbZJRyiTvHWn0AyoA@mail.gmail.com>
2016-03-29 18:43         ` [PATCH v4] " Eric Sunshine

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).