* [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
* 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 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
* [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
* 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
* [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
* 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 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
* [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 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 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 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