git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 00/11] Updates to worktree code and docs
@ 2022-02-20 17:54 Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
                   ` (12 more replies)
  0 siblings, 13 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

This is built on top of ds/sparse-checkout-requires-per-worktree-config and
includes some forward fixes for comments from that series.

 * Patch 1 combines two translatable messages into one. (Thanks, Jean-Noël)
 * Patches 2-4 extract methods from the already-busy add_worktree() method.
   (Thanks, Eric)
 * Patches 5-11 update git-worktree.txt to use 'worktree' over 'working
   tree'. This involves some rewrapping of the paragraphs, so the diffs are
   not obviously just a find and replace. I split the changes mostly by
   section of the file to keep the diffs from being too large.

Thanks, -Stolee

Derrick Stolee (11):
  worktree: combine two translatable messages
  worktree: extract copy_filtered_worktree_config()
  worktree: extract copy_sparse_checkout()
  worktree: extract checkout_worktree()
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'

 Documentation/git-worktree.txt | 271 ++++++++++++++++-----------------
 builtin/worktree.c             | 138 +++++++++--------
 2 files changed, 210 insertions(+), 199 deletions(-)


base-commit: 3ce113827287079dced9aaf9c5d1e1734ecaa265
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1154%2Fderrickstolee%2Fworktree-forward-fixes-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1154/derrickstolee/worktree-forward-fixes-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1154
-- 
gitgitgadget

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

* [PATCH 01/11] worktree: combine two translatable messages
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 20:22   ` Junio C Hamano
  2022-02-20 17:54 ` [PATCH 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

These two messages differ only by the config key name, which should not
be translated. Extract those keys so the messages can be translated from
the same string.

Reported-by: Jean-Noël AVILA <jn.avila@free.fr>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index c6eb636329a..7c272078dc9 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -384,11 +384,13 @@ static int add_worktree(const char *path, const char *refname,
 			    bare &&
 			    git_config_set_multivar_in_file_gently(
 					to_file, "core.bare", NULL, "true", 0))
-				error(_("failed to unset 'core.bare' in '%s'"), to_file);
+				error(_("failed to unset '%s' in '%s'"),
+				      "core.bare", to_file);
 			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
 			    git_config_set_in_file_gently(to_file,
 							  "core.worktree", NULL))
-				error(_("failed to unset 'core.worktree' in '%s'"), to_file);
+				error(_("failed to unset '%s' in '%s'"),
+				      "core.worktree", to_file);
 
 			git_configset_clear(&cs);
 		}
-- 
gitgitgadget


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

* [PATCH 02/11] worktree: extract copy_filtered_worktree_config()
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 20:26   ` Junio C Hamano
  2022-02-20 17:54 ` [PATCH 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

This logic was introduced by 5325591 (worktree: copy sparse-checkout
patterns and config on add, 2022-02-07), but some feedback came in that
the add_worktree() method was already too complex. It is better to
extract this logic into a helper method to reduce this complexity.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 81 ++++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 39 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 7c272078dc9..2771a6dc793 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -236,6 +236,46 @@ static void check_candidate_path(const char *path,
 		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
+static void copy_filtered_worktree_config(const char *worktree_git_dir)
+{
+	char *from_file = git_pathdup("config.worktree");
+	char *to_file = xstrfmt("%s/config.worktree", worktree_git_dir);
+
+	if (file_exists(from_file)) {
+		struct config_set cs = { { 0 } };
+		const char *core_worktree;
+		int bare;
+
+		if (safe_create_leading_directories(to_file) ||
+			copy_file(to_file, from_file, 0666)) {
+			error(_("failed to copy worktree config from '%s' to '%s'"),
+				from_file, to_file);
+			goto worktree_copy_cleanup;
+		}
+
+		git_configset_init(&cs);
+		git_configset_add_file(&cs, from_file);
+
+		if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
+			bare &&
+			git_config_set_multivar_in_file_gently(
+				to_file, "core.bare", NULL, "true", 0))
+			error(_("failed to unset '%s' in '%s'"),
+				"core.bare", to_file);
+		if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
+			git_config_set_in_file_gently(to_file,
+							"core.worktree", NULL))
+			error(_("failed to unset '%s' in '%s'"),
+				"core.worktree", to_file);
+
+		git_configset_clear(&cs);
+	}
+
+worktree_copy_cleanup:
+	free(from_file);
+	free(to_file);
+}
+
 static int add_worktree(const char *path, const char *refname,
 			const struct add_opts *opts)
 {
@@ -360,45 +400,8 @@ static int add_worktree(const char *path, const char *refname,
 	 * values from the current worktree into the new one, that way the
 	 * new worktree behaves the same as this one.
 	 */
-	if (repository_format_worktree_config) {
-		char *from_file = git_pathdup("config.worktree");
-		char *to_file = xstrfmt("%s/config.worktree",
-					sb_repo.buf);
-
-		if (file_exists(from_file)) {
-			struct config_set cs = { { 0 } };
-			const char *core_worktree;
-			int bare;
-
-			if (safe_create_leading_directories(to_file) ||
-			    copy_file(to_file, from_file, 0666)) {
-				error(_("failed to copy worktree config from '%s' to '%s'"),
-				      from_file, to_file);
-				goto worktree_copy_cleanup;
-			}
-
-			git_configset_init(&cs);
-			git_configset_add_file(&cs, from_file);
-
-			if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
-			    bare &&
-			    git_config_set_multivar_in_file_gently(
-					to_file, "core.bare", NULL, "true", 0))
-				error(_("failed to unset '%s' in '%s'"),
-				      "core.bare", to_file);
-			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
-			    git_config_set_in_file_gently(to_file,
-							  "core.worktree", NULL))
-				error(_("failed to unset '%s' in '%s'"),
-				      "core.worktree", to_file);
-
-			git_configset_clear(&cs);
-		}
-
-worktree_copy_cleanup:
-		free(from_file);
-		free(to_file);
-	}
+	if (repository_format_worktree_config)
+		copy_filtered_worktree_config(sb_repo.buf);
 
 	strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
 	strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
-- 
gitgitgadget


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

* [PATCH 03/11] worktree: extract copy_sparse_checkout()
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

This logic was introduced by 5325591 (worktree: copy sparse-checkout
patterns and config on add, 2022-02-07), but some feedback came in that
the add_worktree() method was already too complex. It is better to
extract this logic into a helper method to reduce this complexity.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 2771a6dc793..c806aa2b261 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -236,6 +236,22 @@ static void check_candidate_path(const char *path,
 		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
+static void copy_sparse_checkout(const char *worktree_git_dir)
+{
+	char *from_file = git_pathdup("info/sparse-checkout");
+	char *to_file = xstrfmt("%s/info/sparse-checkout", worktree_git_dir);
+
+	if (file_exists(from_file)) {
+		if (safe_create_leading_directories(to_file) ||
+			copy_file(to_file, from_file, 0666))
+			error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
+				from_file, to_file);
+	}
+
+	free(from_file);
+	free(to_file);
+}
+
 static void copy_filtered_worktree_config(const char *worktree_git_dir)
 {
 	char *from_file = git_pathdup("config.worktree");
@@ -379,21 +395,8 @@ static int add_worktree(const char *path, const char *refname,
 	 * If the current worktree has sparse-checkout enabled, then copy
 	 * the sparse-checkout patterns from the current worktree.
 	 */
-	if (core_apply_sparse_checkout) {
-		char *from_file = git_pathdup("info/sparse-checkout");
-		char *to_file = xstrfmt("%s/info/sparse-checkout",
-					sb_repo.buf);
-
-		if (file_exists(from_file)) {
-			if (safe_create_leading_directories(to_file) ||
-			    copy_file(to_file, from_file, 0666))
-				error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
-				      from_file, to_file);
-		}
-
-		free(from_file);
-		free(to_file);
-	}
+	if (core_apply_sparse_checkout)
+		copy_sparse_checkout(sb_repo.buf);
 
 	/*
 	 * If we are using worktree config, then copy all current config
-- 
gitgitgadget


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

* [PATCH 04/11] worktree: extract checkout_worktree()
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (2 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 21:59   ` Taylor Blau
  2022-02-20 17:54 ` [PATCH 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
                   ` (8 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

The ability to add the --no-checkout flag to 'git worktree' was added in
ef2a0ac9a0 (worktree: add: introduce --checkout option, 2016-03-29).
Recently, we noticed that add_worktree() is rather complicated, so
extract the logic for this checkout process to simplify the method.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index c806aa2b261..25807e63a25 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -292,6 +292,18 @@ worktree_copy_cleanup:
 	free(to_file);
 }
 
+static int checkout_worktree(const struct add_opts *opts,
+			     struct strvec *child_env)
+{
+	struct child_process cp = CHILD_PROCESS_INIT;
+	cp.git_cmd = 1;
+	strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
+	if (opts->quiet)
+		strvec_push(&cp.args, "--quiet");
+	strvec_pushv(&cp.env_array, child_env->v);
+	return run_command(&cp);
+}
+
 static int add_worktree(const char *path, const char *refname,
 			const struct add_opts *opts)
 {
@@ -425,17 +437,9 @@ static int add_worktree(const char *path, const char *refname,
 	if (ret)
 		goto done;
 
-	if (opts->checkout) {
-		struct child_process cp = CHILD_PROCESS_INIT;
-		cp.git_cmd = 1;
-		strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
-		if (opts->quiet)
-			strvec_push(&cp.args, "--quiet");
-		strvec_pushv(&cp.env_array, child_env.v);
-		ret = run_command(&cp);
-		if (ret)
-			goto done;
-	}
+	if (opts->checkout &&
+	    (ret = checkout_worktree(opts, &child_env)))
+		goto done;
 
 	is_junk = 0;
 	FREE_AND_NULL(junk_work_tree);
-- 
gitgitgadget


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

* [PATCH 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (3 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 20:42   ` Junio C Hamano
  2022-02-24 14:33   ` Philip Oakley
  2022-02-20 17:54 ` [PATCH 06/11] " Derrick Stolee via GitGitGadget
                   ` (7 subsequent siblings)
  12 siblings, 2 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the first of multiple changes to git-worktree.txt, restricted to
the DESCRIPTION section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 53 ++++++++++++++++++----------------
 1 file changed, 28 insertions(+), 25 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index b8d53c48303..d9705062e9d 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -25,45 +25,48 @@ Manage multiple working trees attached to the same repository.
 
 A git repository can support multiple working trees, allowing you to check
 out more than one branch at a time.  With `git worktree add` a new working
-tree is associated with the repository.  This new working tree is called a
-"linked working tree" as opposed to the "main working tree" prepared by
-linkgit:git-init[1] or linkgit:git-clone[1].
-A repository has one main working tree (if it's not a
-bare repository) and zero or more linked working trees. When you are done
-with a linked working tree, remove it with `git worktree remove`.
+tree is associated with the repository, along with additional metadata
+that differentiates that working tree from others in the same repository.
+The working tree, along with this metada, is called a "worktree".
+
+This new worktree is called a "linked worktree" as opposed to the "main
+worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1].
+A repository has one main worktree (if it's not a bare repository) and
+zero or more linked worktrees. When you are done with a linked worktree,
+remove it with `git worktree remove`.
 
 In its simplest form, `git worktree add <path>` automatically creates a
 new branch whose name is the final component of `<path>`, which is
 convenient if you plan to work on a new topic. For instance, `git
 worktree add ../hotfix` creates new branch `hotfix` and checks it out at
-path `../hotfix`. To instead work on an existing branch in a new working
-tree, use `git worktree add <path> <branch>`. On the other hand, if you
-just plan to make some experimental changes or do testing without
-disturbing existing development, it is often convenient to create a
-'throwaway' working tree not associated with any branch. For instance,
-`git worktree add -d <path>` creates a new working tree with a detached
-`HEAD` at the same commit as the current branch.
-
-If a working tree is deleted without using `git worktree remove`, then
+path `../hotfix`. To instead work on an existing branch in a new worktree,
+use `git worktree add <path> <branch>`. On the other hand, if you just
+plan to make some experimental changes or do testing without disturbing
+existing development, it is often convenient to create a 'throwaway'
+worktree not associated with any branch. For instance,
+`git worktree add -d <path>` creates a new worktree with a detached `HEAD`
+at the same commit as the current branch.
+
+If a worktree is deleted without using `git worktree remove`, then
 its associated administrative files, which reside in the repository
 (see "DETAILS" below), will eventually be removed automatically (see
 `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
-`git worktree prune` in the main or any linked working tree to
-clean up any stale administrative files.
+`git worktree prune` in the main or any linked worktree to clean up any
+stale administrative files.
 
-If a linked working tree is stored on a portable device or network share
-which is not always mounted, you can prevent its administrative files from
-being pruned by issuing the `git worktree lock` command, optionally
-specifying `--reason` to explain why the working tree is locked.
+If a linked worktree is stored on a portable device or network share which
+is not always mounted, you can prevent its administrative files from being
+pruned by issuing the `git worktree lock` command, optionally specifying
+`--reason` to explain why the worktree is locked.
 
 COMMANDS
 --------
 add <path> [<commit-ish>]::
 
-Create `<path>` and checkout `<commit-ish>` into it. The new working directory
-is linked to the current repository, sharing everything except working
-directory specific files such as `HEAD`, `index`, etc. As a convenience,
-`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
+Create `<path>` and checkout `<commit-ish>` into it. The new worktree
+is linked to the current repository, sharing everything except per-worktree
+files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
+be a bare "`-`", which is synonymous with `@{-1}`.
 +
 If `<commit-ish>` is a branch name (call it `<branch>`) and is not found,
 and neither `-b` nor `-B` nor `--detach` are used, but there does
-- 
gitgitgadget


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

* [PATCH 06/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (4 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 07/11] " Derrick Stolee via GitGitGadget
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the second of multiple changes to git-worktree.txt, restricted
to the COMMANDS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 85 ++++++++++++++++------------------
 1 file changed, 41 insertions(+), 44 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index d9705062e9d..e9ba58fb8bc 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -87,75 +87,72 @@ branches from there if `<branch>` is ambiguous but exists on the
 linkgit:git-config[1].
 +
 If `<commit-ish>` is omitted and neither `-b` nor `-B` nor `--detach` used,
-then, as a convenience, the new working tree is associated with a branch
-(call it `<branch>`) named after `$(basename <path>)`.  If `<branch>`
-doesn't exist, a new branch based on `HEAD` is automatically created as
-if `-b <branch>` was given.  If `<branch>` does exist, it will be
-checked out in the new working tree, if it's not checked out anywhere
-else, otherwise the command will refuse to create the working tree (unless
-`--force` is used).
+then, as a convenience, the new worktree is associated with a branch (call
+it `<branch>`) named after `$(basename <path>)`.  If `<branch>` doesn't
+exist, a new branch based on `HEAD` is automatically created as if
+`-b <branch>` was given.  If `<branch>` does exist, it will be checked out
+in the new worktree, if it's not checked out anywhere else, otherwise the
+command will refuse to create the worktree (unless `--force` is used).
 
 list::
 
-List details of each working tree.  The main working tree is listed first,
-followed by each of the linked working trees.  The output details include
-whether the working tree is bare, the revision currently checked out, the
+List details of each worktree.  The main worktree is listed first,
+followed by each of the linked worktrees.  The output details include
+whether the worktree is bare, the revision currently checked out, the
 branch currently checked out (or "detached HEAD" if none), "locked" if
-the worktree is locked, "prunable" if the worktree can be pruned by `prune`
-command.
+the worktree is locked, "prunable" if the worktree can be pruned by the
+`prune` command.
 
 lock::
 
-If a working tree is on a portable device or network share which
-is not always mounted, lock it to prevent its administrative
-files from being pruned automatically. This also prevents it from
-being moved or deleted. Optionally, specify a reason for the lock
-with `--reason`.
+If a worktree is on a portable device or network share which is not always
+mounted, lock it to prevent its administrative files from being pruned
+automatically. This also prevents it from being moved or deleted.
+Optionally, specify a reason for the lock with `--reason`.
 
 move::
 
-Move a working tree to a new location. Note that the main working tree
-or linked working trees containing submodules cannot be moved with this
-command. (The `git worktree repair` command, however, can reestablish
-the connection with linked working trees if you move the main working
-tree manually.)
+Move a worktree to a new location. Note that the main worktree or linked
+worktrees containing submodules cannot be moved with this command. (The
+`git worktree repair` command, however, can reestablish the connection
+with linked worktrees if you move the main worktree manually.)
 
 prune::
 
-Prune working tree information in `$GIT_DIR/worktrees`.
+Prune worktree information in `$GIT_DIR/worktrees`.
 
 remove::
 
-Remove a working tree. Only clean working trees (no untracked files
-and no modification in tracked files) can be removed. Unclean working
-trees or ones with submodules can be removed with `--force`. The main
-working tree cannot be removed.
+Remove a worktree. Only clean worktrees (no untracked files and no
+modification in tracked files) can be removed. Unclean worktrees or ones
+with submodules can be removed with `--force`. The main worktree cannot be
+removed.
 
 repair [<path>...]::
 
-Repair working tree administrative files, if possible, if they have
-become corrupted or outdated due to external factors.
+Repair worktree administrative files, if possible, if they have become
+corrupted or outdated due to external factors.
 +
-For instance, if the main working tree (or bare repository) is moved,
-linked working trees will be unable to locate it. Running `repair` in
-the main working tree will reestablish the connection from linked
-working trees back to the main working tree.
+For instance, if the main worktree (or bare repository) is moved, linked
+worktrees will be unable to locate it. Running `repair` in the main
+worktree will reestablish the connection from linked worktrees back to the
+main worktree.
 +
-Similarly, if a linked working tree is moved without using `git worktree
-move`, the main working tree (or bare repository) will be unable to
-locate it. Running `repair` within the recently-moved working tree will
-reestablish the connection. If multiple linked working trees are moved,
-running `repair` from any working tree with each tree's new `<path>` as
-an argument, will reestablish the connection to all the specified paths.
+Similarly, if a linked worktree is moved without using `git worktree
+move`, the main worktree (or bare repository) will be unable to locate it.
+Running `repair` within the recently-moved worktree will reestablish the
+connection. If multiple linked worktrees are moved, running `repair` from
+any worktree with each tree's new `<path>` as an argument, will
+reestablish the connection to all the specified paths.
 +
-If both the main working tree and linked working trees have been moved
-manually, then running `repair` in the main working tree and specifying the
-new `<path>` of each linked working tree will reestablish all connections
-in both directions.
+If both the main worktree and linked worktrees have been moved manually,
+then running `repair` in the main worktree and specifying the new `<path>`
+of each linked worktree will reestablish all connections in both
+directions.
 
 unlock::
 
-Unlock a working tree, allowing it to be pruned, moved or deleted.
+Unlock a worktree, allowing it to be pruned, moved or deleted.
 
 OPTIONS
 -------
-- 
gitgitgadget


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

* [PATCH 07/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (5 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 06/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 08/11] " Derrick Stolee via GitGitGadget
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the third of multiple changes to git-worktree.txt, restricted to
the OPTIONS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 42 +++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index e9ba58fb8bc..10021c85e77 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -159,25 +159,25 @@ OPTIONS
 
 -f::
 --force::
-	By default, `add` refuses to create a new working tree when
+	By default, `add` refuses to create a new worktree when
 	`<commit-ish>` is a branch name and is already checked out by
-	another working tree, or if `<path>` is already assigned to some
-	working tree but is missing (for instance, if `<path>` was deleted
+	another worktree, or if `<path>` is already assigned to some
+	worktree but is missing (for instance, if `<path>` was deleted
 	manually). This option overrides these safeguards. To add a missing but
-	locked working tree path, specify `--force` twice.
+	locked worktree path, specify `--force` twice.
 +
-`move` refuses to move a locked working tree unless `--force` is specified
-twice. If the destination is already assigned to some other working tree but is
+`move` refuses to move a locked worktree unless `--force` is specified
+twice. If the destination is already assigned to some other worktree but is
 missing (for instance, if `<new-path>` was deleted manually), then `--force`
 allows the move to proceed; use `--force` twice if the destination is locked.
 +
-`remove` refuses to remove an unclean working tree unless `--force` is used.
-To remove a locked working tree, specify `--force` twice.
+`remove` refuses to remove an unclean worktree unless `--force` is used.
+To remove a locked worktree, specify `--force` twice.
 
 -b <new-branch>::
 -B <new-branch>::
 	With `add`, create a new branch named `<new-branch>` starting at
-	`<commit-ish>`, and check out `<new-branch>` into the new working tree.
+	`<commit-ish>`, and check out `<new-branch>` into the new worktree.
 	If `<commit-ish>` is omitted, it defaults to `HEAD`.
 	By default, `-b` refuses to create a new branch if it already
 	exists. `-B` overrides this safeguard, resetting `<new-branch>` to
@@ -185,7 +185,7 @@ To remove a locked working tree, specify `--force` twice.
 
 -d::
 --detach::
-	With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD"
+	With `add`, detach `HEAD` in the new worktree. See "DETACHED HEAD"
 	in linkgit:git-checkout[1].
 
 --[no-]checkout::
@@ -211,7 +211,7 @@ This can also be set up as the default behaviour by using the
 	`--track` in linkgit:git-branch[1] for details.
 
 --lock::
-	Keep the working tree locked after creation. This is the
+	Keep the worktree locked after creation. This is the
 	equivalent of `git worktree lock` after `git worktree add`,
 	but without a race condition.
 
@@ -236,22 +236,22 @@ This can also be set up as the default behaviour by using the
 With `list`, output additional information about worktrees (see below).
 
 --expire <time>::
-	With `prune`, only expire unused working trees older than `<time>`.
+	With `prune`, only expire unused worktrees older than `<time>`.
 +
-With `list`, annotate missing working trees as prunable if they are
-older than `<time>`.
+With `list`, annotate missing worktrees as prunable if they are older than
+`<time>`.
 
 --reason <string>::
-	With `lock` or with `add --lock`, an explanation why the working tree is locked.
+	With `lock` or with `add --lock`, an explanation why the worktree
+	is locked.
 
 <worktree>::
-	Working trees can be identified by path, either relative or
-	absolute.
+	Worktrees can be identified by path, either relative or absolute.
 +
-If the last path components in the working tree's path is unique among
-working trees, it can be used to identify a working tree. For example if
-you only have two working trees, at `/abc/def/ghi` and `/abc/def/ggg`,
-then `ghi` or `def/ghi` is enough to point to the former working tree.
+If the last path components in the worktree's path is unique among
+worktrees, it can be used to identify a worktree. For example if you only
+have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
+`def/ghi` is enough to point to the former worktree.
 
 REFS
 ----
-- 
gitgitgadget


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

* [PATCH 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (6 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 07/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 22:29   ` Taylor Blau
  2022-02-20 17:54 ` [PATCH 09/11] " Derrick Stolee via GitGitGadget
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the fourth of multiple changes to git-worktree.txt, restricted
to the REFS section.

This section previously described "per working tree" refs but they are
now replaced with "per-worktree" refs, which matches the definition in
glossary-content.txt.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 10021c85e77..54a2c335fd5 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -255,24 +255,23 @@ have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
 
 REFS
 ----
-In multiple working trees, some refs may be shared between all working
-trees and some refs are local. One example is `HEAD` which is different for each
-working tree. This section is about the sharing rules and how to access
-refs of one working tree from another.
-
-In general, all pseudo refs are per working tree and all refs starting
-with `refs/` are shared. Pseudo refs are ones like `HEAD` which are
-directly under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are
-exceptions, however: refs inside `refs/bisect` and `refs/worktree` are not
-shared.
-
-Refs that are per working tree can still be accessed from another
-working tree via two special paths, `main-worktree` and `worktrees`. The
-former gives access to per-working tree refs of the main working tree,
-while the latter to all linked working trees.
+In multiple worktrees, some refs may be shared between all worktrees and
+some refs are local. One example is `HEAD` which is different for each
+worktree. This section is about the sharing rules and how to access
+refs of one worktree from another.
+
+In general, all pseudo refs are per-worktree and all refs starting with
+`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly
+under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions,
+however: refs inside `refs/bisect` and `refs/worktree` are not shared.
+
+Refs that are per-worktree can still be accessed from another worktree via
+two special paths, `main-worktree` and `worktrees`. The former gives
+access to per-worktree refs of the main worktree, while the latter to all
+linked worktrees.
 
 For example, `main-worktree/HEAD` or `main-worktree/refs/bisect/good`
-resolve to the same value as the main working tree's `HEAD` and
+resolve to the same value as the main worktree's `HEAD` and
 `refs/bisect/good` respectively. Similarly, `worktrees/foo/HEAD` or
 `worktrees/bar/refs/bisect/bad` are the same as
 `$GIT_COMMON_DIR/worktrees/foo/HEAD` and
-- 
gitgitgadget


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

* [PATCH 09/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (7 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 08/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 22:31   ` Taylor Blau
  2022-02-20 17:54 ` [PATCH 10/11] " Derrick Stolee via GitGitGadget
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the fifth of multiple changes to git-worktree.txt, restricted to
the CONFIGURATION FILE section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 54a2c335fd5..8821e56c6ec 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -283,12 +283,12 @@ which will handle refs correctly.
 
 CONFIGURATION FILE
 ------------------
-By default, the repository `config` file is shared across all working
-trees. If the config variables `core.bare` or `core.worktree` are
-present in the common config file and `extensions.worktreeConfig` is
-disabled, then they will be applied to the main working tree only.
+By default, the repository `config` file is shared across all worktrees.
+If the config variables `core.bare` or `core.worktree` are present in the
+common config file and `extensions.worktreeConfig` is disabled, then they
+will be applied to the main worktree only.
 
-In order to have configuration specific to working trees, you can turn
+In order to have configuration specific to worktrees, you can turn
 on the `worktreeConfig` extension, e.g.:
 
 ------------
@@ -302,16 +302,16 @@ versions will refuse to access repositories with this extension.
 
 Note that in this file, the exception for `core.bare` and `core.worktree`
 is gone. If they exist in `$GIT_DIR/config`, you must move
-them to the `config.worktree` of the main working tree. You may also
-take this opportunity to review and move other configuration that you
-do not want to share to all working trees:
+them to the `config.worktree` of the main worktree. You may also take this
+opportunity to review and move other configuration that you do not want to
+share to all worktrees:
 
  - `core.worktree` should never be shared.
 
  - `core.bare` should not be shared if the value is `core.bare=true`.
 
- - `core.sparseCheckout` is recommended per working tree, unless you
-   are sure you always use sparse checkout for all working trees.
+ - `core.sparseCheckout` is recommended per worktree, unless you are sure
+   you always use sparse checkout for all worktrees.
 
 See the documentation of `extensions.worktreeConfig` in
 linkgit:git-config[1] for more details.
-- 
gitgitgadget


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

* [PATCH 10/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (8 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 09/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 17:54 ` [PATCH 11/11] " Derrick Stolee via GitGitGadget
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the sixth of multiple changes to git-worktree.txt, restricted to
the DETAILS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 8821e56c6ec..923b44d3fb2 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -318,29 +318,29 @@ linkgit:git-config[1] for more details.
 
 DETAILS
 -------
-Each linked working tree has a private sub-directory in the repository's
+Each linked worktree has a private sub-directory in the repository's
 `$GIT_DIR/worktrees` directory.  The private sub-directory's name is usually
-the base name of the linked working tree's path, possibly appended with a
+the base name of the linked worktree's path, possibly appended with a
 number to make it unique.  For example, when `$GIT_DIR=/path/main/.git` the
 command `git worktree add /path/other/test-next next` creates the linked
-working tree in `/path/other/test-next` and also creates a
+worktree in `/path/other/test-next` and also creates a
 `$GIT_DIR/worktrees/test-next` directory (or `$GIT_DIR/worktrees/test-next1`
 if `test-next` is already taken).
 
-Within a linked working tree, `$GIT_DIR` is set to point to this private
+Within a linked worktree, `$GIT_DIR` is set to point to this private
 directory (e.g. `/path/main/.git/worktrees/test-next` in the example) and
-`$GIT_COMMON_DIR` is set to point back to the main working tree's `$GIT_DIR`
+`$GIT_COMMON_DIR` is set to point back to the main worktree's `$GIT_DIR`
 (e.g. `/path/main/.git`). These settings are made in a `.git` file located at
-the top directory of the linked working tree.
+the top directory of the linked worktree.
 
 Path resolution via `git rev-parse --git-path` uses either
 `$GIT_DIR` or `$GIT_COMMON_DIR` depending on the path. For example, in the
-linked working tree `git rev-parse --git-path HEAD` returns
+linked worktree `git rev-parse --git-path HEAD` returns
 `/path/main/.git/worktrees/test-next/HEAD` (not
 `/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
 rev-parse --git-path refs/heads/master` uses
 `$GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
-since refs are shared across all working trees, except `refs/bisect` and
+since refs are shared across all worktrees, except `refs/bisect` and
 `refs/worktree`.
 
 See linkgit:gitrepository-layout[5] for more information. The rule of
@@ -348,8 +348,8 @@ thumb is do not make any assumption about whether a path belongs to
 `$GIT_DIR` or `$GIT_COMMON_DIR` when you need to directly access something
 inside `$GIT_DIR`. Use `git rev-parse --git-path` to get the final path.
 
-If you manually move a linked working tree, you need to update the `gitdir` file
-in the entry's directory. For example, if a linked working tree is moved
+If you manually move a linked worktree, you need to update the `gitdir` file
+in the entry's directory. For example, if a linked worktree is moved
 to `/newpath/test-next` and its `.git` file points to
 `/path/main/.git/worktrees/test-next`, then update
 `/path/main/.git/worktrees/test-next/gitdir` to reference `/newpath/test-next`
@@ -358,10 +358,10 @@ automatically.
 
 To prevent a `$GIT_DIR/worktrees` entry from being pruned (which
 can be useful in some situations, such as when the
-entry's working tree is stored on a portable device), use the
+entry's worktree is stored on a portable device), use the
 `git worktree lock` command, which adds a file named
 `locked` to the entry's directory. The file contains the reason in
-plain text. For example, if a linked working tree's `.git` file points
+plain text. For example, if a linked worktree's `.git` file points
 to `/path/main/.git/worktrees/test-next` then a file named
 `/path/main/.git/worktrees/test-next/locked` will prevent the
 `test-next` entry from being pruned.  See
-- 
gitgitgadget


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

* [PATCH 11/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (9 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 10/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 17:54 ` Derrick Stolee via GitGitGadget
  2022-02-20 22:37   ` Taylor Blau
  2022-02-20 22:38 ` [PATCH 00/11] Updates to worktree code and docs Taylor Blau
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
  12 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-20 17:54 UTC (permalink / raw)
  To: git

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the last of multiple changes to git-worktree.txt, starting at
the LIST OUTPUT FORMAT section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 923b44d3fb2..1d5111ddba5 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -382,11 +382,11 @@ $ git worktree list
 /path/to/other-linked-worktree  1234abc  (detached HEAD)
 ------------
 
-The command also shows annotations for each working tree, according to its state.
+The command also shows annotations for each worktree, according to its state.
 These annotations are:
 
- * `locked`, if the working tree is locked.
- * `prunable`, if the working tree can be pruned via `git worktree prune`.
+ * `locked`, if the worktree is locked.
+ * `prunable`, if the worktree can be pruned via `git worktree prune`.
 
 ------------
 $ git worktree list
@@ -404,14 +404,14 @@ $ git worktree list --verbose
 /path/to/linked-worktree              abcd1234 [master]
 /path/to/locked-worktree-no-reason    abcd5678 (detached HEAD) locked
 /path/to/locked-worktree-with-reason  1234abcd (brancha)
-	locked: working tree path is mounted on a portable device
+	locked: worktree path is mounted on a portable device
 /path/to/prunable-worktree            5678abc1 (detached HEAD)
 	prunable: gitdir file points to non-existent location
 ------------
 
 Note that the annotation is moved to the next line if the additional
 information is available, otherwise it stays on the same line as the
-working tree itself.
+worktree itself.
 
 Porcelain Format
 ~~~~~~~~~~~~~~~~
@@ -420,7 +420,7 @@ label and value separated by a single space.  Boolean attributes (like `bare`
 and `detached`) are listed as a label only, and are present only
 if the value is true.  Some attributes (like `locked`) can be listed as a label
 only or with a value depending upon whether a reason is available.  The first
-attribute of a working tree is always `worktree`, an empty line indicates the
+attribute of a worktree is always `worktree`, an empty line indicates the
 end of the record.  For example:
 
 ------------
@@ -470,9 +470,9 @@ EXAMPLES
 You are in the middle of a refactoring session and your boss comes in and
 demands that you fix something immediately. You might typically use
 linkgit:git-stash[1] to store your changes away temporarily, however, your
-working tree is in such a state of disarray (with new, moved, and removed
+worktree is in such a state of disarray (with new, moved, and removed
 files, and other bits and pieces strewn around) that you don't want to risk
-disturbing any of it. Instead, you create a temporary linked working tree to
+disturbing any of it. Instead, you create a temporary linked worktree to
 make the emergency fix, remove it when done, and then resume your earlier
 refactoring session.
 
-- 
gitgitgadget

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

* Re: [PATCH 01/11] worktree: combine two translatable messages
  2022-02-20 17:54 ` [PATCH 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
@ 2022-02-20 20:22   ` Junio C Hamano
  2022-02-20 20:29     ` Derrick Stolee
  0 siblings, 1 reply; 63+ messages in thread
From: Junio C Hamano @ 2022-02-20 20:22 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, Derrick Stolee, Eric Sunshine, Jean-Noël AVILA,
	Elijah Newren

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

[jc: bogus CC addressses stripped and retyped; did something change
at GGG recently?]

> From: Derrick Stolee <derrickstolee@github.com>
>
> These two messages differ only by the config key name, which should not
> be translated. Extract those keys so the messages can be translated from
> the same string.

Makes sense.  Not just the reusing the same string is good, but this
will also make sure that translators have no chance of making a typo
on the variable names themselves, which is an added benefit.

> Reported-by: Jean-Noël AVILA <jn.avila@free.fr>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  builtin/worktree.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/builtin/worktree.c b/builtin/worktree.c
> index c6eb636329a..7c272078dc9 100644
> --- a/builtin/worktree.c
> +++ b/builtin/worktree.c
> @@ -384,11 +384,13 @@ static int add_worktree(const char *path, const char *refname,
>  			    bare &&
>  			    git_config_set_multivar_in_file_gently(
>  					to_file, "core.bare", NULL, "true", 0))
> -				error(_("failed to unset 'core.bare' in '%s'"), to_file);
> +				error(_("failed to unset '%s' in '%s'"),
> +				      "core.bare", to_file);
>  			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
>  			    git_config_set_in_file_gently(to_file,
>  							  "core.worktree", NULL))
> -				error(_("failed to unset 'core.worktree' in '%s'"), to_file);
> +				error(_("failed to unset '%s' in '%s'"),
> +				      "core.worktree", to_file);
>  
>  			git_configset_clear(&cs);
>  		}

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

* Re: [PATCH 02/11] worktree: extract copy_filtered_worktree_config()
  2022-02-20 17:54 ` [PATCH 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
@ 2022-02-20 20:26   ` Junio C Hamano
  0 siblings, 0 replies; 63+ messages in thread
From: Junio C Hamano @ 2022-02-20 20:26 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, Derrick Stolee, Eric Sunshine, Jean-Noël AVILA,
	Elijah Newren

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Derrick Stolee <derrickstolee@github.com>
>
> This logic was introduced by 5325591 (worktree: copy sparse-checkout
> patterns and config on add, 2022-02-07), but some feedback came in that
> the add_worktree() method was already too complex. It is better to
> extract this logic into a helper method to reduce this complexity.
>
> Reported-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  builtin/worktree.c | 81 ++++++++++++++++++++++++----------------------
>  1 file changed, 42 insertions(+), 39 deletions(-)

Quite straight-forward.  Looking good.

Thanks.

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

* Re: [PATCH 01/11] worktree: combine two translatable messages
  2022-02-20 20:22   ` Junio C Hamano
@ 2022-02-20 20:29     ` Derrick Stolee
  0 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee @ 2022-02-20 20:29 UTC (permalink / raw)
  To: Junio C Hamano, Derrick Stolee via GitGitGadget
  Cc: git, Eric Sunshine, Jean-Noël AVILA, Elijah Newren

On 2/20/2022 3:22 PM, Junio C Hamano wrote:
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
> [jc: bogus CC addressses stripped and retyped; did something change
> at GGG recently?]

This is actually my fault. I copy/pasted from the previous PR, but
that led to markdown-formatted links of some of the email addresses,
confusing GGG.

I fixed the description so a reroll shouldn't have this problem.

Thanks,
-Stolee

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

* Re: [PATCH 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 ` [PATCH 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
@ 2022-02-20 20:42   ` Junio C Hamano
  2022-02-20 20:48     ` Derrick Stolee
  2022-02-24 14:33   ` Philip Oakley
  1 sibling, 1 reply; 63+ messages in thread
From: Junio C Hamano @ 2022-02-20 20:42 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, Eric Sunshine, Elijah Newren, Jean-Noël AVILA,
	Derrick Stolee

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Derrick Stolee <derrickstolee@github.com>
>
> It is helpful to distinguish between a 'working tree' and a 'worktree'.
> A worktree contains a working tree plus additional metadata. This
> metadata includes per-worktree refs and worktree-specific config.
>
> This is the first of multiple changes to git-worktree.txt, restricted to
> the DESCRIPTION section.

Looked almost perfect, except for one and a half iffy parts.

> -If a working tree is deleted without using `git worktree remove`, then
> ...
> +If a worktree is deleted without using `git worktree remove`, then
>  its associated administrative files, which reside in the repository
>  (see "DETAILS" below), will eventually be removed automatically (see

I think this one should be "working tree".  The administrative files
are integral part of a worktree, but from the point of view of a
working tree, it is "associated" with it and not part of it.  If you
delete without using "git worktree remove", that would be done with
a command like "rm -f", which removes the working tree but not the
worktree.

> -If a linked working tree is stored on a portable device or network share
> -which is not always mounted, you can prevent its administrative files from
> -being pruned by issuing the `git worktree lock` command, optionally
> -specifying `--reason` to explain why the working tree is locked.
> +If a linked worktree is stored on a portable device or network share which
> +is not always mounted, you can prevent its administrative files from being
> +pruned by issuing the `git worktree lock` command, optionally specifying
> +`--reason` to explain why the worktree is locked.

This one, because what is on a removal device is the working tree
half of a worktree that leaves the "administrative files" half still
on the mothership when it is removed, I think it is OK to call it a
working tree, but because we defined "a linked worktree" and removed
the definition of "a linked working tree" earlier, the original as-is
won't work well.

"If the working tree portion of a linked worktree is stored on ..."
may be more correct, but it is a bit mouthful.  I dunno (hence this
is not even a full "iffy" part, just halfway iffy).

>  add <path> [<commit-ish>]::
>  
> -Create `<path>` and checkout `<commit-ish>` into it. The new working directory
> -is linked to the current repository, sharing everything except working
> -directory specific files such as `HEAD`, `index`, etc. As a convenience,
> -`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
> +Create `<path>` and checkout `<commit-ish>` into it. The new worktree
> +is linked to the current repository, sharing everything except per-worktree
> +files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
> +be a bare "`-`", which is synonymous with `@{-1}`.

The original has the problem, too, but it is unclear what is created
at <path> by reading only the first sentence, even though the
mention of "The new worktree" that immediately follows strongly
hints that we are creating a worktree.

    Create a new worktree at <path> and ...

perhaps?  This clarification is not even part of one and a half ;-)

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

* Re: [PATCH 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 20:42   ` Junio C Hamano
@ 2022-02-20 20:48     ` Derrick Stolee
  0 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee @ 2022-02-20 20:48 UTC (permalink / raw)
  To: Junio C Hamano, Derrick Stolee via GitGitGadget
  Cc: git, Eric Sunshine, Elijah Newren, Jean-Noël AVILA

On 2/20/2022 3:42 PM, Junio C Hamano wrote:
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>> From: Derrick Stolee <derrickstolee@github.com>
>>
>> It is helpful to distinguish between a 'working tree' and a 'worktree'.
>> A worktree contains a working tree plus additional metadata. This
>> metadata includes per-worktree refs and worktree-specific config.
>>
>> This is the first of multiple changes to git-worktree.txt, restricted to
>> the DESCRIPTION section.
> 
> Looked almost perfect, except for one and a half iffy parts.
> 
>> -If a working tree is deleted without using `git worktree remove`, then
>> ...
>> +If a worktree is deleted without using `git worktree remove`, then
>>  its associated administrative files, which reside in the repository
>>  (see "DETAILS" below), will eventually be removed automatically (see
> 
> I think this one should be "working tree".  The administrative files
> are integral part of a worktree, but from the point of view of a
> working tree, it is "associated" with it and not part of it.  If you
> delete without using "git worktree remove", that would be done with
> a command like "rm -f", which removes the working tree but not the
> worktree.

Good point. I agree. There is some similar discussion in the COMMANDS
section around moving/renaming/repairing worktrees, so likely similar
thoughts apply there, too.
 
>> -If a linked working tree is stored on a portable device or network share
>> -which is not always mounted, you can prevent its administrative files from
>> -being pruned by issuing the `git worktree lock` command, optionally
>> -specifying `--reason` to explain why the working tree is locked.
>> +If a linked worktree is stored on a portable device or network share which
>> +is not always mounted, you can prevent its administrative files from being
>> +pruned by issuing the `git worktree lock` command, optionally specifying
>> +`--reason` to explain why the worktree is locked.
> 
> This one, because what is on a removal device is the working tree
> half of a worktree that leaves the "administrative files" half still
> on the mothership when it is removed, I think it is OK to call it a
> working tree, but because we defined "a linked worktree" and removed
> the definition of "a linked working tree" earlier, the original as-is
> won't work well.
> 
> "If the working tree portion of a linked worktree is stored on ..."
> may be more correct, but it is a bit mouthful.  I dunno (hence this
> is not even a full "iffy" part, just halfway iffy).

I think the wordy way you say it here is the most correct way.

Another way to approach this is to start at the definition by saying
"We will refer to the location of a worktree to be its associated
working directory, even though its metadata is stored in another
location."

That could allow us to use "worktree" even in these cases, but does
create some overloading of the word.

>>  add <path> [<commit-ish>]::
>>  
>> -Create `<path>` and checkout `<commit-ish>` into it. The new working directory
>> -is linked to the current repository, sharing everything except working
>> -directory specific files such as `HEAD`, `index`, etc. As a convenience,
>> -`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
>> +Create `<path>` and checkout `<commit-ish>` into it. The new worktree
>> +is linked to the current repository, sharing everything except per-worktree
>> +files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
>> +be a bare "`-`", which is synonymous with `@{-1}`.
> 
> The original has the problem, too, but it is unclear what is created
> at <path> by reading only the first sentence, even though the
> mention of "The new worktree" that immediately follows strongly
> hints that we are creating a worktree.
> 
>     Create a new worktree at <path> and ...
> 
> perhaps?  This clarification is not even part of one and a half ;-)

This is a good change.

Thanks,
-Stolee

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

* Re: [PATCH 04/11] worktree: extract checkout_worktree()
  2022-02-20 17:54 ` [PATCH 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
@ 2022-02-20 21:59   ` Taylor Blau
  0 siblings, 0 replies; 63+ messages in thread
From: Taylor Blau @ 2022-02-20 21:59 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git

On Sun, Feb 20, 2022 at 05:54:20PM +0000, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <derrickstolee@github.com>
>
> The ability to add the --no-checkout flag to 'git worktree' was added in
> ef2a0ac9a0 (worktree: add: introduce --checkout option, 2016-03-29).
> Recently, we noticed that add_worktree() is rather complicated, so
> extract the logic for this checkout process to simplify the method.

Thanks; all of these "worktree: extract ..." patches look fine to me. I
reviewed them locally with:

    $ git show <the-patch> --color-moved-ws=ignore-all-space --color-moved

and it was clear that all of the existing functionality was preserved.

Thanks,
Taylor

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

* Re: [PATCH 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 ` [PATCH 08/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 22:29   ` Taylor Blau
  0 siblings, 0 replies; 63+ messages in thread
From: Taylor Blau @ 2022-02-20 22:29 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git

On Sun, Feb 20, 2022 at 05:54:24PM +0000, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <derrickstolee@github.com>
>
> It is helpful to distinguish between a 'working tree' and a 'worktree'.
> A worktree contains a working tree plus additional metadata. This
> metadata includes per-worktree refs and worktree-specific config.
>
> This is the fourth of multiple changes to git-worktree.txt, restricted
> to the REFS section.
>
> This section previously described "per working tree" refs but they are
> now replaced with "per-worktree" refs, which matches the definition in
> glossary-content.txt.
>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  Documentation/git-worktree.txt | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> index 10021c85e77..54a2c335fd5 100644
> --- a/Documentation/git-worktree.txt
> +++ b/Documentation/git-worktree.txt
> @@ -255,24 +255,23 @@ have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
>
>  REFS
>  ----
> -In multiple working trees, some refs may be shared between all working
> -trees and some refs are local. One example is `HEAD` which is different for each
> -working tree. This section is about the sharing rules and how to access
> -refs of one working tree from another.

Not the fault of this patch, but I have a tough time deciphering this
first sentence. Would the first part be clearer as:

    When using multiple worktrees, some refs are shared among all
    worktrees, but others are specific to an individual worktree.

?

Otherwise, this patch (and all of the replacement one preceding it)
look good to me.

Thanks,
Taylor

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

* Re: [PATCH 09/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 ` [PATCH 09/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 22:31   ` Taylor Blau
  2022-02-21  2:26     ` Derrick Stolee
  0 siblings, 1 reply; 63+ messages in thread
From: Taylor Blau @ 2022-02-20 22:31 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git

On Sun, Feb 20, 2022 at 05:54:25PM +0000, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <derrickstolee@github.com>
>
> It is helpful to distinguish between a 'working tree' and a 'worktree'.
> A worktree contains a working tree plus additional metadata. This
> metadata includes per-worktree refs and worktree-specific config.
>
> This is the fifth of multiple changes to git-worktree.txt, restricted to
> the CONFIGURATION FILE section.
>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  Documentation/git-worktree.txt | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> index 54a2c335fd5..8821e56c6ec 100644
> --- a/Documentation/git-worktree.txt
> +++ b/Documentation/git-worktree.txt
> @@ -283,12 +283,12 @@ which will handle refs correctly.
>
>  CONFIGURATION FILE
>  ------------------
> -By default, the repository `config` file is shared across all working
> -trees. If the config variables `core.bare` or `core.worktree` are
> -present in the common config file and `extensions.worktreeConfig` is
> -disabled, then they will be applied to the main working tree only.
> +By default, the repository `config` file is shared across all worktrees.
> +If the config variables `core.bare` or `core.worktree` are present in the
> +common config file and `extensions.worktreeConfig` is disabled, then they
> +will be applied to the main worktree only.
>
> -In order to have configuration specific to working trees, you can turn
> +In order to have configuration specific to worktrees, you can turn

Also not the fault of this patch, but I wonder if this would be more
clearly worded as:

    In order to have worktree-specific configuration, you can [...].

>  on the `worktreeConfig` extension, e.g.:
>
>  ------------
> @@ -302,16 +302,16 @@ versions will refuse to access repositories with this extension.
>
>  Note that in this file, the exception for `core.bare` and `core.worktree`
>  is gone. If they exist in `$GIT_DIR/config`, you must move
> -them to the `config.worktree` of the main working tree. You may also
> -take this opportunity to review and move other configuration that you
> -do not want to share to all working trees:
> +them to the `config.worktree` of the main worktree. You may also take this
> +opportunity to review and move other configuration that you do not want to
> +share to all worktrees:
>
>   - `core.worktree` should never be shared.
>
>   - `core.bare` should not be shared if the value is `core.bare=true`.
>
> - - `core.sparseCheckout` is recommended per working tree, unless you
> -   are sure you always use sparse checkout for all working trees.
> + - `core.sparseCheckout` is recommended per worktree, unless you are sure
> +   you always use sparse checkout for all worktrees.

Another minor point, but perhaps the third bullet should share more
language with the first two. Maybe instead:

    - `core.sparseCheckout` should not be shared, unless you are sure
      you always use sparse checkout among all worktrees.

Feel free (in this instance, and in any others) to ignore these
suggestions. I wouldn't raise them in an ordinary review, but I figure
since we are already tweaking the language in this file, it couldn't
hurt to mention here...

Thanks,
Taylor

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

* Re: [PATCH 11/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 ` [PATCH 11/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 22:37   ` Taylor Blau
  2022-02-21  2:11     ` Derrick Stolee
  0 siblings, 1 reply; 63+ messages in thread
From: Taylor Blau @ 2022-02-20 22:37 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git

On Sun, Feb 20, 2022 at 05:54:27PM +0000, Derrick Stolee via GitGitGadget wrote:
> @@ -404,14 +404,14 @@ $ git worktree list --verbose
>  /path/to/linked-worktree              abcd1234 [master]
>  /path/to/locked-worktree-no-reason    abcd5678 (detached HEAD) locked
>  /path/to/locked-worktree-with-reason  1234abcd (brancha)
> -	locked: working tree path is mounted on a portable device
> +	locked: worktree path is mounted on a portable device

I thought this might have been an over-zealous find-and-replace, since I
had assumed that the "locked: working tree path ..." message came from
Git. But my assumption was wrong, and this is the `<reason>` in `git
worktree --reason=<reason> <worktree>`.

So it makes sense to update here along with the rest of these other
instances.

>  /path/to/prunable-worktree            5678abc1 (detached HEAD)
>  	prunable: gitdir file points to non-existent location
>  ------------
>
>  Note that the annotation is moved to the next line if the additional
>  information is available, otherwise it stays on the same line as the
> -working tree itself.
> +worktree itself.
>
>  Porcelain Format
>  ~~~~~~~~~~~~~~~~
> @@ -420,7 +420,7 @@ label and value separated by a single space.  Boolean attributes (like `bare`
>  and `detached`) are listed as a label only, and are present only
>  if the value is true.  Some attributes (like `locked`) can be listed as a label
>  only or with a value depending upon whether a reason is available.  The first
> -attribute of a working tree is always `worktree`, an empty line indicates the
> +attribute of a worktree is always `worktree`, an empty line indicates the
>  end of the record.  For example:
>
>  ------------
> @@ -470,9 +470,9 @@ EXAMPLES
>  You are in the middle of a refactoring session and your boss comes in and
>  demands that you fix something immediately. You might typically use
>  linkgit:git-stash[1] to store your changes away temporarily, however, your
> -working tree is in such a state of disarray (with new, moved, and removed
> +worktree is in such a state of disarray (with new, moved, and removed

This one should probably remain as "working tree", since the example
being given here is focused on disarray in the working tree itself, not
in the worktree's metadata.

>  files, and other bits and pieces strewn around) that you don't want to risk
> -disturbing any of it. Instead, you create a temporary linked working tree to
> +disturbing any of it. Instead, you create a temporary linked worktree to
>  make the emergency fix, remove it when done, and then resume your earlier
>  refactoring session.

But this one is in the context of "create a _worktree_", which makes
sense and should probably be updated as you have done here.

Thanks,
Taylor

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

* Re: [PATCH 00/11] Updates to worktree code and docs
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (10 preceding siblings ...)
  2022-02-20 17:54 ` [PATCH 11/11] " Derrick Stolee via GitGitGadget
@ 2022-02-20 22:38 ` Taylor Blau
  2022-02-20 22:41   ` Taylor Blau
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
  12 siblings, 1 reply; 63+ messages in thread
From: Taylor Blau @ 2022-02-20 22:38 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget; +Cc: git

On Sun, Feb 20, 2022 at 05:54:16PM +0000, Derrick Stolee via GitGitGadget wrote:
> This is built on top of ds/sparse-checkout-requires-per-worktree-config and
> includes some forward fixes for comments from that series.

Thanks, I took a careful look through these and they all mostly look
good to me.

I left a couple of small notes throughout, but I wouldn't be sad if you
ignored any or all of them (though see my notes on the very last patch,
where I think you replaced one too many instances of "working tree").

Thanks,
Taylor

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

* Re: [PATCH 00/11] Updates to worktree code and docs
  2022-02-20 22:38 ` [PATCH 00/11] Updates to worktree code and docs Taylor Blau
@ 2022-02-20 22:41   ` Taylor Blau
  0 siblings, 0 replies; 63+ messages in thread
From: Taylor Blau @ 2022-02-20 22:41 UTC (permalink / raw)
  Cc: Derrick Stolee via GitGitGadget, Junio C Hamano, Eric Sunshine,
	Jean-Noël AVILA, Elijah Newren, git

On Sun, Feb 20, 2022 at 05:38:20PM -0500, Taylor Blau wrote:
> On Sun, Feb 20, 2022 at 05:54:16PM +0000, Derrick Stolee via GitGitGadget wrote:
> > This is built on top of ds/sparse-checkout-requires-per-worktree-config and
> > includes some forward fixes for comments from that series.
>
> Thanks, I took a careful look through these and they all mostly look
> good to me.
>
> I left a couple of small notes throughout, but I wouldn't be sad if you
> ignored any or all of them (though see my notes on the very last patch,
> where I think you replaced one too many instances of "working tree").

In this (and a handful of other replies), my 'group-reply' macro was too
eager to drop any entries in the Cc list that it couldn't parse, so a
handful of recipients got dropped.

That's fine, since nothing in any of those messages was critical in
terms of reaching those individuals, but they are CC'd here just in
case.

Thanks,
Taylor

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

* Re: [PATCH 11/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 22:37   ` Taylor Blau
@ 2022-02-21  2:11     ` Derrick Stolee
  0 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee @ 2022-02-21  2:11 UTC (permalink / raw)
  To: Taylor Blau, Derrick Stolee via GitGitGadget; +Cc: git

On 2/20/2022 5:37 PM, Taylor Blau wrote:
> On Sun, Feb 20, 2022 at 05:54:27PM +0000, Derrick Stolee via GitGitGadget wrote:
>> @@ -404,14 +404,14 @@ $ git worktree list --verbose
>>  /path/to/linked-worktree              abcd1234 [master]
>>  /path/to/locked-worktree-no-reason    abcd5678 (detached HEAD) locked
>>  /path/to/locked-worktree-with-reason  1234abcd (brancha)
>> -	locked: working tree path is mounted on a portable device
>> +	locked: worktree path is mounted on a portable device
> 
> I thought this might have been an over-zealous find-and-replace, since I
> had assumed that the "locked: working tree path ..." message came from
> Git. But my assumption was wrong, and this is the `<reason>` in `git
> worktree --reason=<reason> <worktree>`.
> 
> So it makes sense to update here along with the rest of these other
> instances.

This is a good catch. It could have easily been over-zealous.

>>  /path/to/prunable-worktree            5678abc1 (detached HEAD)
>>  	prunable: gitdir file points to non-existent location
>>  ------------
>>
>>  Note that the annotation is moved to the next line if the additional
>>  information is available, otherwise it stays on the same line as the
>> -working tree itself.
>> +worktree itself.
>>
>>  Porcelain Format
>>  ~~~~~~~~~~~~~~~~
>> @@ -420,7 +420,7 @@ label and value separated by a single space.  Boolean attributes (like `bare`
>>  and `detached`) are listed as a label only, and are present only
>>  if the value is true.  Some attributes (like `locked`) can be listed as a label
>>  only or with a value depending upon whether a reason is available.  The first
>> -attribute of a working tree is always `worktree`, an empty line indicates the
>> +attribute of a worktree is always `worktree`, an empty line indicates the
>>  end of the record.  For example:
>>
>>  ------------
>> @@ -470,9 +470,9 @@ EXAMPLES
>>  You are in the middle of a refactoring session and your boss comes in and
>>  demands that you fix something immediately. You might typically use
>>  linkgit:git-stash[1] to store your changes away temporarily, however, your
>> -working tree is in such a state of disarray (with new, moved, and removed
>> +worktree is in such a state of disarray (with new, moved, and removed
> 
> This one should probably remain as "working tree", since the example
> being given here is focused on disarray in the working tree itself, not
> in the worktree's metadata.

You're right. Thanks for catching this one.

>>  files, and other bits and pieces strewn around) that you don't want to risk
>> -disturbing any of it. Instead, you create a temporary linked working tree to
>> +disturbing any of it. Instead, you create a temporary linked worktree to
>>  make the emergency fix, remove it when done, and then resume your earlier
>>  refactoring session.
> 
> But this one is in the context of "create a _worktree_", which makes
> sense and should probably be updated as you have done here.

Thanks,
-Stolee

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

* Re: [PATCH 09/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 22:31   ` Taylor Blau
@ 2022-02-21  2:26     ` Derrick Stolee
  0 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee @ 2022-02-21  2:26 UTC (permalink / raw)
  To: Taylor Blau, Derrick Stolee via GitGitGadget; +Cc: git

On 2/20/2022 5:31 PM, Taylor Blau wrote:
> On Sun, Feb 20, 2022 at 05:54:25PM +0000, Derrick Stolee via GitGitGadget wrote:
>> From: Derrick Stolee <derrickstolee@github.com>
...
>> -In order to have configuration specific to working trees, you can turn
>> +In order to have configuration specific to worktrees, you can turn
> 
> Also not the fault of this patch, but I wonder if this would be more
> clearly worded as:
> 
>     In order to have worktree-specific configuration, you can [...].
> 

I like this change.

>>   - `core.worktree` should never be shared.
>>
>>   - `core.bare` should not be shared if the value is `core.bare=true`.
>>
>> - - `core.sparseCheckout` is recommended per working tree, unless you
>> -   are sure you always use sparse checkout for all working trees.
>> + - `core.sparseCheckout` is recommended per worktree, unless you are sure
>> +   you always use sparse checkout for all worktrees.
> 
> Another minor point, but perhaps the third bullet should share more
> language with the first two. Maybe instead:
> 
>     - `core.sparseCheckout` should not be shared, unless you are sure
>       you always use sparse checkout among all worktrees.

I thought I had a good reason to deviate here, but looking at it now I
agree with you.

Thanks,
-Stolee

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

* [PATCH v2 00/11] Updates to worktree code and docs
  2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
                   ` (11 preceding siblings ...)
  2022-02-20 22:38 ` [PATCH 00/11] Updates to worktree code and docs Taylor Blau
@ 2022-02-22  0:17 ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
                     ` (13 more replies)
  12 siblings, 14 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git; +Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee

This is built on top of ds/sparse-checkout-requires-per-worktree-config and
includes some forward fixes for comments from that series.

 * Patch 1 combines two translatable messages into one. (Thanks, Jean-Noël)
 * Patches 2-4 extract methods from the already-busy add_worktree() method.
   (Thanks, Eric)
 * Patches 5-11 update git-worktree.txt to use 'worktree' over 'working
   tree'. This involves some rewrapping of the paragraphs, so the diffs are
   not obviously just a find and replace. I split the changes mostly by
   section of the file to keep the diffs from being too large.


Updates in v2
=============

Based on Junio and Taylor's review, I updated some language in the docs:

 * Some uses of "worktree" should have stayed as "working tree"
 * Some adjacent wording was improved.

Thanks, -Stolee

Derrick Stolee (11):
  worktree: combine two translatable messages
  worktree: extract copy_filtered_worktree_config()
  worktree: extract copy_sparse_checkout()
  worktree: extract checkout_worktree()
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'

 Documentation/git-worktree.txt | 268 ++++++++++++++++-----------------
 builtin/worktree.c             | 138 +++++++++--------
 2 files changed, 209 insertions(+), 197 deletions(-)


base-commit: 3ce113827287079dced9aaf9c5d1e1734ecaa265
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1154%2Fderrickstolee%2Fworktree-forward-fixes-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1154/derrickstolee/worktree-forward-fixes-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1154

Range-diff vs v1:

  1:  a113ed9a844 =  1:  a113ed9a844 worktree: combine two translatable messages
  2:  f8aa87112a8 =  2:  f8aa87112a8 worktree: extract copy_filtered_worktree_config()
  3:  ccc5b1ef9fb =  3:  ccc5b1ef9fb worktree: extract copy_sparse_checkout()
  4:  1e62e4e4fa1 =  4:  1e62e4e4fa1 worktree: extract checkout_worktree()
  5:  a6a8eb8e7bb !  5:  2801ae232ae worktree: use 'worktree' over 'working tree'
     @@ Commit message
          This is the first of multiple changes to git-worktree.txt, restricted to
          the DESCRIPTION section.
      
     +    Helped-by: Junio C Hamano <gitster@pobox.com>
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
       ## Documentation/git-worktree.txt ##
     @@ Documentation/git-worktree.txt: Manage multiple working trees attached to the sa
      -'throwaway' working tree not associated with any branch. For instance,
      -`git worktree add -d <path>` creates a new working tree with a detached
      -`HEAD` at the same commit as the current branch.
     --
     --If a working tree is deleted without using `git worktree remove`, then
      +path `../hotfix`. To instead work on an existing branch in a new worktree,
      +use `git worktree add <path> <branch>`. On the other hand, if you just
      +plan to make some experimental changes or do testing without disturbing
     @@ Documentation/git-worktree.txt: Manage multiple working trees attached to the sa
      +worktree not associated with any branch. For instance,
      +`git worktree add -d <path>` creates a new worktree with a detached `HEAD`
      +at the same commit as the current branch.
     -+
     -+If a worktree is deleted without using `git worktree remove`, then
     + 
     + If a working tree is deleted without using `git worktree remove`, then
       its associated administrative files, which reside in the repository
       (see "DETAILS" below), will eventually be removed automatically (see
       `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
     @@ Documentation/git-worktree.txt: Manage multiple working trees attached to the sa
      -which is not always mounted, you can prevent its administrative files from
      -being pruned by issuing the `git worktree lock` command, optionally
      -specifying `--reason` to explain why the working tree is locked.
     -+If a linked worktree is stored on a portable device or network share which
     -+is not always mounted, you can prevent its administrative files from being
     -+pruned by issuing the `git worktree lock` command, optionally specifying
     -+`--reason` to explain why the worktree is locked.
     ++If the working tree for a a linked worktree is stored on a portable device
     ++or network share which is not always mounted, you can prevent its
     ++administrative files from being pruned by issuing the `git worktree lock`
     ++command, optionally specifying `--reason` to explain why the worktree is
     ++locked.
       
       COMMANDS
       --------
     @@ Documentation/git-worktree.txt: Manage multiple working trees attached to the sa
      -is linked to the current repository, sharing everything except working
      -directory specific files such as `HEAD`, `index`, etc. As a convenience,
      -`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
     -+Create `<path>` and checkout `<commit-ish>` into it. The new worktree
     ++Create a worktree at `<path>` and checkout `<commit-ish>` into it. The new worktree
      +is linked to the current repository, sharing everything except per-worktree
      +files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
      +be a bare "`-`", which is synonymous with `@{-1}`.
  6:  1fc4a98dc7a !  6:  a375e4b6ff0 worktree: use 'worktree' over 'working tree'
     @@ Commit message
          This is the second of multiple changes to git-worktree.txt, restricted
          to the COMMANDS section.
      
     +    There is some language around the movement of "the working tree of a
     +    linked worktree" which is used once, but the remaining uses are left as
     +    just moving "a linked worktree" for brevity.
     +
     +    Helped-by: Junio C Hamano <gitster@pobox.com>
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
       ## Documentation/git-worktree.txt ##
     @@ Documentation/git-worktree.txt: branches from there if `<branch>` is ambiguous b
      -reestablish the connection. If multiple linked working trees are moved,
      -running `repair` from any working tree with each tree's new `<path>` as
      -an argument, will reestablish the connection to all the specified paths.
     -+Similarly, if a linked worktree is moved without using `git worktree
     -+move`, the main worktree (or bare repository) will be unable to locate it.
     -+Running `repair` within the recently-moved worktree will reestablish the
     -+connection. If multiple linked worktrees are moved, running `repair` from
     -+any worktree with each tree's new `<path>` as an argument, will
     -+reestablish the connection to all the specified paths.
     ++Similarly, if the working directory for a linked worktree is moved without
     ++using `git worktree move`, the main worktree (or bare repository) will be
     ++unable to locate it. Running `repair` within the recently-moved worktree
     ++will reestablish the connection. If multiple linked worktrees are moved,
     ++running `repair` from any worktree with each tree's new `<path>` as an
     ++argument, will reestablish the connection to all the specified paths.
       +
      -If both the main working tree and linked working trees have been moved
      -manually, then running `repair` in the main working tree and specifying the
  7:  00d261d0a2a =  7:  d1c4b687cbc worktree: use 'worktree' over 'working tree'
  8:  e7e579d2995 !  8:  65a0cd52711 worktree: use 'worktree' over 'working tree'
     @@ Commit message
          now replaced with "per-worktree" refs, which matches the definition in
          glossary-content.txt.
      
     +    The first paragraph of this section was also a bit confusing, so it is
     +    cleaned up to make it easier to understand.
     +
     +    Helped-by: Taylor Blau <m3@ttaylorr.com>
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
       ## Documentation/git-worktree.txt ##
     @@ Documentation/git-worktree.txt: have two worktrees, at `/abc/def/ghi` and `/abc/
      -working tree via two special paths, `main-worktree` and `worktrees`. The
      -former gives access to per-working tree refs of the main working tree,
      -while the latter to all linked working trees.
     -+In multiple worktrees, some refs may be shared between all worktrees and
     -+some refs are local. One example is `HEAD` which is different for each
     -+worktree. This section is about the sharing rules and how to access
     -+refs of one worktree from another.
     ++When using multiple worktrees, some refs are shared between all worktrees,
     ++but others are specific to an individual worktree. One example is `HEAD`,
     ++which is different for each worktree. This section is about the sharing
     ++rules and how to access refs of one worktree from another.
      +
      +In general, all pseudo refs are per-worktree and all refs starting with
      +`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly
  9:  23e74c87116 !  9:  e8890134fb4 worktree: use 'worktree' over 'working tree'
     @@ Commit message
          This is the fifth of multiple changes to git-worktree.txt, restricted to
          the CONFIGURATION FILE section.
      
     +    While here, clear up some language to improve readability.
     +
     +    Helped-by: Taylor Blau <me@ttaylorr.com>
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
       ## Documentation/git-worktree.txt ##
     @@ Documentation/git-worktree.txt: which will handle refs correctly.
      +will be applied to the main worktree only.
       
      -In order to have configuration specific to working trees, you can turn
     -+In order to have configuration specific to worktrees, you can turn
     - on the `worktreeConfig` extension, e.g.:
     +-on the `worktreeConfig` extension, e.g.:
     ++In order to have worktree-specific configuration, you can turn on the
     ++`worktreeConfig` extension, e.g.:
       
       ------------
     + $ git config extensions.worktreeConfig true
      @@ Documentation/git-worktree.txt: versions will refuse to access repositories with this extension.
       
       Note that in this file, the exception for `core.bare` and `core.worktree`
     @@ Documentation/git-worktree.txt: versions will refuse to access repositories with
       
      - - `core.sparseCheckout` is recommended per working tree, unless you
      -   are sure you always use sparse checkout for all working trees.
     -+ - `core.sparseCheckout` is recommended per worktree, unless you are sure
     -+   you always use sparse checkout for all worktrees.
     ++ - `core.sparseCheckout` should not be shared, unless you are sure you
     ++   always use sparse checkout for all worktrees.
       
       See the documentation of `extensions.worktreeConfig` in
       linkgit:git-config[1] for more details.
 10:  4729a96af6e = 10:  75f0e4ff5c2 worktree: use 'worktree' over 'working tree'
 11:  91773337675 ! 11:  1e07383552a worktree: use 'worktree' over 'working tree'
     @@ Commit message
          This is the last of multiple changes to git-worktree.txt, starting at
          the LIST OUTPUT FORMAT section.
      
     +    The EXAMPLES section has an instance of "working tree" that must stay as
     +    it is, because it is not talking about a worktree, but an example of why
     +    a user might want to create a worktree.
     +
     +    Helped-by: Taylor Blau <me@ttaylorr.com>
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
       ## Documentation/git-worktree.txt ##
     @@ Documentation/git-worktree.txt: label and value separated by a single space.  Bo
       end of the record.  For example:
       
       ------------
     -@@ Documentation/git-worktree.txt: EXAMPLES
     - You are in the middle of a refactoring session and your boss comes in and
     - demands that you fix something immediately. You might typically use
     +@@ Documentation/git-worktree.txt: demands that you fix something immediately. You might typically use
       linkgit:git-stash[1] to store your changes away temporarily, however, your
     --working tree is in such a state of disarray (with new, moved, and removed
     -+worktree is in such a state of disarray (with new, moved, and removed
     + working tree is in such a state of disarray (with new, moved, and removed
       files, and other bits and pieces strewn around) that you don't want to risk
      -disturbing any of it. Instead, you create a temporary linked working tree to
      +disturbing any of it. Instead, you create a temporary linked worktree to

-- 
gitgitgadget

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

* [PATCH v2 01/11] worktree: combine two translatable messages
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
                     ` (12 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

These two messages differ only by the config key name, which should not
be translated. Extract those keys so the messages can be translated from
the same string.

Reported-by: Jean-Noël AVILA <jn.avila@free.fr>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index c6eb636329a..7c272078dc9 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -384,11 +384,13 @@ static int add_worktree(const char *path, const char *refname,
 			    bare &&
 			    git_config_set_multivar_in_file_gently(
 					to_file, "core.bare", NULL, "true", 0))
-				error(_("failed to unset 'core.bare' in '%s'"), to_file);
+				error(_("failed to unset '%s' in '%s'"),
+				      "core.bare", to_file);
 			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
 			    git_config_set_in_file_gently(to_file,
 							  "core.worktree", NULL))
-				error(_("failed to unset 'core.worktree' in '%s'"), to_file);
+				error(_("failed to unset '%s' in '%s'"),
+				      "core.worktree", to_file);
 
 			git_configset_clear(&cs);
 		}
-- 
gitgitgadget


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

* [PATCH v2 02/11] worktree: extract copy_filtered_worktree_config()
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
                     ` (11 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

This logic was introduced by 5325591 (worktree: copy sparse-checkout
patterns and config on add, 2022-02-07), but some feedback came in that
the add_worktree() method was already too complex. It is better to
extract this logic into a helper method to reduce this complexity.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 81 ++++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 39 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 7c272078dc9..2771a6dc793 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -236,6 +236,46 @@ static void check_candidate_path(const char *path,
 		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
+static void copy_filtered_worktree_config(const char *worktree_git_dir)
+{
+	char *from_file = git_pathdup("config.worktree");
+	char *to_file = xstrfmt("%s/config.worktree", worktree_git_dir);
+
+	if (file_exists(from_file)) {
+		struct config_set cs = { { 0 } };
+		const char *core_worktree;
+		int bare;
+
+		if (safe_create_leading_directories(to_file) ||
+			copy_file(to_file, from_file, 0666)) {
+			error(_("failed to copy worktree config from '%s' to '%s'"),
+				from_file, to_file);
+			goto worktree_copy_cleanup;
+		}
+
+		git_configset_init(&cs);
+		git_configset_add_file(&cs, from_file);
+
+		if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
+			bare &&
+			git_config_set_multivar_in_file_gently(
+				to_file, "core.bare", NULL, "true", 0))
+			error(_("failed to unset '%s' in '%s'"),
+				"core.bare", to_file);
+		if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
+			git_config_set_in_file_gently(to_file,
+							"core.worktree", NULL))
+			error(_("failed to unset '%s' in '%s'"),
+				"core.worktree", to_file);
+
+		git_configset_clear(&cs);
+	}
+
+worktree_copy_cleanup:
+	free(from_file);
+	free(to_file);
+}
+
 static int add_worktree(const char *path, const char *refname,
 			const struct add_opts *opts)
 {
@@ -360,45 +400,8 @@ static int add_worktree(const char *path, const char *refname,
 	 * values from the current worktree into the new one, that way the
 	 * new worktree behaves the same as this one.
 	 */
-	if (repository_format_worktree_config) {
-		char *from_file = git_pathdup("config.worktree");
-		char *to_file = xstrfmt("%s/config.worktree",
-					sb_repo.buf);
-
-		if (file_exists(from_file)) {
-			struct config_set cs = { { 0 } };
-			const char *core_worktree;
-			int bare;
-
-			if (safe_create_leading_directories(to_file) ||
-			    copy_file(to_file, from_file, 0666)) {
-				error(_("failed to copy worktree config from '%s' to '%s'"),
-				      from_file, to_file);
-				goto worktree_copy_cleanup;
-			}
-
-			git_configset_init(&cs);
-			git_configset_add_file(&cs, from_file);
-
-			if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
-			    bare &&
-			    git_config_set_multivar_in_file_gently(
-					to_file, "core.bare", NULL, "true", 0))
-				error(_("failed to unset '%s' in '%s'"),
-				      "core.bare", to_file);
-			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
-			    git_config_set_in_file_gently(to_file,
-							  "core.worktree", NULL))
-				error(_("failed to unset '%s' in '%s'"),
-				      "core.worktree", to_file);
-
-			git_configset_clear(&cs);
-		}
-
-worktree_copy_cleanup:
-		free(from_file);
-		free(to_file);
-	}
+	if (repository_format_worktree_config)
+		copy_filtered_worktree_config(sb_repo.buf);
 
 	strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
 	strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
-- 
gitgitgadget


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

* [PATCH v2 03/11] worktree: extract copy_sparse_checkout()
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
                     ` (10 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

This logic was introduced by 5325591 (worktree: copy sparse-checkout
patterns and config on add, 2022-02-07), but some feedback came in that
the add_worktree() method was already too complex. It is better to
extract this logic into a helper method to reduce this complexity.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 2771a6dc793..c806aa2b261 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -236,6 +236,22 @@ static void check_candidate_path(const char *path,
 		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
+static void copy_sparse_checkout(const char *worktree_git_dir)
+{
+	char *from_file = git_pathdup("info/sparse-checkout");
+	char *to_file = xstrfmt("%s/info/sparse-checkout", worktree_git_dir);
+
+	if (file_exists(from_file)) {
+		if (safe_create_leading_directories(to_file) ||
+			copy_file(to_file, from_file, 0666))
+			error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
+				from_file, to_file);
+	}
+
+	free(from_file);
+	free(to_file);
+}
+
 static void copy_filtered_worktree_config(const char *worktree_git_dir)
 {
 	char *from_file = git_pathdup("config.worktree");
@@ -379,21 +395,8 @@ static int add_worktree(const char *path, const char *refname,
 	 * If the current worktree has sparse-checkout enabled, then copy
 	 * the sparse-checkout patterns from the current worktree.
 	 */
-	if (core_apply_sparse_checkout) {
-		char *from_file = git_pathdup("info/sparse-checkout");
-		char *to_file = xstrfmt("%s/info/sparse-checkout",
-					sb_repo.buf);
-
-		if (file_exists(from_file)) {
-			if (safe_create_leading_directories(to_file) ||
-			    copy_file(to_file, from_file, 0666))
-				error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
-				      from_file, to_file);
-		}
-
-		free(from_file);
-		free(to_file);
-	}
+	if (core_apply_sparse_checkout)
+		copy_sparse_checkout(sb_repo.buf);
 
 	/*
 	 * If we are using worktree config, then copy all current config
-- 
gitgitgadget


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

* [PATCH v2 04/11] worktree: extract checkout_worktree()
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (2 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
                     ` (9 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

The ability to add the --no-checkout flag to 'git worktree' was added in
ef2a0ac9a0 (worktree: add: introduce --checkout option, 2016-03-29).
Recently, we noticed that add_worktree() is rather complicated, so
extract the logic for this checkout process to simplify the method.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index c806aa2b261..25807e63a25 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -292,6 +292,18 @@ worktree_copy_cleanup:
 	free(to_file);
 }
 
+static int checkout_worktree(const struct add_opts *opts,
+			     struct strvec *child_env)
+{
+	struct child_process cp = CHILD_PROCESS_INIT;
+	cp.git_cmd = 1;
+	strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
+	if (opts->quiet)
+		strvec_push(&cp.args, "--quiet");
+	strvec_pushv(&cp.env_array, child_env->v);
+	return run_command(&cp);
+}
+
 static int add_worktree(const char *path, const char *refname,
 			const struct add_opts *opts)
 {
@@ -425,17 +437,9 @@ static int add_worktree(const char *path, const char *refname,
 	if (ret)
 		goto done;
 
-	if (opts->checkout) {
-		struct child_process cp = CHILD_PROCESS_INIT;
-		cp.git_cmd = 1;
-		strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
-		if (opts->quiet)
-			strvec_push(&cp.args, "--quiet");
-		strvec_pushv(&cp.env_array, child_env.v);
-		ret = run_command(&cp);
-		if (ret)
-			goto done;
-	}
+	if (opts->checkout &&
+	    (ret = checkout_worktree(opts, &child_env)))
+		goto done;
 
 	is_junk = 0;
 	FREE_AND_NULL(junk_work_tree);
-- 
gitgitgadget


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

* [PATCH v2 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (3 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  7:22     ` Junio C Hamano
  2022-02-23  6:47     ` Elijah Newren
  2022-02-22  0:17   ` [PATCH v2 06/11] " Derrick Stolee via GitGitGadget
                     ` (8 subsequent siblings)
  13 siblings, 2 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the first of multiple changes to git-worktree.txt, restricted to
the DESCRIPTION section.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 50 ++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index b8d53c48303..27437615436 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -25,45 +25,49 @@ Manage multiple working trees attached to the same repository.
 
 A git repository can support multiple working trees, allowing you to check
 out more than one branch at a time.  With `git worktree add` a new working
-tree is associated with the repository.  This new working tree is called a
-"linked working tree" as opposed to the "main working tree" prepared by
-linkgit:git-init[1] or linkgit:git-clone[1].
-A repository has one main working tree (if it's not a
-bare repository) and zero or more linked working trees. When you are done
-with a linked working tree, remove it with `git worktree remove`.
+tree is associated with the repository, along with additional metadata
+that differentiates that working tree from others in the same repository.
+The working tree, along with this metada, is called a "worktree".
+
+This new worktree is called a "linked worktree" as opposed to the "main
+worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1].
+A repository has one main worktree (if it's not a bare repository) and
+zero or more linked worktrees. When you are done with a linked worktree,
+remove it with `git worktree remove`.
 
 In its simplest form, `git worktree add <path>` automatically creates a
 new branch whose name is the final component of `<path>`, which is
 convenient if you plan to work on a new topic. For instance, `git
 worktree add ../hotfix` creates new branch `hotfix` and checks it out at
-path `../hotfix`. To instead work on an existing branch in a new working
-tree, use `git worktree add <path> <branch>`. On the other hand, if you
-just plan to make some experimental changes or do testing without
-disturbing existing development, it is often convenient to create a
-'throwaway' working tree not associated with any branch. For instance,
-`git worktree add -d <path>` creates a new working tree with a detached
-`HEAD` at the same commit as the current branch.
+path `../hotfix`. To instead work on an existing branch in a new worktree,
+use `git worktree add <path> <branch>`. On the other hand, if you just
+plan to make some experimental changes or do testing without disturbing
+existing development, it is often convenient to create a 'throwaway'
+worktree not associated with any branch. For instance,
+`git worktree add -d <path>` creates a new worktree with a detached `HEAD`
+at the same commit as the current branch.
 
 If a working tree is deleted without using `git worktree remove`, then
 its associated administrative files, which reside in the repository
 (see "DETAILS" below), will eventually be removed automatically (see
 `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
-`git worktree prune` in the main or any linked working tree to
-clean up any stale administrative files.
+`git worktree prune` in the main or any linked worktree to clean up any
+stale administrative files.
 
-If a linked working tree is stored on a portable device or network share
-which is not always mounted, you can prevent its administrative files from
-being pruned by issuing the `git worktree lock` command, optionally
-specifying `--reason` to explain why the working tree is locked.
+If the working tree for a a linked worktree is stored on a portable device
+or network share which is not always mounted, you can prevent its
+administrative files from being pruned by issuing the `git worktree lock`
+command, optionally specifying `--reason` to explain why the worktree is
+locked.
 
 COMMANDS
 --------
 add <path> [<commit-ish>]::
 
-Create `<path>` and checkout `<commit-ish>` into it. The new working directory
-is linked to the current repository, sharing everything except working
-directory specific files such as `HEAD`, `index`, etc. As a convenience,
-`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
+Create a worktree at `<path>` and checkout `<commit-ish>` into it. The new worktree
+is linked to the current repository, sharing everything except per-worktree
+files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
+be a bare "`-`", which is synonymous with `@{-1}`.
 +
 If `<commit-ish>` is a branch name (call it `<branch>`) and is not found,
 and neither `-b` nor `-B` nor `--detach` are used, but there does
-- 
gitgitgadget


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

* [PATCH v2 06/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (4 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  7:22     ` Junio C Hamano
  2022-02-22  0:17   ` [PATCH v2 07/11] " Derrick Stolee via GitGitGadget
                     ` (7 subsequent siblings)
  13 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the second of multiple changes to git-worktree.txt, restricted
to the COMMANDS section.

There is some language around the movement of "the working tree of a
linked worktree" which is used once, but the remaining uses are left as
just moving "a linked worktree" for brevity.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 85 ++++++++++++++++------------------
 1 file changed, 41 insertions(+), 44 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 27437615436..00edf343610 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -88,75 +88,72 @@ branches from there if `<branch>` is ambiguous but exists on the
 linkgit:git-config[1].
 +
 If `<commit-ish>` is omitted and neither `-b` nor `-B` nor `--detach` used,
-then, as a convenience, the new working tree is associated with a branch
-(call it `<branch>`) named after `$(basename <path>)`.  If `<branch>`
-doesn't exist, a new branch based on `HEAD` is automatically created as
-if `-b <branch>` was given.  If `<branch>` does exist, it will be
-checked out in the new working tree, if it's not checked out anywhere
-else, otherwise the command will refuse to create the working tree (unless
-`--force` is used).
+then, as a convenience, the new worktree is associated with a branch (call
+it `<branch>`) named after `$(basename <path>)`.  If `<branch>` doesn't
+exist, a new branch based on `HEAD` is automatically created as if
+`-b <branch>` was given.  If `<branch>` does exist, it will be checked out
+in the new worktree, if it's not checked out anywhere else, otherwise the
+command will refuse to create the worktree (unless `--force` is used).
 
 list::
 
-List details of each working tree.  The main working tree is listed first,
-followed by each of the linked working trees.  The output details include
-whether the working tree is bare, the revision currently checked out, the
+List details of each worktree.  The main worktree is listed first,
+followed by each of the linked worktrees.  The output details include
+whether the worktree is bare, the revision currently checked out, the
 branch currently checked out (or "detached HEAD" if none), "locked" if
-the worktree is locked, "prunable" if the worktree can be pruned by `prune`
-command.
+the worktree is locked, "prunable" if the worktree can be pruned by the
+`prune` command.
 
 lock::
 
-If a working tree is on a portable device or network share which
-is not always mounted, lock it to prevent its administrative
-files from being pruned automatically. This also prevents it from
-being moved or deleted. Optionally, specify a reason for the lock
-with `--reason`.
+If a worktree is on a portable device or network share which is not always
+mounted, lock it to prevent its administrative files from being pruned
+automatically. This also prevents it from being moved or deleted.
+Optionally, specify a reason for the lock with `--reason`.
 
 move::
 
-Move a working tree to a new location. Note that the main working tree
-or linked working trees containing submodules cannot be moved with this
-command. (The `git worktree repair` command, however, can reestablish
-the connection with linked working trees if you move the main working
-tree manually.)
+Move a worktree to a new location. Note that the main worktree or linked
+worktrees containing submodules cannot be moved with this command. (The
+`git worktree repair` command, however, can reestablish the connection
+with linked worktrees if you move the main worktree manually.)
 
 prune::
 
-Prune working tree information in `$GIT_DIR/worktrees`.
+Prune worktree information in `$GIT_DIR/worktrees`.
 
 remove::
 
-Remove a working tree. Only clean working trees (no untracked files
-and no modification in tracked files) can be removed. Unclean working
-trees or ones with submodules can be removed with `--force`. The main
-working tree cannot be removed.
+Remove a worktree. Only clean worktrees (no untracked files and no
+modification in tracked files) can be removed. Unclean worktrees or ones
+with submodules can be removed with `--force`. The main worktree cannot be
+removed.
 
 repair [<path>...]::
 
-Repair working tree administrative files, if possible, if they have
-become corrupted or outdated due to external factors.
+Repair worktree administrative files, if possible, if they have become
+corrupted or outdated due to external factors.
 +
-For instance, if the main working tree (or bare repository) is moved,
-linked working trees will be unable to locate it. Running `repair` in
-the main working tree will reestablish the connection from linked
-working trees back to the main working tree.
+For instance, if the main worktree (or bare repository) is moved, linked
+worktrees will be unable to locate it. Running `repair` in the main
+worktree will reestablish the connection from linked worktrees back to the
+main worktree.
 +
-Similarly, if a linked working tree is moved without using `git worktree
-move`, the main working tree (or bare repository) will be unable to
-locate it. Running `repair` within the recently-moved working tree will
-reestablish the connection. If multiple linked working trees are moved,
-running `repair` from any working tree with each tree's new `<path>` as
-an argument, will reestablish the connection to all the specified paths.
+Similarly, if the working directory for a linked worktree is moved without
+using `git worktree move`, the main worktree (or bare repository) will be
+unable to locate it. Running `repair` within the recently-moved worktree
+will reestablish the connection. If multiple linked worktrees are moved,
+running `repair` from any worktree with each tree's new `<path>` as an
+argument, will reestablish the connection to all the specified paths.
 +
-If both the main working tree and linked working trees have been moved
-manually, then running `repair` in the main working tree and specifying the
-new `<path>` of each linked working tree will reestablish all connections
-in both directions.
+If both the main worktree and linked worktrees have been moved manually,
+then running `repair` in the main worktree and specifying the new `<path>`
+of each linked worktree will reestablish all connections in both
+directions.
 
 unlock::
 
-Unlock a working tree, allowing it to be pruned, moved or deleted.
+Unlock a worktree, allowing it to be pruned, moved or deleted.
 
 OPTIONS
 -------
-- 
gitgitgadget


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

* [PATCH v2 07/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (5 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 06/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 08/11] " Derrick Stolee via GitGitGadget
                     ` (6 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the third of multiple changes to git-worktree.txt, restricted to
the OPTIONS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 42 +++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 00edf343610..358325ac073 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -160,25 +160,25 @@ OPTIONS
 
 -f::
 --force::
-	By default, `add` refuses to create a new working tree when
+	By default, `add` refuses to create a new worktree when
 	`<commit-ish>` is a branch name and is already checked out by
-	another working tree, or if `<path>` is already assigned to some
-	working tree but is missing (for instance, if `<path>` was deleted
+	another worktree, or if `<path>` is already assigned to some
+	worktree but is missing (for instance, if `<path>` was deleted
 	manually). This option overrides these safeguards. To add a missing but
-	locked working tree path, specify `--force` twice.
+	locked worktree path, specify `--force` twice.
 +
-`move` refuses to move a locked working tree unless `--force` is specified
-twice. If the destination is already assigned to some other working tree but is
+`move` refuses to move a locked worktree unless `--force` is specified
+twice. If the destination is already assigned to some other worktree but is
 missing (for instance, if `<new-path>` was deleted manually), then `--force`
 allows the move to proceed; use `--force` twice if the destination is locked.
 +
-`remove` refuses to remove an unclean working tree unless `--force` is used.
-To remove a locked working tree, specify `--force` twice.
+`remove` refuses to remove an unclean worktree unless `--force` is used.
+To remove a locked worktree, specify `--force` twice.
 
 -b <new-branch>::
 -B <new-branch>::
 	With `add`, create a new branch named `<new-branch>` starting at
-	`<commit-ish>`, and check out `<new-branch>` into the new working tree.
+	`<commit-ish>`, and check out `<new-branch>` into the new worktree.
 	If `<commit-ish>` is omitted, it defaults to `HEAD`.
 	By default, `-b` refuses to create a new branch if it already
 	exists. `-B` overrides this safeguard, resetting `<new-branch>` to
@@ -186,7 +186,7 @@ To remove a locked working tree, specify `--force` twice.
 
 -d::
 --detach::
-	With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD"
+	With `add`, detach `HEAD` in the new worktree. See "DETACHED HEAD"
 	in linkgit:git-checkout[1].
 
 --[no-]checkout::
@@ -212,7 +212,7 @@ This can also be set up as the default behaviour by using the
 	`--track` in linkgit:git-branch[1] for details.
 
 --lock::
-	Keep the working tree locked after creation. This is the
+	Keep the worktree locked after creation. This is the
 	equivalent of `git worktree lock` after `git worktree add`,
 	but without a race condition.
 
@@ -237,22 +237,22 @@ This can also be set up as the default behaviour by using the
 With `list`, output additional information about worktrees (see below).
 
 --expire <time>::
-	With `prune`, only expire unused working trees older than `<time>`.
+	With `prune`, only expire unused worktrees older than `<time>`.
 +
-With `list`, annotate missing working trees as prunable if they are
-older than `<time>`.
+With `list`, annotate missing worktrees as prunable if they are older than
+`<time>`.
 
 --reason <string>::
-	With `lock` or with `add --lock`, an explanation why the working tree is locked.
+	With `lock` or with `add --lock`, an explanation why the worktree
+	is locked.
 
 <worktree>::
-	Working trees can be identified by path, either relative or
-	absolute.
+	Worktrees can be identified by path, either relative or absolute.
 +
-If the last path components in the working tree's path is unique among
-working trees, it can be used to identify a working tree. For example if
-you only have two working trees, at `/abc/def/ghi` and `/abc/def/ggg`,
-then `ghi` or `def/ghi` is enough to point to the former working tree.
+If the last path components in the worktree's path is unique among
+worktrees, it can be used to identify a worktree. For example if you only
+have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
+`def/ghi` is enough to point to the former worktree.
 
 REFS
 ----
-- 
gitgitgadget


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

* [PATCH v2 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (6 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 07/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22 19:49     ` Taylor Blau
  2022-02-22  0:17   ` [PATCH v2 09/11] " Derrick Stolee via GitGitGadget
                     ` (5 subsequent siblings)
  13 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the fourth of multiple changes to git-worktree.txt, restricted
to the REFS section.

This section previously described "per working tree" refs but they are
now replaced with "per-worktree" refs, which matches the definition in
glossary-content.txt.

The first paragraph of this section was also a bit confusing, so it is
cleaned up to make it easier to understand.

Helped-by: Taylor Blau <m3@ttaylorr.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 358325ac073..41c6d503937 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -256,24 +256,23 @@ have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
 
 REFS
 ----
-In multiple working trees, some refs may be shared between all working
-trees and some refs are local. One example is `HEAD` which is different for each
-working tree. This section is about the sharing rules and how to access
-refs of one working tree from another.
-
-In general, all pseudo refs are per working tree and all refs starting
-with `refs/` are shared. Pseudo refs are ones like `HEAD` which are
-directly under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are
-exceptions, however: refs inside `refs/bisect` and `refs/worktree` are not
-shared.
-
-Refs that are per working tree can still be accessed from another
-working tree via two special paths, `main-worktree` and `worktrees`. The
-former gives access to per-working tree refs of the main working tree,
-while the latter to all linked working trees.
+When using multiple worktrees, some refs are shared between all worktrees,
+but others are specific to an individual worktree. One example is `HEAD`,
+which is different for each worktree. This section is about the sharing
+rules and how to access refs of one worktree from another.
+
+In general, all pseudo refs are per-worktree and all refs starting with
+`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly
+under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions,
+however: refs inside `refs/bisect` and `refs/worktree` are not shared.
+
+Refs that are per-worktree can still be accessed from another worktree via
+two special paths, `main-worktree` and `worktrees`. The former gives
+access to per-worktree refs of the main worktree, while the latter to all
+linked worktrees.
 
 For example, `main-worktree/HEAD` or `main-worktree/refs/bisect/good`
-resolve to the same value as the main working tree's `HEAD` and
+resolve to the same value as the main worktree's `HEAD` and
 `refs/bisect/good` respectively. Similarly, `worktrees/foo/HEAD` or
 `worktrees/bar/refs/bisect/bad` are the same as
 `$GIT_COMMON_DIR/worktrees/foo/HEAD` and
-- 
gitgitgadget


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

* [PATCH v2 09/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (7 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 08/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:17   ` [PATCH v2 10/11] " Derrick Stolee via GitGitGadget
                     ` (4 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the fifth of multiple changes to git-worktree.txt, restricted to
the CONFIGURATION FILE section.

While here, clear up some language to improve readability.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 41c6d503937..d890221d31f 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -284,13 +284,13 @@ which will handle refs correctly.
 
 CONFIGURATION FILE
 ------------------
-By default, the repository `config` file is shared across all working
-trees. If the config variables `core.bare` or `core.worktree` are
-present in the common config file and `extensions.worktreeConfig` is
-disabled, then they will be applied to the main working tree only.
+By default, the repository `config` file is shared across all worktrees.
+If the config variables `core.bare` or `core.worktree` are present in the
+common config file and `extensions.worktreeConfig` is disabled, then they
+will be applied to the main worktree only.
 
-In order to have configuration specific to working trees, you can turn
-on the `worktreeConfig` extension, e.g.:
+In order to have worktree-specific configuration, you can turn on the
+`worktreeConfig` extension, e.g.:
 
 ------------
 $ git config extensions.worktreeConfig true
@@ -303,16 +303,16 @@ versions will refuse to access repositories with this extension.
 
 Note that in this file, the exception for `core.bare` and `core.worktree`
 is gone. If they exist in `$GIT_DIR/config`, you must move
-them to the `config.worktree` of the main working tree. You may also
-take this opportunity to review and move other configuration that you
-do not want to share to all working trees:
+them to the `config.worktree` of the main worktree. You may also take this
+opportunity to review and move other configuration that you do not want to
+share to all worktrees:
 
  - `core.worktree` should never be shared.
 
  - `core.bare` should not be shared if the value is `core.bare=true`.
 
- - `core.sparseCheckout` is recommended per working tree, unless you
-   are sure you always use sparse checkout for all working trees.
+ - `core.sparseCheckout` should not be shared, unless you are sure you
+   always use sparse checkout for all worktrees.
 
 See the documentation of `extensions.worktreeConfig` in
 linkgit:git-config[1] for more details.
-- 
gitgitgadget


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

* [PATCH v2 10/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (8 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 09/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22  0:17   ` Derrick Stolee via GitGitGadget
  2022-02-22  0:18   ` [PATCH v2 11/11] " Derrick Stolee via GitGitGadget
                     ` (3 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:17 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the sixth of multiple changes to git-worktree.txt, restricted to
the DETAILS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index d890221d31f..cca45f19a37 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -319,29 +319,29 @@ linkgit:git-config[1] for more details.
 
 DETAILS
 -------
-Each linked working tree has a private sub-directory in the repository's
+Each linked worktree has a private sub-directory in the repository's
 `$GIT_DIR/worktrees` directory.  The private sub-directory's name is usually
-the base name of the linked working tree's path, possibly appended with a
+the base name of the linked worktree's path, possibly appended with a
 number to make it unique.  For example, when `$GIT_DIR=/path/main/.git` the
 command `git worktree add /path/other/test-next next` creates the linked
-working tree in `/path/other/test-next` and also creates a
+worktree in `/path/other/test-next` and also creates a
 `$GIT_DIR/worktrees/test-next` directory (or `$GIT_DIR/worktrees/test-next1`
 if `test-next` is already taken).
 
-Within a linked working tree, `$GIT_DIR` is set to point to this private
+Within a linked worktree, `$GIT_DIR` is set to point to this private
 directory (e.g. `/path/main/.git/worktrees/test-next` in the example) and
-`$GIT_COMMON_DIR` is set to point back to the main working tree's `$GIT_DIR`
+`$GIT_COMMON_DIR` is set to point back to the main worktree's `$GIT_DIR`
 (e.g. `/path/main/.git`). These settings are made in a `.git` file located at
-the top directory of the linked working tree.
+the top directory of the linked worktree.
 
 Path resolution via `git rev-parse --git-path` uses either
 `$GIT_DIR` or `$GIT_COMMON_DIR` depending on the path. For example, in the
-linked working tree `git rev-parse --git-path HEAD` returns
+linked worktree `git rev-parse --git-path HEAD` returns
 `/path/main/.git/worktrees/test-next/HEAD` (not
 `/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
 rev-parse --git-path refs/heads/master` uses
 `$GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
-since refs are shared across all working trees, except `refs/bisect` and
+since refs are shared across all worktrees, except `refs/bisect` and
 `refs/worktree`.
 
 See linkgit:gitrepository-layout[5] for more information. The rule of
@@ -349,8 +349,8 @@ thumb is do not make any assumption about whether a path belongs to
 `$GIT_DIR` or `$GIT_COMMON_DIR` when you need to directly access something
 inside `$GIT_DIR`. Use `git rev-parse --git-path` to get the final path.
 
-If you manually move a linked working tree, you need to update the `gitdir` file
-in the entry's directory. For example, if a linked working tree is moved
+If you manually move a linked worktree, you need to update the `gitdir` file
+in the entry's directory. For example, if a linked worktree is moved
 to `/newpath/test-next` and its `.git` file points to
 `/path/main/.git/worktrees/test-next`, then update
 `/path/main/.git/worktrees/test-next/gitdir` to reference `/newpath/test-next`
@@ -359,10 +359,10 @@ automatically.
 
 To prevent a `$GIT_DIR/worktrees` entry from being pruned (which
 can be useful in some situations, such as when the
-entry's working tree is stored on a portable device), use the
+entry's worktree is stored on a portable device), use the
 `git worktree lock` command, which adds a file named
 `locked` to the entry's directory. The file contains the reason in
-plain text. For example, if a linked working tree's `.git` file points
+plain text. For example, if a linked worktree's `.git` file points
 to `/path/main/.git/worktrees/test-next` then a file named
 `/path/main/.git/worktrees/test-next/locked` will prevent the
 `test-next` entry from being pruned.  See
-- 
gitgitgadget


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

* [PATCH v2 11/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (9 preceding siblings ...)
  2022-02-22  0:17   ` [PATCH v2 10/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22  0:18   ` Derrick Stolee via GitGitGadget
  2022-02-22 19:50   ` [PATCH v2 00/11] Updates to worktree code and docs Taylor Blau
                     ` (2 subsequent siblings)
  13 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-22  0:18 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the last of multiple changes to git-worktree.txt, starting at
the LIST OUTPUT FORMAT section.

The EXAMPLES section has an instance of "working tree" that must stay as
it is, because it is not talking about a worktree, but an example of why
a user might want to create a worktree.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index cca45f19a37..1243332d722 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -383,11 +383,11 @@ $ git worktree list
 /path/to/other-linked-worktree  1234abc  (detached HEAD)
 ------------
 
-The command also shows annotations for each working tree, according to its state.
+The command also shows annotations for each worktree, according to its state.
 These annotations are:
 
- * `locked`, if the working tree is locked.
- * `prunable`, if the working tree can be pruned via `git worktree prune`.
+ * `locked`, if the worktree is locked.
+ * `prunable`, if the worktree can be pruned via `git worktree prune`.
 
 ------------
 $ git worktree list
@@ -405,14 +405,14 @@ $ git worktree list --verbose
 /path/to/linked-worktree              abcd1234 [master]
 /path/to/locked-worktree-no-reason    abcd5678 (detached HEAD) locked
 /path/to/locked-worktree-with-reason  1234abcd (brancha)
-	locked: working tree path is mounted on a portable device
+	locked: worktree path is mounted on a portable device
 /path/to/prunable-worktree            5678abc1 (detached HEAD)
 	prunable: gitdir file points to non-existent location
 ------------
 
 Note that the annotation is moved to the next line if the additional
 information is available, otherwise it stays on the same line as the
-working tree itself.
+worktree itself.
 
 Porcelain Format
 ~~~~~~~~~~~~~~~~
@@ -421,7 +421,7 @@ label and value separated by a single space.  Boolean attributes (like `bare`
 and `detached`) are listed as a label only, and are present only
 if the value is true.  Some attributes (like `locked`) can be listed as a label
 only or with a value depending upon whether a reason is available.  The first
-attribute of a working tree is always `worktree`, an empty line indicates the
+attribute of a worktree is always `worktree`, an empty line indicates the
 end of the record.  For example:
 
 ------------
@@ -473,7 +473,7 @@ demands that you fix something immediately. You might typically use
 linkgit:git-stash[1] to store your changes away temporarily, however, your
 working tree is in such a state of disarray (with new, moved, and removed
 files, and other bits and pieces strewn around) that you don't want to risk
-disturbing any of it. Instead, you create a temporary linked working tree to
+disturbing any of it. Instead, you create a temporary linked worktree to
 make the emergency fix, remove it when done, and then resume your earlier
 refactoring session.
 
-- 
gitgitgadget

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

* Re: [PATCH v2 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17   ` [PATCH v2 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
@ 2022-02-22  7:22     ` Junio C Hamano
  2022-02-23  6:47     ` Elijah Newren
  1 sibling, 0 replies; 63+ messages in thread
From: Junio C Hamano @ 2022-02-22  7:22 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, sunshine, newren, jn.avila, Taylor Blau, Derrick Stolee

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

> +If the working tree for a a linked worktree is stored on a portable device

a a.

I've prepared the following to be squashed locally.  I also have
another small one for 06/11.

Since 05/11-11/11 all share exactly the same subject, I am not sure
how well "git rebase -i --autosquash" would work, though.  I suspect
it would so very poorly.

Subject: [PATCH] fixup! worktree: use 'worktree' over 'working tree'

---
 Documentation/git-worktree.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 1243332d72..46afc7224f 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -54,7 +54,7 @@ its associated administrative files, which reside in the repository
 `git worktree prune` in the main or any linked worktree to clean up any
 stale administrative files.
 
-If the working tree for a a linked worktree is stored on a portable device
+If the working tree for a linked worktree is stored on a portable device
 or network share which is not always mounted, you can prevent its
 administrative files from being pruned by issuing the `git worktree lock`
 command, optionally specifying `--reason` to explain why the worktree is
-- 
2.35.1-273-ge6ebfd0e8c


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

* Re: [PATCH v2 06/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17   ` [PATCH v2 06/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22  7:22     ` Junio C Hamano
  2022-02-22 14:06       ` Derrick Stolee
  0 siblings, 1 reply; 63+ messages in thread
From: Junio C Hamano @ 2022-02-22  7:22 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, sunshine, newren, jn.avila, Taylor Blau, Derrick Stolee

"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:

> +Similarly, if the working directory for a linked worktree is moved without

"the working tree for a linked worktree" is the phrase used in
05/11, which this part should also adopt, I think.

From 8da2786fa1ff0d094a5c8e7151bfadbd9ca3dd4e Mon Sep 17 00:00:00 2001
From: Junio C Hamano <gitster@pobox.com>
Date: Mon, 21 Feb 2022 23:18:45 -0800
Subject: [PATCH] fixup! worktree: use 'worktree' over 'working tree'

---
 Documentation/git-worktree.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 46afc7224f..2447cd8034 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -139,7 +139,7 @@ worktrees will be unable to locate it. Running `repair` in the main
 worktree will reestablish the connection from linked worktrees back to the
 main worktree.
 +
-Similarly, if the working directory for a linked worktree is moved without
+Similarly, if the working tree for a linked worktree is moved without
 using `git worktree move`, the main worktree (or bare repository) will be
 unable to locate it. Running `repair` within the recently-moved worktree
 will reestablish the connection. If multiple linked worktrees are moved,
-- 
2.35.1-273-ge6ebfd0e8c


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

* Re: [PATCH v2 06/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  7:22     ` Junio C Hamano
@ 2022-02-22 14:06       ` Derrick Stolee
  0 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee @ 2022-02-22 14:06 UTC (permalink / raw)
  To: Junio C Hamano, Derrick Stolee via GitGitGadget
  Cc: git, sunshine, newren, jn.avila, Taylor Blau

On 2/22/2022 2:22 AM, Junio C Hamano wrote:
> "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com> writes:
> 
>> +Similarly, if the working directory for a linked worktree is moved without
> 
> "the working tree for a linked worktree" is the phrase used in
> 05/11, which this part should also adopt, I think.

You're right. I appreciate both fixups you've provided.

Thanks,
-Stolee

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

* Re: [PATCH v2 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17   ` [PATCH v2 08/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22 19:49     ` Taylor Blau
  2022-02-22 21:24       ` Derrick Stolee
  0 siblings, 1 reply; 63+ messages in thread
From: Taylor Blau @ 2022-02-22 19:49 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, sunshine, gitster, newren, jn.avila, Taylor Blau,
	Derrick Stolee

On Tue, Feb 22, 2022 at 12:17:57AM +0000, Derrick Stolee via GitGitGadget wrote:
> Helped-by: Taylor Blau <m3@ttaylorr.com>

One more small fixup, this should be: s/m3/me.

Thanks,
Taylor

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

* Re: [PATCH v2 00/11] Updates to worktree code and docs
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (10 preceding siblings ...)
  2022-02-22  0:18   ` [PATCH v2 11/11] " Derrick Stolee via GitGitGadget
@ 2022-02-22 19:50   ` Taylor Blau
  2022-02-23 20:24     ` Junio C Hamano
  2022-02-23  6:51   ` Elijah Newren
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
  13 siblings, 1 reply; 63+ messages in thread
From: Taylor Blau @ 2022-02-22 19:50 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: git, sunshine, gitster, newren, jn.avila, Taylor Blau,
	Derrick Stolee

On Tue, Feb 22, 2022 at 12:17:49AM +0000, Derrick Stolee via GitGitGadget wrote:
> Updates in v2
> =============
>
> Based on Junio and Taylor's review, I updated some language in the docs:
>
>  * Some uses of "worktree" should have stayed as "working tree"
>  * Some adjacent wording was improved.

Thanks; these updates (in addition to the handful of fixups that Junio
provided on top) look good to me. I'll leave it to the two of you to
figure out if you want to send another reroll, or if Junio already
caught the minor changes when applying.

Thanks,
Taylor

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

* Re: [PATCH v2 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-22 19:49     ` Taylor Blau
@ 2022-02-22 21:24       ` Derrick Stolee
  2022-02-23  0:05         ` Taylor Blau
  0 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee @ 2022-02-22 21:24 UTC (permalink / raw)
  To: Taylor Blau, Derrick Stolee via GitGitGadget
  Cc: git, sunshine, gitster, newren, jn.avila

On 2/22/2022 2:49 PM, Taylor Blau wrote:
> On Tue, Feb 22, 2022 at 12:17:57AM +0000, Derrick Stolee via GitGitGadget wrote:
>> Helped-by: Taylor Blau <m3@ttaylorr.com>
> 
> One more small fixup, this should be: s/m3/me.

!!!

I don't know what was going on with me when making these updates
that I introduced so many typos. Sorry for that.

-Stolee

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

* Re: [PATCH v2 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-22 21:24       ` Derrick Stolee
@ 2022-02-23  0:05         ` Taylor Blau
  0 siblings, 0 replies; 63+ messages in thread
From: Taylor Blau @ 2022-02-23  0:05 UTC (permalink / raw)
  To: Derrick Stolee
  Cc: Taylor Blau, Derrick Stolee via GitGitGadget, git, sunshine,
	gitster, newren, jn.avila

On Tue, Feb 22, 2022 at 04:24:08PM -0500, Derrick Stolee wrote:
> On 2/22/2022 2:49 PM, Taylor Blau wrote:
> > On Tue, Feb 22, 2022 at 12:17:57AM +0000, Derrick Stolee via GitGitGadget wrote:
> >> Helped-by: Taylor Blau <m3@ttaylorr.com>
> >
> > One more small fixup, this should be: s/m3/me.
>
> !!!
>
> I don't know what was going on with me when making these updates
> that I introduced so many typos. Sorry for that.

:-) no problem. I think these sorts of mostly find-and-replace kind of
patches are for whatever reason the most prone to introducing typos!

Thanks,
Taylor

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

* Re: [PATCH v2 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-22  0:17   ` [PATCH v2 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
  2022-02-22  7:22     ` Junio C Hamano
@ 2022-02-23  6:47     ` Elijah Newren
  1 sibling, 0 replies; 63+ messages in thread
From: Elijah Newren @ 2022-02-23  6:47 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: Git Mailing List, Eric Sunshine, Junio C Hamano,
	Jean-Noël AVILA, Taylor Blau, Derrick Stolee

On Mon, Feb 21, 2022 at 4:18 PM Derrick Stolee via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> From: Derrick Stolee <derrickstolee@github.com>
>
> It is helpful to distinguish between a 'working tree' and a 'worktree'.
> A worktree contains a working tree plus additional metadata. This
> metadata includes per-worktree refs and worktree-specific config.
>
> This is the first of multiple changes to git-worktree.txt, restricted to
> the DESCRIPTION section.
>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  Documentation/git-worktree.txt | 50 ++++++++++++++++++----------------
>  1 file changed, 27 insertions(+), 23 deletions(-)
>
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> index b8d53c48303..27437615436 100644
> --- a/Documentation/git-worktree.txt
> +++ b/Documentation/git-worktree.txt
> @@ -25,45 +25,49 @@ Manage multiple working trees attached to the same repository.
>
>  A git repository can support multiple working trees, allowing you to check
>  out more than one branch at a time.  With `git worktree add` a new working
> -tree is associated with the repository.  This new working tree is called a
> -"linked working tree" as opposed to the "main working tree" prepared by
> -linkgit:git-init[1] or linkgit:git-clone[1].
> -A repository has one main working tree (if it's not a
> -bare repository) and zero or more linked working trees. When you are done
> -with a linked working tree, remove it with `git worktree remove`.
> +tree is associated with the repository, along with additional metadata
> +that differentiates that working tree from others in the same repository.
> +The working tree, along with this metada, is called a "worktree".

Looks like the "metada" typo still persisted.

> +This new worktree is called a "linked worktree" as opposed to the "main
> +worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1].
> +A repository has one main worktree (if it's not a bare repository) and
> +zero or more linked worktrees. When you are done with a linked worktree,
> +remove it with `git worktree remove`.
>
>  In its simplest form, `git worktree add <path>` automatically creates a
>  new branch whose name is the final component of `<path>`, which is
>  convenient if you plan to work on a new topic. For instance, `git
>  worktree add ../hotfix` creates new branch `hotfix` and checks it out at
> -path `../hotfix`. To instead work on an existing branch in a new working
> -tree, use `git worktree add <path> <branch>`. On the other hand, if you
> -just plan to make some experimental changes or do testing without
> -disturbing existing development, it is often convenient to create a
> -'throwaway' working tree not associated with any branch. For instance,
> -`git worktree add -d <path>` creates a new working tree with a detached
> -`HEAD` at the same commit as the current branch.
> +path `../hotfix`. To instead work on an existing branch in a new worktree,
> +use `git worktree add <path> <branch>`. On the other hand, if you just
> +plan to make some experimental changes or do testing without disturbing
> +existing development, it is often convenient to create a 'throwaway'
> +worktree not associated with any branch. For instance,
> +`git worktree add -d <path>` creates a new worktree with a detached `HEAD`
> +at the same commit as the current branch.
>
>  If a working tree is deleted without using `git worktree remove`, then
>  its associated administrative files, which reside in the repository
>  (see "DETAILS" below), will eventually be removed automatically (see
>  `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
> -`git worktree prune` in the main or any linked working tree to
> -clean up any stale administrative files.
> +`git worktree prune` in the main or any linked worktree to clean up any
> +stale administrative files.
>
> -If a linked working tree is stored on a portable device or network share
> -which is not always mounted, you can prevent its administrative files from
> -being pruned by issuing the `git worktree lock` command, optionally
> -specifying `--reason` to explain why the working tree is locked.
> +If the working tree for a a linked worktree is stored on a portable device

If you re-roll, don't forget to correct the "a a" too.  :-)

> +or network share which is not always mounted, you can prevent its
> +administrative files from being pruned by issuing the `git worktree lock`
> +command, optionally specifying `--reason` to explain why the worktree is
> +locked.
>
>  COMMANDS
>  --------
>  add <path> [<commit-ish>]::
>
> -Create `<path>` and checkout `<commit-ish>` into it. The new working directory
> -is linked to the current repository, sharing everything except working
> -directory specific files such as `HEAD`, `index`, etc. As a convenience,
> -`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
> +Create a worktree at `<path>` and checkout `<commit-ish>` into it. The new worktree
> +is linked to the current repository, sharing everything except per-worktree
> +files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
> +be a bare "`-`", which is synonymous with `@{-1}`.
>  +
>  If `<commit-ish>` is a branch name (call it `<branch>`) and is not found,
>  and neither `-b` nor `-B` nor `--detach` are used, but there does
> --
> gitgitgadget

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

* Re: [PATCH v2 00/11] Updates to worktree code and docs
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (11 preceding siblings ...)
  2022-02-22 19:50   ` [PATCH v2 00/11] Updates to worktree code and docs Taylor Blau
@ 2022-02-23  6:51   ` Elijah Newren
  2022-02-23 14:26     ` Derrick Stolee
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
  13 siblings, 1 reply; 63+ messages in thread
From: Elijah Newren @ 2022-02-23  6:51 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget
  Cc: Git Mailing List, Eric Sunshine, Junio C Hamano,
	Jean-Noël AVILA, Taylor Blau, Derrick Stolee

On Mon, Feb 21, 2022 at 4:18 PM Derrick Stolee via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> This is built on top of ds/sparse-checkout-requires-per-worktree-config and
> includes some forward fixes for comments from that series.
>
>  * Patch 1 combines two translatable messages into one. (Thanks, Jean-Noël)
>  * Patches 2-4 extract methods from the already-busy add_worktree() method.
>    (Thanks, Eric)
>  * Patches 5-11 update git-worktree.txt to use 'worktree' over 'working
>    tree'. This involves some rewrapping of the paragraphs, so the diffs are
>    not obviously just a find and replace. I split the changes mostly by
>    section of the file to keep the diffs from being too large.
>
>
> Updates in v2
> =============
>
> Based on Junio and Taylor's review, I updated some language in the docs:
>
>  * Some uses of "worktree" should have stayed as "working tree"
>  * Some adjacent wording was improved.

I read through the series.  Looks like the only thing I caught was
typos that others caught -- though one of them was a typo flagged by
Taylor in v1 that went uncorrected in v2 ("metada").  Otherwise, looks
good; thanks for fixing this all up.

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

* Re: [PATCH v2 00/11] Updates to worktree code and docs
  2022-02-23  6:51   ` Elijah Newren
@ 2022-02-23 14:26     ` Derrick Stolee
  0 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee @ 2022-02-23 14:26 UTC (permalink / raw)
  To: Elijah Newren, Derrick Stolee via GitGitGadget
  Cc: Git Mailing List, Eric Sunshine, Junio C Hamano,
	Jean-Noël AVILA, Taylor Blau

On 2/23/2022 1:51 AM, Elijah Newren wrote:
> On Mon, Feb 21, 2022 at 4:18 PM Derrick Stolee via GitGitGadget
> <gitgitgadget@gmail.com> wrote:
>>
>> This is built on top of ds/sparse-checkout-requires-per-worktree-config and
>> includes some forward fixes for comments from that series.
>>
>>  * Patch 1 combines two translatable messages into one. (Thanks, Jean-Noël)
>>  * Patches 2-4 extract methods from the already-busy add_worktree() method.
>>    (Thanks, Eric)
>>  * Patches 5-11 update git-worktree.txt to use 'worktree' over 'working
>>    tree'. This involves some rewrapping of the paragraphs, so the diffs are
>>    not obviously just a find and replace. I split the changes mostly by
>>    section of the file to keep the diffs from being too large.
>>
>>
>> Updates in v2
>> =============
>>
>> Based on Junio and Taylor's review, I updated some language in the docs:
>>
>>  * Some uses of "worktree" should have stayed as "working tree"
>>  * Some adjacent wording was improved.
> 
> I read through the series.  Looks like the only thing I caught was
> typos that others caught -- though one of them was a typo flagged by
> Taylor in v1 that went uncorrected in v2 ("metada").  Otherwise, looks
> good; thanks for fixing this all up.

Thanks, all. There were enough typos in this version that I'll send
a v3 that fixes them all.

Thanks,
-Stolee

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

* [PATCH v3 00/11] Updates to worktree code and docs
  2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
                     ` (12 preceding siblings ...)
  2022-02-23  6:51   ` Elijah Newren
@ 2022-02-23 14:29   ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
                       ` (10 more replies)
  13 siblings, 11 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git; +Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee

This is built on top of ds/sparse-checkout-requires-per-worktree-config and
includes some forward fixes for comments from that series.

 * Patch 1 combines two translatable messages into one. (Thanks, Jean-Noël)
 * Patches 2-4 extract methods from the already-busy add_worktree() method.
   (Thanks, Eric)
 * Patches 5-11 update git-worktree.txt to use 'worktree' over 'working
   tree'. This involves some rewrapping of the paragraphs, so the diffs are
   not obviously just a find and replace. I split the changes mostly by
   section of the file to keep the diffs from being too large.


Updates in v3
=============

Several typos were fixed:

 * Patch 5: fixed "metata" and "a a" typos.
 * Patch 6: fixed "working directory" typo.
 * Patch 8: fixed typo in Taylor's email.


Updates in v2
=============

Based on Junio and Taylor's review, I updated some language in the docs:

 * Some uses of "worktree" should have stayed as "working tree"
 * Some adjacent wording was improved.

Thanks, -Stolee

Derrick Stolee (11):
  worktree: combine two translatable messages
  worktree: extract copy_filtered_worktree_config()
  worktree: extract copy_sparse_checkout()
  worktree: extract checkout_worktree()
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'
  worktree: use 'worktree' over 'working tree'

 Documentation/git-worktree.txt | 268 ++++++++++++++++-----------------
 builtin/worktree.c             | 138 +++++++++--------
 2 files changed, 209 insertions(+), 197 deletions(-)


base-commit: 3ce113827287079dced9aaf9c5d1e1734ecaa265
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1154%2Fderrickstolee%2Fworktree-forward-fixes-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1154/derrickstolee/worktree-forward-fixes-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1154

Range-diff vs v2:

  1:  a113ed9a844 =  1:  a113ed9a844 worktree: combine two translatable messages
  2:  f8aa87112a8 =  2:  f8aa87112a8 worktree: extract copy_filtered_worktree_config()
  3:  ccc5b1ef9fb =  3:  ccc5b1ef9fb worktree: extract copy_sparse_checkout()
  4:  1e62e4e4fa1 =  4:  1e62e4e4fa1 worktree: extract checkout_worktree()
  5:  2801ae232ae !  5:  4e66cf33648 worktree: use 'worktree' over 'working tree'
     @@ Documentation/git-worktree.txt: Manage multiple working trees attached to the sa
      -with a linked working tree, remove it with `git worktree remove`.
      +tree is associated with the repository, along with additional metadata
      +that differentiates that working tree from others in the same repository.
     -+The working tree, along with this metada, is called a "worktree".
     ++The working tree, along with this metadata, is called a "worktree".
      +
      +This new worktree is called a "linked worktree" as opposed to the "main
      +worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1].
     @@ Documentation/git-worktree.txt: Manage multiple working trees attached to the sa
      -which is not always mounted, you can prevent its administrative files from
      -being pruned by issuing the `git worktree lock` command, optionally
      -specifying `--reason` to explain why the working tree is locked.
     -+If the working tree for a a linked worktree is stored on a portable device
     ++If the working tree for a linked worktree is stored on a portable device
      +or network share which is not always mounted, you can prevent its
      +administrative files from being pruned by issuing the `git worktree lock`
      +command, optionally specifying `--reason` to explain why the worktree is
  6:  a375e4b6ff0 !  6:  704cce17815 worktree: use 'worktree' over 'working tree'
     @@ Documentation/git-worktree.txt: branches from there if `<branch>` is ambiguous b
      -reestablish the connection. If multiple linked working trees are moved,
      -running `repair` from any working tree with each tree's new `<path>` as
      -an argument, will reestablish the connection to all the specified paths.
     -+Similarly, if the working directory for a linked worktree is moved without
     ++Similarly, if the working tree for a linked worktree is moved without
      +using `git worktree move`, the main worktree (or bare repository) will be
      +unable to locate it. Running `repair` within the recently-moved worktree
      +will reestablish the connection. If multiple linked worktrees are moved,
  7:  d1c4b687cbc =  7:  bee53e679ff worktree: use 'worktree' over 'working tree'
  8:  65a0cd52711 !  8:  0eb374620a7 worktree: use 'worktree' over 'working tree'
     @@ Commit message
          The first paragraph of this section was also a bit confusing, so it is
          cleaned up to make it easier to understand.
      
     -    Helped-by: Taylor Blau <m3@ttaylorr.com>
     +    Helped-by: Taylor Blau <me@ttaylorr.com>
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
       ## Documentation/git-worktree.txt ##
  9:  e8890134fb4 =  9:  c9afb58d967 worktree: use 'worktree' over 'working tree'
 10:  75f0e4ff5c2 = 10:  1e235677ef0 worktree: use 'worktree' over 'working tree'
 11:  1e07383552a = 11:  11ee7e107b4 worktree: use 'worktree' over 'working tree'

-- 
gitgitgadget

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

* [PATCH v3 01/11] worktree: combine two translatable messages
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
                       ` (9 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

These two messages differ only by the config key name, which should not
be translated. Extract those keys so the messages can be translated from
the same string.

Reported-by: Jean-Noël AVILA <jn.avila@free.fr>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index c6eb636329a..7c272078dc9 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -384,11 +384,13 @@ static int add_worktree(const char *path, const char *refname,
 			    bare &&
 			    git_config_set_multivar_in_file_gently(
 					to_file, "core.bare", NULL, "true", 0))
-				error(_("failed to unset 'core.bare' in '%s'"), to_file);
+				error(_("failed to unset '%s' in '%s'"),
+				      "core.bare", to_file);
 			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
 			    git_config_set_in_file_gently(to_file,
 							  "core.worktree", NULL))
-				error(_("failed to unset 'core.worktree' in '%s'"), to_file);
+				error(_("failed to unset '%s' in '%s'"),
+				      "core.worktree", to_file);
 
 			git_configset_clear(&cs);
 		}
-- 
gitgitgadget


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

* [PATCH v3 02/11] worktree: extract copy_filtered_worktree_config()
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
                       ` (8 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

This logic was introduced by 5325591 (worktree: copy sparse-checkout
patterns and config on add, 2022-02-07), but some feedback came in that
the add_worktree() method was already too complex. It is better to
extract this logic into a helper method to reduce this complexity.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 81 ++++++++++++++++++++++++----------------------
 1 file changed, 42 insertions(+), 39 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 7c272078dc9..2771a6dc793 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -236,6 +236,46 @@ static void check_candidate_path(const char *path,
 		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
+static void copy_filtered_worktree_config(const char *worktree_git_dir)
+{
+	char *from_file = git_pathdup("config.worktree");
+	char *to_file = xstrfmt("%s/config.worktree", worktree_git_dir);
+
+	if (file_exists(from_file)) {
+		struct config_set cs = { { 0 } };
+		const char *core_worktree;
+		int bare;
+
+		if (safe_create_leading_directories(to_file) ||
+			copy_file(to_file, from_file, 0666)) {
+			error(_("failed to copy worktree config from '%s' to '%s'"),
+				from_file, to_file);
+			goto worktree_copy_cleanup;
+		}
+
+		git_configset_init(&cs);
+		git_configset_add_file(&cs, from_file);
+
+		if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
+			bare &&
+			git_config_set_multivar_in_file_gently(
+				to_file, "core.bare", NULL, "true", 0))
+			error(_("failed to unset '%s' in '%s'"),
+				"core.bare", to_file);
+		if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
+			git_config_set_in_file_gently(to_file,
+							"core.worktree", NULL))
+			error(_("failed to unset '%s' in '%s'"),
+				"core.worktree", to_file);
+
+		git_configset_clear(&cs);
+	}
+
+worktree_copy_cleanup:
+	free(from_file);
+	free(to_file);
+}
+
 static int add_worktree(const char *path, const char *refname,
 			const struct add_opts *opts)
 {
@@ -360,45 +400,8 @@ static int add_worktree(const char *path, const char *refname,
 	 * values from the current worktree into the new one, that way the
 	 * new worktree behaves the same as this one.
 	 */
-	if (repository_format_worktree_config) {
-		char *from_file = git_pathdup("config.worktree");
-		char *to_file = xstrfmt("%s/config.worktree",
-					sb_repo.buf);
-
-		if (file_exists(from_file)) {
-			struct config_set cs = { { 0 } };
-			const char *core_worktree;
-			int bare;
-
-			if (safe_create_leading_directories(to_file) ||
-			    copy_file(to_file, from_file, 0666)) {
-				error(_("failed to copy worktree config from '%s' to '%s'"),
-				      from_file, to_file);
-				goto worktree_copy_cleanup;
-			}
-
-			git_configset_init(&cs);
-			git_configset_add_file(&cs, from_file);
-
-			if (!git_configset_get_bool(&cs, "core.bare", &bare) &&
-			    bare &&
-			    git_config_set_multivar_in_file_gently(
-					to_file, "core.bare", NULL, "true", 0))
-				error(_("failed to unset '%s' in '%s'"),
-				      "core.bare", to_file);
-			if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
-			    git_config_set_in_file_gently(to_file,
-							  "core.worktree", NULL))
-				error(_("failed to unset '%s' in '%s'"),
-				      "core.worktree", to_file);
-
-			git_configset_clear(&cs);
-		}
-
-worktree_copy_cleanup:
-		free(from_file);
-		free(to_file);
-	}
+	if (repository_format_worktree_config)
+		copy_filtered_worktree_config(sb_repo.buf);
 
 	strvec_pushf(&child_env, "%s=%s", GIT_DIR_ENVIRONMENT, sb_git.buf);
 	strvec_pushf(&child_env, "%s=%s", GIT_WORK_TREE_ENVIRONMENT, path);
-- 
gitgitgadget


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

* [PATCH v3 03/11] worktree: extract copy_sparse_checkout()
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
                       ` (7 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

This logic was introduced by 5325591 (worktree: copy sparse-checkout
patterns and config on add, 2022-02-07), but some feedback came in that
the add_worktree() method was already too complex. It is better to
extract this logic into a helper method to reduce this complexity.

Reported-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index 2771a6dc793..c806aa2b261 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -236,6 +236,22 @@ static void check_candidate_path(const char *path,
 		die(_("'%s' is a missing but already registered worktree;\nuse '%s -f' to override, or 'prune' or 'remove' to clear"), path, cmd);
 }
 
+static void copy_sparse_checkout(const char *worktree_git_dir)
+{
+	char *from_file = git_pathdup("info/sparse-checkout");
+	char *to_file = xstrfmt("%s/info/sparse-checkout", worktree_git_dir);
+
+	if (file_exists(from_file)) {
+		if (safe_create_leading_directories(to_file) ||
+			copy_file(to_file, from_file, 0666))
+			error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
+				from_file, to_file);
+	}
+
+	free(from_file);
+	free(to_file);
+}
+
 static void copy_filtered_worktree_config(const char *worktree_git_dir)
 {
 	char *from_file = git_pathdup("config.worktree");
@@ -379,21 +395,8 @@ static int add_worktree(const char *path, const char *refname,
 	 * If the current worktree has sparse-checkout enabled, then copy
 	 * the sparse-checkout patterns from the current worktree.
 	 */
-	if (core_apply_sparse_checkout) {
-		char *from_file = git_pathdup("info/sparse-checkout");
-		char *to_file = xstrfmt("%s/info/sparse-checkout",
-					sb_repo.buf);
-
-		if (file_exists(from_file)) {
-			if (safe_create_leading_directories(to_file) ||
-			    copy_file(to_file, from_file, 0666))
-				error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
-				      from_file, to_file);
-		}
-
-		free(from_file);
-		free(to_file);
-	}
+	if (core_apply_sparse_checkout)
+		copy_sparse_checkout(sb_repo.buf);
 
 	/*
 	 * If we are using worktree config, then copy all current config
-- 
gitgitgadget


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

* [PATCH v3 04/11] worktree: extract checkout_worktree()
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (2 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
                       ` (6 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

The ability to add the --no-checkout flag to 'git worktree' was added in
ef2a0ac9a0 (worktree: add: introduce --checkout option, 2016-03-29).
Recently, we noticed that add_worktree() is rather complicated, so
extract the logic for this checkout process to simplify the method.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 builtin/worktree.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/builtin/worktree.c b/builtin/worktree.c
index c806aa2b261..25807e63a25 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -292,6 +292,18 @@ worktree_copy_cleanup:
 	free(to_file);
 }
 
+static int checkout_worktree(const struct add_opts *opts,
+			     struct strvec *child_env)
+{
+	struct child_process cp = CHILD_PROCESS_INIT;
+	cp.git_cmd = 1;
+	strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
+	if (opts->quiet)
+		strvec_push(&cp.args, "--quiet");
+	strvec_pushv(&cp.env_array, child_env->v);
+	return run_command(&cp);
+}
+
 static int add_worktree(const char *path, const char *refname,
 			const struct add_opts *opts)
 {
@@ -425,17 +437,9 @@ static int add_worktree(const char *path, const char *refname,
 	if (ret)
 		goto done;
 
-	if (opts->checkout) {
-		struct child_process cp = CHILD_PROCESS_INIT;
-		cp.git_cmd = 1;
-		strvec_pushl(&cp.args, "reset", "--hard", "--no-recurse-submodules", NULL);
-		if (opts->quiet)
-			strvec_push(&cp.args, "--quiet");
-		strvec_pushv(&cp.env_array, child_env.v);
-		ret = run_command(&cp);
-		if (ret)
-			goto done;
-	}
+	if (opts->checkout &&
+	    (ret = checkout_worktree(opts, &child_env)))
+		goto done;
 
 	is_junk = 0;
 	FREE_AND_NULL(junk_work_tree);
-- 
gitgitgadget


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

* [PATCH v3 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (3 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 06/11] " Derrick Stolee via GitGitGadget
                       ` (5 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the first of multiple changes to git-worktree.txt, restricted to
the DESCRIPTION section.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 50 ++++++++++++++++++----------------
 1 file changed, 27 insertions(+), 23 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index b8d53c48303..956c17c4306 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -25,45 +25,49 @@ Manage multiple working trees attached to the same repository.
 
 A git repository can support multiple working trees, allowing you to check
 out more than one branch at a time.  With `git worktree add` a new working
-tree is associated with the repository.  This new working tree is called a
-"linked working tree" as opposed to the "main working tree" prepared by
-linkgit:git-init[1] or linkgit:git-clone[1].
-A repository has one main working tree (if it's not a
-bare repository) and zero or more linked working trees. When you are done
-with a linked working tree, remove it with `git worktree remove`.
+tree is associated with the repository, along with additional metadata
+that differentiates that working tree from others in the same repository.
+The working tree, along with this metadata, is called a "worktree".
+
+This new worktree is called a "linked worktree" as opposed to the "main
+worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1].
+A repository has one main worktree (if it's not a bare repository) and
+zero or more linked worktrees. When you are done with a linked worktree,
+remove it with `git worktree remove`.
 
 In its simplest form, `git worktree add <path>` automatically creates a
 new branch whose name is the final component of `<path>`, which is
 convenient if you plan to work on a new topic. For instance, `git
 worktree add ../hotfix` creates new branch `hotfix` and checks it out at
-path `../hotfix`. To instead work on an existing branch in a new working
-tree, use `git worktree add <path> <branch>`. On the other hand, if you
-just plan to make some experimental changes or do testing without
-disturbing existing development, it is often convenient to create a
-'throwaway' working tree not associated with any branch. For instance,
-`git worktree add -d <path>` creates a new working tree with a detached
-`HEAD` at the same commit as the current branch.
+path `../hotfix`. To instead work on an existing branch in a new worktree,
+use `git worktree add <path> <branch>`. On the other hand, if you just
+plan to make some experimental changes or do testing without disturbing
+existing development, it is often convenient to create a 'throwaway'
+worktree not associated with any branch. For instance,
+`git worktree add -d <path>` creates a new worktree with a detached `HEAD`
+at the same commit as the current branch.
 
 If a working tree is deleted without using `git worktree remove`, then
 its associated administrative files, which reside in the repository
 (see "DETAILS" below), will eventually be removed automatically (see
 `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
-`git worktree prune` in the main or any linked working tree to
-clean up any stale administrative files.
+`git worktree prune` in the main or any linked worktree to clean up any
+stale administrative files.
 
-If a linked working tree is stored on a portable device or network share
-which is not always mounted, you can prevent its administrative files from
-being pruned by issuing the `git worktree lock` command, optionally
-specifying `--reason` to explain why the working tree is locked.
+If the working tree for a linked worktree is stored on a portable device
+or network share which is not always mounted, you can prevent its
+administrative files from being pruned by issuing the `git worktree lock`
+command, optionally specifying `--reason` to explain why the worktree is
+locked.
 
 COMMANDS
 --------
 add <path> [<commit-ish>]::
 
-Create `<path>` and checkout `<commit-ish>` into it. The new working directory
-is linked to the current repository, sharing everything except working
-directory specific files such as `HEAD`, `index`, etc. As a convenience,
-`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
+Create a worktree at `<path>` and checkout `<commit-ish>` into it. The new worktree
+is linked to the current repository, sharing everything except per-worktree
+files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
+be a bare "`-`", which is synonymous with `@{-1}`.
 +
 If `<commit-ish>` is a branch name (call it `<branch>`) and is not found,
 and neither `-b` nor `-B` nor `--detach` are used, but there does
-- 
gitgitgadget


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

* [PATCH v3 06/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (4 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 07/11] " Derrick Stolee via GitGitGadget
                       ` (4 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the second of multiple changes to git-worktree.txt, restricted
to the COMMANDS section.

There is some language around the movement of "the working tree of a
linked worktree" which is used once, but the remaining uses are left as
just moving "a linked worktree" for brevity.

Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 85 ++++++++++++++++------------------
 1 file changed, 41 insertions(+), 44 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 956c17c4306..234882be45a 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -88,75 +88,72 @@ branches from there if `<branch>` is ambiguous but exists on the
 linkgit:git-config[1].
 +
 If `<commit-ish>` is omitted and neither `-b` nor `-B` nor `--detach` used,
-then, as a convenience, the new working tree is associated with a branch
-(call it `<branch>`) named after `$(basename <path>)`.  If `<branch>`
-doesn't exist, a new branch based on `HEAD` is automatically created as
-if `-b <branch>` was given.  If `<branch>` does exist, it will be
-checked out in the new working tree, if it's not checked out anywhere
-else, otherwise the command will refuse to create the working tree (unless
-`--force` is used).
+then, as a convenience, the new worktree is associated with a branch (call
+it `<branch>`) named after `$(basename <path>)`.  If `<branch>` doesn't
+exist, a new branch based on `HEAD` is automatically created as if
+`-b <branch>` was given.  If `<branch>` does exist, it will be checked out
+in the new worktree, if it's not checked out anywhere else, otherwise the
+command will refuse to create the worktree (unless `--force` is used).
 
 list::
 
-List details of each working tree.  The main working tree is listed first,
-followed by each of the linked working trees.  The output details include
-whether the working tree is bare, the revision currently checked out, the
+List details of each worktree.  The main worktree is listed first,
+followed by each of the linked worktrees.  The output details include
+whether the worktree is bare, the revision currently checked out, the
 branch currently checked out (or "detached HEAD" if none), "locked" if
-the worktree is locked, "prunable" if the worktree can be pruned by `prune`
-command.
+the worktree is locked, "prunable" if the worktree can be pruned by the
+`prune` command.
 
 lock::
 
-If a working tree is on a portable device or network share which
-is not always mounted, lock it to prevent its administrative
-files from being pruned automatically. This also prevents it from
-being moved or deleted. Optionally, specify a reason for the lock
-with `--reason`.
+If a worktree is on a portable device or network share which is not always
+mounted, lock it to prevent its administrative files from being pruned
+automatically. This also prevents it from being moved or deleted.
+Optionally, specify a reason for the lock with `--reason`.
 
 move::
 
-Move a working tree to a new location. Note that the main working tree
-or linked working trees containing submodules cannot be moved with this
-command. (The `git worktree repair` command, however, can reestablish
-the connection with linked working trees if you move the main working
-tree manually.)
+Move a worktree to a new location. Note that the main worktree or linked
+worktrees containing submodules cannot be moved with this command. (The
+`git worktree repair` command, however, can reestablish the connection
+with linked worktrees if you move the main worktree manually.)
 
 prune::
 
-Prune working tree information in `$GIT_DIR/worktrees`.
+Prune worktree information in `$GIT_DIR/worktrees`.
 
 remove::
 
-Remove a working tree. Only clean working trees (no untracked files
-and no modification in tracked files) can be removed. Unclean working
-trees or ones with submodules can be removed with `--force`. The main
-working tree cannot be removed.
+Remove a worktree. Only clean worktrees (no untracked files and no
+modification in tracked files) can be removed. Unclean worktrees or ones
+with submodules can be removed with `--force`. The main worktree cannot be
+removed.
 
 repair [<path>...]::
 
-Repair working tree administrative files, if possible, if they have
-become corrupted or outdated due to external factors.
+Repair worktree administrative files, if possible, if they have become
+corrupted or outdated due to external factors.
 +
-For instance, if the main working tree (or bare repository) is moved,
-linked working trees will be unable to locate it. Running `repair` in
-the main working tree will reestablish the connection from linked
-working trees back to the main working tree.
+For instance, if the main worktree (or bare repository) is moved, linked
+worktrees will be unable to locate it. Running `repair` in the main
+worktree will reestablish the connection from linked worktrees back to the
+main worktree.
 +
-Similarly, if a linked working tree is moved without using `git worktree
-move`, the main working tree (or bare repository) will be unable to
-locate it. Running `repair` within the recently-moved working tree will
-reestablish the connection. If multiple linked working trees are moved,
-running `repair` from any working tree with each tree's new `<path>` as
-an argument, will reestablish the connection to all the specified paths.
+Similarly, if the working tree for a linked worktree is moved without
+using `git worktree move`, the main worktree (or bare repository) will be
+unable to locate it. Running `repair` within the recently-moved worktree
+will reestablish the connection. If multiple linked worktrees are moved,
+running `repair` from any worktree with each tree's new `<path>` as an
+argument, will reestablish the connection to all the specified paths.
 +
-If both the main working tree and linked working trees have been moved
-manually, then running `repair` in the main working tree and specifying the
-new `<path>` of each linked working tree will reestablish all connections
-in both directions.
+If both the main worktree and linked worktrees have been moved manually,
+then running `repair` in the main worktree and specifying the new `<path>`
+of each linked worktree will reestablish all connections in both
+directions.
 
 unlock::
 
-Unlock a working tree, allowing it to be pruned, moved or deleted.
+Unlock a worktree, allowing it to be pruned, moved or deleted.
 
 OPTIONS
 -------
-- 
gitgitgadget


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

* [PATCH v3 07/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (5 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 06/11] " Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 08/11] " Derrick Stolee via GitGitGadget
                       ` (3 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the third of multiple changes to git-worktree.txt, restricted to
the OPTIONS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 42 +++++++++++++++++-----------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 234882be45a..329d3a9e4ea 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -160,25 +160,25 @@ OPTIONS
 
 -f::
 --force::
-	By default, `add` refuses to create a new working tree when
+	By default, `add` refuses to create a new worktree when
 	`<commit-ish>` is a branch name and is already checked out by
-	another working tree, or if `<path>` is already assigned to some
-	working tree but is missing (for instance, if `<path>` was deleted
+	another worktree, or if `<path>` is already assigned to some
+	worktree but is missing (for instance, if `<path>` was deleted
 	manually). This option overrides these safeguards. To add a missing but
-	locked working tree path, specify `--force` twice.
+	locked worktree path, specify `--force` twice.
 +
-`move` refuses to move a locked working tree unless `--force` is specified
-twice. If the destination is already assigned to some other working tree but is
+`move` refuses to move a locked worktree unless `--force` is specified
+twice. If the destination is already assigned to some other worktree but is
 missing (for instance, if `<new-path>` was deleted manually), then `--force`
 allows the move to proceed; use `--force` twice if the destination is locked.
 +
-`remove` refuses to remove an unclean working tree unless `--force` is used.
-To remove a locked working tree, specify `--force` twice.
+`remove` refuses to remove an unclean worktree unless `--force` is used.
+To remove a locked worktree, specify `--force` twice.
 
 -b <new-branch>::
 -B <new-branch>::
 	With `add`, create a new branch named `<new-branch>` starting at
-	`<commit-ish>`, and check out `<new-branch>` into the new working tree.
+	`<commit-ish>`, and check out `<new-branch>` into the new worktree.
 	If `<commit-ish>` is omitted, it defaults to `HEAD`.
 	By default, `-b` refuses to create a new branch if it already
 	exists. `-B` overrides this safeguard, resetting `<new-branch>` to
@@ -186,7 +186,7 @@ To remove a locked working tree, specify `--force` twice.
 
 -d::
 --detach::
-	With `add`, detach `HEAD` in the new working tree. See "DETACHED HEAD"
+	With `add`, detach `HEAD` in the new worktree. See "DETACHED HEAD"
 	in linkgit:git-checkout[1].
 
 --[no-]checkout::
@@ -212,7 +212,7 @@ This can also be set up as the default behaviour by using the
 	`--track` in linkgit:git-branch[1] for details.
 
 --lock::
-	Keep the working tree locked after creation. This is the
+	Keep the worktree locked after creation. This is the
 	equivalent of `git worktree lock` after `git worktree add`,
 	but without a race condition.
 
@@ -237,22 +237,22 @@ This can also be set up as the default behaviour by using the
 With `list`, output additional information about worktrees (see below).
 
 --expire <time>::
-	With `prune`, only expire unused working trees older than `<time>`.
+	With `prune`, only expire unused worktrees older than `<time>`.
 +
-With `list`, annotate missing working trees as prunable if they are
-older than `<time>`.
+With `list`, annotate missing worktrees as prunable if they are older than
+`<time>`.
 
 --reason <string>::
-	With `lock` or with `add --lock`, an explanation why the working tree is locked.
+	With `lock` or with `add --lock`, an explanation why the worktree
+	is locked.
 
 <worktree>::
-	Working trees can be identified by path, either relative or
-	absolute.
+	Worktrees can be identified by path, either relative or absolute.
 +
-If the last path components in the working tree's path is unique among
-working trees, it can be used to identify a working tree. For example if
-you only have two working trees, at `/abc/def/ghi` and `/abc/def/ggg`,
-then `ghi` or `def/ghi` is enough to point to the former working tree.
+If the last path components in the worktree's path is unique among
+worktrees, it can be used to identify a worktree. For example if you only
+have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
+`def/ghi` is enough to point to the former worktree.
 
 REFS
 ----
-- 
gitgitgadget


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

* [PATCH v3 08/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (6 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 07/11] " Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 09/11] " Derrick Stolee via GitGitGadget
                       ` (2 subsequent siblings)
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the fourth of multiple changes to git-worktree.txt, restricted
to the REFS section.

This section previously described "per working tree" refs but they are
now replaced with "per-worktree" refs, which matches the definition in
glossary-content.txt.

The first paragraph of this section was also a bit confusing, so it is
cleaned up to make it easier to understand.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 329d3a9e4ea..563c93a1bc4 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -256,24 +256,23 @@ have two worktrees, at `/abc/def/ghi` and `/abc/def/ggg`, then `ghi` or
 
 REFS
 ----
-In multiple working trees, some refs may be shared between all working
-trees and some refs are local. One example is `HEAD` which is different for each
-working tree. This section is about the sharing rules and how to access
-refs of one working tree from another.
-
-In general, all pseudo refs are per working tree and all refs starting
-with `refs/` are shared. Pseudo refs are ones like `HEAD` which are
-directly under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are
-exceptions, however: refs inside `refs/bisect` and `refs/worktree` are not
-shared.
-
-Refs that are per working tree can still be accessed from another
-working tree via two special paths, `main-worktree` and `worktrees`. The
-former gives access to per-working tree refs of the main working tree,
-while the latter to all linked working trees.
+When using multiple worktrees, some refs are shared between all worktrees,
+but others are specific to an individual worktree. One example is `HEAD`,
+which is different for each worktree. This section is about the sharing
+rules and how to access refs of one worktree from another.
+
+In general, all pseudo refs are per-worktree and all refs starting with
+`refs/` are shared. Pseudo refs are ones like `HEAD` which are directly
+under `$GIT_DIR` instead of inside `$GIT_DIR/refs`. There are exceptions,
+however: refs inside `refs/bisect` and `refs/worktree` are not shared.
+
+Refs that are per-worktree can still be accessed from another worktree via
+two special paths, `main-worktree` and `worktrees`. The former gives
+access to per-worktree refs of the main worktree, while the latter to all
+linked worktrees.
 
 For example, `main-worktree/HEAD` or `main-worktree/refs/bisect/good`
-resolve to the same value as the main working tree's `HEAD` and
+resolve to the same value as the main worktree's `HEAD` and
 `refs/bisect/good` respectively. Similarly, `worktrees/foo/HEAD` or
 `worktrees/bar/refs/bisect/bad` are the same as
 `$GIT_COMMON_DIR/worktrees/foo/HEAD` and
-- 
gitgitgadget


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

* [PATCH v3 09/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (7 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 08/11] " Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 10/11] " Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 11/11] " Derrick Stolee via GitGitGadget
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the fifth of multiple changes to git-worktree.txt, restricted to
the CONFIGURATION FILE section.

While here, clear up some language to improve readability.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 563c93a1bc4..a1ee5c43f1d 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -284,13 +284,13 @@ which will handle refs correctly.
 
 CONFIGURATION FILE
 ------------------
-By default, the repository `config` file is shared across all working
-trees. If the config variables `core.bare` or `core.worktree` are
-present in the common config file and `extensions.worktreeConfig` is
-disabled, then they will be applied to the main working tree only.
+By default, the repository `config` file is shared across all worktrees.
+If the config variables `core.bare` or `core.worktree` are present in the
+common config file and `extensions.worktreeConfig` is disabled, then they
+will be applied to the main worktree only.
 
-In order to have configuration specific to working trees, you can turn
-on the `worktreeConfig` extension, e.g.:
+In order to have worktree-specific configuration, you can turn on the
+`worktreeConfig` extension, e.g.:
 
 ------------
 $ git config extensions.worktreeConfig true
@@ -303,16 +303,16 @@ versions will refuse to access repositories with this extension.
 
 Note that in this file, the exception for `core.bare` and `core.worktree`
 is gone. If they exist in `$GIT_DIR/config`, you must move
-them to the `config.worktree` of the main working tree. You may also
-take this opportunity to review and move other configuration that you
-do not want to share to all working trees:
+them to the `config.worktree` of the main worktree. You may also take this
+opportunity to review and move other configuration that you do not want to
+share to all worktrees:
 
  - `core.worktree` should never be shared.
 
  - `core.bare` should not be shared if the value is `core.bare=true`.
 
- - `core.sparseCheckout` is recommended per working tree, unless you
-   are sure you always use sparse checkout for all working trees.
+ - `core.sparseCheckout` should not be shared, unless you are sure you
+   always use sparse checkout for all worktrees.
 
 See the documentation of `extensions.worktreeConfig` in
 linkgit:git-config[1] for more details.
-- 
gitgitgadget


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

* [PATCH v3 10/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (8 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 09/11] " Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  2022-02-23 14:29     ` [PATCH v3 11/11] " Derrick Stolee via GitGitGadget
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the sixth of multiple changes to git-worktree.txt, restricted to
the DETAILS section.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index a1ee5c43f1d..1b4d1d69a16 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -319,29 +319,29 @@ linkgit:git-config[1] for more details.
 
 DETAILS
 -------
-Each linked working tree has a private sub-directory in the repository's
+Each linked worktree has a private sub-directory in the repository's
 `$GIT_DIR/worktrees` directory.  The private sub-directory's name is usually
-the base name of the linked working tree's path, possibly appended with a
+the base name of the linked worktree's path, possibly appended with a
 number to make it unique.  For example, when `$GIT_DIR=/path/main/.git` the
 command `git worktree add /path/other/test-next next` creates the linked
-working tree in `/path/other/test-next` and also creates a
+worktree in `/path/other/test-next` and also creates a
 `$GIT_DIR/worktrees/test-next` directory (or `$GIT_DIR/worktrees/test-next1`
 if `test-next` is already taken).
 
-Within a linked working tree, `$GIT_DIR` is set to point to this private
+Within a linked worktree, `$GIT_DIR` is set to point to this private
 directory (e.g. `/path/main/.git/worktrees/test-next` in the example) and
-`$GIT_COMMON_DIR` is set to point back to the main working tree's `$GIT_DIR`
+`$GIT_COMMON_DIR` is set to point back to the main worktree's `$GIT_DIR`
 (e.g. `/path/main/.git`). These settings are made in a `.git` file located at
-the top directory of the linked working tree.
+the top directory of the linked worktree.
 
 Path resolution via `git rev-parse --git-path` uses either
 `$GIT_DIR` or `$GIT_COMMON_DIR` depending on the path. For example, in the
-linked working tree `git rev-parse --git-path HEAD` returns
+linked worktree `git rev-parse --git-path HEAD` returns
 `/path/main/.git/worktrees/test-next/HEAD` (not
 `/path/other/test-next/.git/HEAD` or `/path/main/.git/HEAD`) while `git
 rev-parse --git-path refs/heads/master` uses
 `$GIT_COMMON_DIR` and returns `/path/main/.git/refs/heads/master`,
-since refs are shared across all working trees, except `refs/bisect` and
+since refs are shared across all worktrees, except `refs/bisect` and
 `refs/worktree`.
 
 See linkgit:gitrepository-layout[5] for more information. The rule of
@@ -349,8 +349,8 @@ thumb is do not make any assumption about whether a path belongs to
 `$GIT_DIR` or `$GIT_COMMON_DIR` when you need to directly access something
 inside `$GIT_DIR`. Use `git rev-parse --git-path` to get the final path.
 
-If you manually move a linked working tree, you need to update the `gitdir` file
-in the entry's directory. For example, if a linked working tree is moved
+If you manually move a linked worktree, you need to update the `gitdir` file
+in the entry's directory. For example, if a linked worktree is moved
 to `/newpath/test-next` and its `.git` file points to
 `/path/main/.git/worktrees/test-next`, then update
 `/path/main/.git/worktrees/test-next/gitdir` to reference `/newpath/test-next`
@@ -359,10 +359,10 @@ automatically.
 
 To prevent a `$GIT_DIR/worktrees` entry from being pruned (which
 can be useful in some situations, such as when the
-entry's working tree is stored on a portable device), use the
+entry's worktree is stored on a portable device), use the
 `git worktree lock` command, which adds a file named
 `locked` to the entry's directory. The file contains the reason in
-plain text. For example, if a linked working tree's `.git` file points
+plain text. For example, if a linked worktree's `.git` file points
 to `/path/main/.git/worktrees/test-next` then a file named
 `/path/main/.git/worktrees/test-next/locked` will prevent the
 `test-next` entry from being pruned.  See
-- 
gitgitgadget


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

* [PATCH v3 11/11] worktree: use 'worktree' over 'working tree'
  2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
                       ` (9 preceding siblings ...)
  2022-02-23 14:29     ` [PATCH v3 10/11] " Derrick Stolee via GitGitGadget
@ 2022-02-23 14:29     ` Derrick Stolee via GitGitGadget
  10 siblings, 0 replies; 63+ messages in thread
From: Derrick Stolee via GitGitGadget @ 2022-02-23 14:29 UTC (permalink / raw)
  To: git
  Cc: sunshine, gitster, newren, jn.avila, Taylor Blau, Derrick Stolee,
	Derrick Stolee

From: Derrick Stolee <derrickstolee@github.com>

It is helpful to distinguish between a 'working tree' and a 'worktree'.
A worktree contains a working tree plus additional metadata. This
metadata includes per-worktree refs and worktree-specific config.

This is the last of multiple changes to git-worktree.txt, starting at
the LIST OUTPUT FORMAT section.

The EXAMPLES section has an instance of "working tree" that must stay as
it is, because it is not talking about a worktree, but an example of why
a user might want to create a worktree.

Helped-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Derrick Stolee <derrickstolee@github.com>
---
 Documentation/git-worktree.txt | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 1b4d1d69a16..453e1550226 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -383,11 +383,11 @@ $ git worktree list
 /path/to/other-linked-worktree  1234abc  (detached HEAD)
 ------------
 
-The command also shows annotations for each working tree, according to its state.
+The command also shows annotations for each worktree, according to its state.
 These annotations are:
 
- * `locked`, if the working tree is locked.
- * `prunable`, if the working tree can be pruned via `git worktree prune`.
+ * `locked`, if the worktree is locked.
+ * `prunable`, if the worktree can be pruned via `git worktree prune`.
 
 ------------
 $ git worktree list
@@ -405,14 +405,14 @@ $ git worktree list --verbose
 /path/to/linked-worktree              abcd1234 [master]
 /path/to/locked-worktree-no-reason    abcd5678 (detached HEAD) locked
 /path/to/locked-worktree-with-reason  1234abcd (brancha)
-	locked: working tree path is mounted on a portable device
+	locked: worktree path is mounted on a portable device
 /path/to/prunable-worktree            5678abc1 (detached HEAD)
 	prunable: gitdir file points to non-existent location
 ------------
 
 Note that the annotation is moved to the next line if the additional
 information is available, otherwise it stays on the same line as the
-working tree itself.
+worktree itself.
 
 Porcelain Format
 ~~~~~~~~~~~~~~~~
@@ -421,7 +421,7 @@ label and value separated by a single space.  Boolean attributes (like `bare`
 and `detached`) are listed as a label only, and are present only
 if the value is true.  Some attributes (like `locked`) can be listed as a label
 only or with a value depending upon whether a reason is available.  The first
-attribute of a working tree is always `worktree`, an empty line indicates the
+attribute of a worktree is always `worktree`, an empty line indicates the
 end of the record.  For example:
 
 ------------
@@ -473,7 +473,7 @@ demands that you fix something immediately. You might typically use
 linkgit:git-stash[1] to store your changes away temporarily, however, your
 working tree is in such a state of disarray (with new, moved, and removed
 files, and other bits and pieces strewn around) that you don't want to risk
-disturbing any of it. Instead, you create a temporary linked working tree to
+disturbing any of it. Instead, you create a temporary linked worktree to
 make the emergency fix, remove it when done, and then resume your earlier
 refactoring session.
 
-- 
gitgitgadget

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

* Re: [PATCH v2 00/11] Updates to worktree code and docs
  2022-02-22 19:50   ` [PATCH v2 00/11] Updates to worktree code and docs Taylor Blau
@ 2022-02-23 20:24     ` Junio C Hamano
  0 siblings, 0 replies; 63+ messages in thread
From: Junio C Hamano @ 2022-02-23 20:24 UTC (permalink / raw)
  To: Taylor Blau
  Cc: Derrick Stolee via GitGitGadget, git, sunshine, newren, jn.avila,
	Derrick Stolee

Taylor Blau <me@ttaylorr.com> writes:

> On Tue, Feb 22, 2022 at 12:17:49AM +0000, Derrick Stolee via GitGitGadget wrote:
>> Updates in v2
>> =============
>>
>> Based on Junio and Taylor's review, I updated some language in the docs:
>>
>>  * Some uses of "worktree" should have stayed as "working tree"
>>  * Some adjacent wording was improved.
>
> Thanks; these updates (in addition to the handful of fixups that Junio
> provided on top) look good to me. I'll leave it to the two of you to
> figure out if you want to send another reroll, or if Junio already
> caught the minor changes when applying.

I thought I'd locally fix the three but I see Derrick has a reroll
already on the list, so I'll try that one first ;-)

Thanks, all.

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

* Re: [PATCH 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-20 17:54 ` [PATCH 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
  2022-02-20 20:42   ` Junio C Hamano
@ 2022-02-24 14:33   ` Philip Oakley
  2022-02-24 15:53     ` Derrick Stolee
  1 sibling, 1 reply; 63+ messages in thread
From: Philip Oakley @ 2022-02-24 14:33 UTC (permalink / raw)
  To: Derrick Stolee via GitGitGadget, git
  Cc: mailto:sunshine@sunshineco.com, mailto:gitster@pobox.com,
	Elijah Newren [ ], Jean-Noël AVILA [ ], Derrick Stolee

On 20/02/2022 17:54, Derrick Stolee via GitGitGadget wrote:
> From: Derrick Stolee <derrickstolee@github.com>
>
> It is helpful to distinguish between a 'working tree' and a 'worktree'.
> A worktree contains a working tree plus additional metadata. This
> metadata includes per-worktree refs and worktree-specific config.
Doesn't this need a clear call-out in the text to highlight the
distinction, so that it is obvious at first glance to the casual reader?

I'd ended up with something like:
- worktree
    A directory whose files and sub-directories are (selectively) under
Git revision management.
- working tree
    The working tree comprises Git revision management meta-data for the
worktree,
     and the worktree itself.
    The meta-data may be independently located away from the worktree's
data.

The key feature is to have a layout structure that shows the distinction.

Or are we trying to remove all references to "working tree"? Or have I
misunderstood?

Philip

>
> This is the first of multiple changes to git-worktree.txt, restricted to
> the DESCRIPTION section.
>
> Signed-off-by: Derrick Stolee <derrickstolee@github.com>
> ---
>  Documentation/git-worktree.txt | 53 ++++++++++++++++++----------------
>  1 file changed, 28 insertions(+), 25 deletions(-)
>
> diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
> index b8d53c48303..d9705062e9d 100644
> --- a/Documentation/git-worktree.txt
> +++ b/Documentation/git-worktree.txt
> @@ -25,45 +25,48 @@ Manage multiple working trees attached to the same repository.
>  
>  A git repository can support multiple working trees, allowing you to check
Are we removing the above "working trees" phrases as well?
>  out more than one branch at a time.  With `git worktree add` a new working
> -tree is associated with the repository.  This new working tree is called a
> -"linked working tree" as opposed to the "main working tree" prepared by
> -linkgit:git-init[1] or linkgit:git-clone[1].
> -A repository has one main working tree (if it's not a
> -bare repository) and zero or more linked working trees. When you are done
> -with a linked working tree, remove it with `git worktree remove`.
> +tree is associated with the repository, along with additional metadata
> +that differentiates that working tree from others in the same repository.
> +The working tree, along with this metada, is called a "worktree".
> +
> +This new worktree is called a "linked worktree" as opposed to the "main
> +worktree" prepared by linkgit:git-init[1] or linkgit:git-clone[1].
> +A repository has one main worktree (if it's not a bare repository) and
> +zero or more linked worktrees. When you are done with a linked worktree,
> +remove it with `git worktree remove`.
>  
>  In its simplest form, `git worktree add <path>` automatically creates a
>  new branch whose name is the final component of `<path>`, which is
>  convenient if you plan to work on a new topic. For instance, `git
>  worktree add ../hotfix` creates new branch `hotfix` and checks it out at
> -path `../hotfix`. To instead work on an existing branch in a new working
> -tree, use `git worktree add <path> <branch>`. On the other hand, if you
> -just plan to make some experimental changes or do testing without
> -disturbing existing development, it is often convenient to create a
> -'throwaway' working tree not associated with any branch. For instance,
> -`git worktree add -d <path>` creates a new working tree with a detached
> -`HEAD` at the same commit as the current branch.
> -
> -If a working tree is deleted without using `git worktree remove`, then
> +path `../hotfix`. To instead work on an existing branch in a new worktree,
> +use `git worktree add <path> <branch>`. On the other hand, if you just
> +plan to make some experimental changes or do testing without disturbing
> +existing development, it is often convenient to create a 'throwaway'
> +worktree not associated with any branch. For instance,
> +`git worktree add -d <path>` creates a new worktree with a detached `HEAD`
> +at the same commit as the current branch.
> +
> +If a worktree is deleted without using `git worktree remove`, then
>  its associated administrative files, which reside in the repository
>  (see "DETAILS" below), will eventually be removed automatically (see
>  `gc.worktreePruneExpire` in linkgit:git-config[1]), or you can run
> -`git worktree prune` in the main or any linked working tree to
> -clean up any stale administrative files.
> +`git worktree prune` in the main or any linked worktree to clean up any
> +stale administrative files.
>  
> -If a linked working tree is stored on a portable device or network share
> -which is not always mounted, you can prevent its administrative files from
> -being pruned by issuing the `git worktree lock` command, optionally
> -specifying `--reason` to explain why the working tree is locked.
> +If a linked worktree is stored on a portable device or network share which
> +is not always mounted, you can prevent its administrative files from being
> +pruned by issuing the `git worktree lock` command, optionally specifying
> +`--reason` to explain why the worktree is locked.
>  
>  COMMANDS
>  --------
>  add <path> [<commit-ish>]::
>  
> -Create `<path>` and checkout `<commit-ish>` into it. The new working directory
> -is linked to the current repository, sharing everything except working
> -directory specific files such as `HEAD`, `index`, etc. As a convenience,
> -`<commit-ish>` may be a bare "`-`", which is synonymous with `@{-1}`.
> +Create `<path>` and checkout `<commit-ish>` into it. The new worktree
> +is linked to the current repository, sharing everything except per-worktree
> +files such as `HEAD`, `index`, etc. As a convenience, `<commit-ish>` may
> +be a bare "`-`", which is synonymous with `@{-1}`.
>  +
>  If `<commit-ish>` is a branch name (call it `<branch>`) and is not found,
>  and neither `-b` nor `-B` nor `--detach` are used, but there does


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

* Re: [PATCH 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-24 14:33   ` Philip Oakley
@ 2022-02-24 15:53     ` Derrick Stolee
  2022-03-03 15:41       ` Philip Oakley
  0 siblings, 1 reply; 63+ messages in thread
From: Derrick Stolee @ 2022-02-24 15:53 UTC (permalink / raw)
  To: Philip Oakley, Derrick Stolee via GitGitGadget, git
  Cc: Elijah Newren [ ], Jean-Noël AVILA [ ]

On 2/24/2022 9:33 AM, Philip Oakley wrote:
> On 20/02/2022 17:54, Derrick Stolee via GitGitGadget wrote:
>> From: Derrick Stolee <derrickstolee@github.com>
>>
>> It is helpful to distinguish between a 'working tree' and a 'worktree'.
>> A worktree contains a working tree plus additional metadata. This
>> metadata includes per-worktree refs and worktree-specific config.
> Doesn't this need a clear call-out in the text to highlight the
> distinction, so that it is obvious at first glance to the casual reader?
> 
> I'd ended up with something like:
> - worktree
>     A directory whose files and sub-directories are (selectively) under
> Git revision management.
> - working tree
>     The working tree comprises Git revision management meta-data for the
> worktree,
>      and the worktree itself.
>     The meta-data may be independently located away from the worktree's
> data.
> 
> The key feature is to have a layout structure that shows the distinction.

See below where I mention that the first paragraph points out this
distinction. Your use of bullets makes it even more clear, and I think
that would be more valuable if this wasn't the very first thing in the
document.

> Or are we trying to remove all references to "working tree"? Or have I
> misunderstood?
...
>>  A git repository can support multiple working trees, allowing you to check
> Are we removing the above "working trees" phrases as well?

This one is important to keep. The worktree feature is how Git manages
multiple working trees.

The reason for switching most of the other references is because the
discussion applies specifically to worktrees, not working trees.

>>  out more than one branch at a time.  With `git worktree add` a new working
>> -tree is associated with the repository.  This new working tree is called a
>> -"linked working tree" as opposed to the "main working tree" prepared by
>> -linkgit:git-init[1] or linkgit:git-clone[1].
>> -A repository has one main working tree (if it's not a
>> -bare repository) and zero or more linked working trees. When you are done
>> -with a linked working tree, remove it with `git worktree remove`.
>> +tree is associated with the repository, along with additional metadata
>> +that differentiates that working tree from others in the same repository.
>> +The working tree, along with this metada, is called a "worktree".

This first paragraph is all about the distinction between working tree
and worktree, so it hopefully handles the concerns you had above.

Thanks,
-Stolee

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

* Re: [PATCH 05/11] worktree: use 'worktree' over 'working tree'
  2022-02-24 15:53     ` Derrick Stolee
@ 2022-03-03 15:41       ` Philip Oakley
  0 siblings, 0 replies; 63+ messages in thread
From: Philip Oakley @ 2022-03-03 15:41 UTC (permalink / raw)
  To: Derrick Stolee, Derrick Stolee via GitGitGadget, git
  Cc: Elijah Newren [ ], Jean-Noël AVILA [ ]

Sorry for the delay in replying. I had some family matters to attend to.

On 24/02/2022 15:53, Derrick Stolee wrote:
> On 2/24/2022 9:33 AM, Philip Oakley wrote:
>> On 20/02/2022 17:54, Derrick Stolee via GitGitGadget wrote:
>>> From: Derrick Stolee <derrickstolee@github.com>
>>>
>>> It is helpful to distinguish between a 'working tree' and a 'worktree'.
>>> A worktree contains a working tree plus additional metadata. This
>>> metadata includes per-worktree refs and worktree-specific config.
>> Doesn't this need a clear call-out in the text to highlight the
>> distinction, so that it is obvious at first glance to the casual reader?
>>
>> I'd ended up with something like:
>> - worktree
>>     A directory whose files and sub-directories are (selectively) under
>> Git revision management.
>> - working tree
>>     The working tree comprises Git revision management meta-data for the
>> worktree,
>>      and the worktree itself.
>>     The meta-data may be independently located away from the worktree's
>> data.
>>
>> The key feature is to have a layout structure that shows the distinction.
> See below where I mention that the first paragraph points out this
> distinction. Your use of bullets makes it even more clear, and I think
> that would be more valuable if this wasn't the very first thing in the
> document.

I don't really buy the "first paragraph points out this distinction"
because it's still part of a wall of text, so not easy to locate.

It's not helped by the top line NAME which uses both `worktree` and
`working tree` as if they are equivalent. Though that could be easily
solved by making it:

    git-worktree - Manage multiple working trees and their meta-data

which would highlight the two distinct parts. (could also add the
`git/user` distinction as below)


You'll probably also have noticed how even in my original suggestion,
I'd still misread the partition and got worktree/working-tree swapped
over, so it is easily done.

If we are trying to have clarity on the worktree/working-tree 
distinction, I still think it needs to be made very obvious, with
perhaps even the naming of the _git_ meta data part, or at least calling
it out as being the independent of the _users_ working tree .

Philip
>
>> Or are we trying to remove all references to "working tree"? Or have I
>> misunderstood?
> ...
>>>  A git repository can support multiple working trees, allowing you to check
>> Are we removing the above "working trees" phrases as well?
> This one is important to keep. The worktree feature is how Git manages
> multiple working trees.
>
> The reason for switching most of the other references is because the
> discussion applies specifically to worktrees, not working trees.
>
>>>  out more than one branch at a time.  With `git worktree add` a new working
>>> -tree is associated with the repository.  This new working tree is called a
>>> -"linked working tree" as opposed to the "main working tree" prepared by
>>> -linkgit:git-init[1] or linkgit:git-clone[1].
>>> -A repository has one main working tree (if it's not a
>>> -bare repository) and zero or more linked working trees. When you are done
>>> -with a linked working tree, remove it with `git worktree remove`.
>>> +tree is associated with the repository, along with additional metadata
>>> +that differentiates that working tree from others in the same repository.
>>> +The working tree, along with this metada, is called a "worktree".
> This first paragraph is all about the distinction between working tree
> and worktree, so it hopefully handles the concerns you had above.
>
> Thanks,
> -Stolee


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

end of thread, other threads:[~2022-03-03 15:41 UTC | newest]

Thread overview: 63+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-20 17:54 [PATCH 00/11] Updates to worktree code and docs Derrick Stolee via GitGitGadget
2022-02-20 17:54 ` [PATCH 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
2022-02-20 20:22   ` Junio C Hamano
2022-02-20 20:29     ` Derrick Stolee
2022-02-20 17:54 ` [PATCH 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
2022-02-20 20:26   ` Junio C Hamano
2022-02-20 17:54 ` [PATCH 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
2022-02-20 17:54 ` [PATCH 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
2022-02-20 21:59   ` Taylor Blau
2022-02-20 17:54 ` [PATCH 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
2022-02-20 20:42   ` Junio C Hamano
2022-02-20 20:48     ` Derrick Stolee
2022-02-24 14:33   ` Philip Oakley
2022-02-24 15:53     ` Derrick Stolee
2022-03-03 15:41       ` Philip Oakley
2022-02-20 17:54 ` [PATCH 06/11] " Derrick Stolee via GitGitGadget
2022-02-20 17:54 ` [PATCH 07/11] " Derrick Stolee via GitGitGadget
2022-02-20 17:54 ` [PATCH 08/11] " Derrick Stolee via GitGitGadget
2022-02-20 22:29   ` Taylor Blau
2022-02-20 17:54 ` [PATCH 09/11] " Derrick Stolee via GitGitGadget
2022-02-20 22:31   ` Taylor Blau
2022-02-21  2:26     ` Derrick Stolee
2022-02-20 17:54 ` [PATCH 10/11] " Derrick Stolee via GitGitGadget
2022-02-20 17:54 ` [PATCH 11/11] " Derrick Stolee via GitGitGadget
2022-02-20 22:37   ` Taylor Blau
2022-02-21  2:11     ` Derrick Stolee
2022-02-20 22:38 ` [PATCH 00/11] Updates to worktree code and docs Taylor Blau
2022-02-20 22:41   ` Taylor Blau
2022-02-22  0:17 ` [PATCH v2 " Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
2022-02-22  7:22     ` Junio C Hamano
2022-02-23  6:47     ` Elijah Newren
2022-02-22  0:17   ` [PATCH v2 06/11] " Derrick Stolee via GitGitGadget
2022-02-22  7:22     ` Junio C Hamano
2022-02-22 14:06       ` Derrick Stolee
2022-02-22  0:17   ` [PATCH v2 07/11] " Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 08/11] " Derrick Stolee via GitGitGadget
2022-02-22 19:49     ` Taylor Blau
2022-02-22 21:24       ` Derrick Stolee
2022-02-23  0:05         ` Taylor Blau
2022-02-22  0:17   ` [PATCH v2 09/11] " Derrick Stolee via GitGitGadget
2022-02-22  0:17   ` [PATCH v2 10/11] " Derrick Stolee via GitGitGadget
2022-02-22  0:18   ` [PATCH v2 11/11] " Derrick Stolee via GitGitGadget
2022-02-22 19:50   ` [PATCH v2 00/11] Updates to worktree code and docs Taylor Blau
2022-02-23 20:24     ` Junio C Hamano
2022-02-23  6:51   ` Elijah Newren
2022-02-23 14:26     ` Derrick Stolee
2022-02-23 14:29   ` [PATCH v3 " Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 01/11] worktree: combine two translatable messages Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 02/11] worktree: extract copy_filtered_worktree_config() Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 03/11] worktree: extract copy_sparse_checkout() Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 04/11] worktree: extract checkout_worktree() Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 05/11] worktree: use 'worktree' over 'working tree' Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 06/11] " Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 07/11] " Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 08/11] " Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 09/11] " Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 10/11] " Derrick Stolee via GitGitGadget
2022-02-23 14:29     ` [PATCH v3 11/11] " Derrick Stolee via GitGitGadget

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).