Skip to contentSkip to conversation

Sparse checkout: fix bug with worktree of bare repo

PATCH Superseded Derrick Stolee via GitGitGadget 8 participants 138 messages Dec 20, 2021 – Feb 16, 2022 Documentation Page 2 of 2

lore
Share & tools
lore
#119 lore raw

Re: [PATCH v6 2/6] worktree: create init_worktree_config()

In reply to Junio C Hamano
Quoted 14 lines · Junio C Hamano

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 839

Quoted 9 lines · Derrick Stolee via GitGitGadget
worktree.c +9 -0
+static int move_config_setting(const char *key, const char *value,
+			       const char *from_file, const char *to_file)
+{
+	if (git_config_set_in_file_gently(to_file, key, value))
+		return error(_("unable to set %s in '%s'"), key, to_file);
+	if (git_config_set_in_file_gently(from_file, key, NULL))
+		return error(_("unable to unset %s in '%s'"), key, from_file);
+	return 0;
+}

Interesting.

Quoted 5 lines

The verb "move" in its name made me expect a "get (and remove) whatever value(s) defined out of the old file, and set them identically in the new file" sequence, but that is not what is done here. "set to this new single value in the new file and unset from the old one".

I think this "copy into the worktree-specific config, then remove from the common file" is an important sequence of events in case a concurrent process comes in and reads the two config files in the intermediate state and does not see the config value anywhere.

But perhaps that's not actually what you are concerned about, because you're saying that the 'value' being provided does not actually guarantee that we are moving the setting.

Quoted 5 lines

I can see the need to say "move it only when its value is X", so having the caller to extract the value before deciding to call the function (hence not "moving from old") does make sense, but then the function is misnamed---it is not "moving", it is doing something else.

I think the end state is correct for all uses here, since we only run this after checking to see if the config value exists in the 'from_file', so 'value' is correct (and this is a static method, not a generally-useful method for config.h).

Perhaps a "write_in_new_and_remove_from_old()" would be a better, if verbose, name. I struggle to find a less cumbersome name, and "move" seems to match the intent pretty well in the context of its use.

Quoted 13 lines

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 870

Quoted 12 lines
worktree.c +12 -0
+	common_config_file = xstrfmt("%s/config", r->commondir);
+	main_worktree_file = xstrfmt("%s/config.worktree", r->commondir);
+
+	git_configset_init(&cs);
+	git_configset_add_file(&cs, common_config_file);
+
+	/*
+	 * If core.bare is true in the common config file, then we need to
+	 * move it to the main worktree's config file or it will break all
+	 * worktrees. If it is false, then leave it in place because it
+	 * _could_ be negating a global core.bare=true.
+	 */
Quoted 7 lines

Is the assumption that the secondary worktrees are never bare, but the primary one could be (iow, adding worktrees to a bare repository would leave the original bare repository as the primary "worktree" that does not have "working tree")? I am trying to see what downsides it tries to avoid by not moving the core.bare==false setting. Shouldn't core.bare be set to false when "worktree add" creates a new one anyway, if the secondaries are never bare?

Secondary worktrees cannot be bare. If Git interprets the worktree config to have core.bare=true in a secondary worktree, it errors out.

You seem to be suggesting that we should explicitly write core.bare=false into each of the worktree-specific config files. Is that right? This move is effectively the same, since 'false' is the default.

Quoted 7 lines
Quoted 6 lines
worktree.c +6 -0
+	if (!git_configset_get_bool(&cs, "core.bare", &bare) && bare) {
+		if ((res = move_config_setting("core.bare", "true",
+					       common_config_file,
+					       main_worktree_file)))
+			goto cleanup;
+	}
Quoted 9 lines

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 879

Quoted 3 lines
worktree.c +3 -0
+	/*
+	 * If core.worktree is set, then the main worktree is located
+	 * somewhere different than the parent of the common Git dir.

OK. We do not want to share the working tree for the primary worktree among secondary worktrees. For the primary, common and uncommon are the same, so it may not matter, but mention of "common Git dir" here may confuse readers? Unless overridden by the config, the parent of the git dir is the root of the working tree, no?

Here, the verbal gymnastics are somewhat necessary because secondary worktrees have a .git _file_, not a git directory, so using "common Git dir" is a way to explicitly reference the Git dir. And the strangeness here is exactly that core.worktree can change this working tree to be something other than the parent of the (common) Git dir.

Quoted 7 lines

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 882

Quoted 3 lines
worktree.c +3 -0
+	 * Relocate that value to avoid breaking all worktrees with this
+	 * upgrade to worktree config.
+	 */

And if it is not set, then working tree of each worktree is the parent of the per-worktree Git dir, so they will automatically become separate, which makes sense.

Thanks,
-Stolee

#124 lore raw

Re: [PATCH v6 3/6] config: add repo_config_set_worktree_gently()

In reply to Junio C Hamano
Quoted 1 line · Junio C Hamano

"Derrick Stolee via GitGitGadget" <[email protected]> writes:

...

Quoted 11 lines

config.c void git_config_set_multivar_in_file(const char *config_filename, · line 3201

Quoted 9 lines
config.c +3 -2
@@ -3181,14 +3196,28 @@ void git_config_set_multivar_in_file(const char *config_filename,
 int git_config_set_multivar_gently(const char *key, const char *value,
 				   const char *value_pattern, unsigned flags)
 {
-	return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern,
-						      flags);
+	return repo_config_set_multivar_gently(the_repository, key, value,
+					       value_pattern, flags);
+}

Is this an unrelated "morally no-op" change?

This one is to match the pattern of how "git_*" methods should depend on their "repo_*" counterparts (with "the_repository" inserted properly). So, it's part of the standard process for creating these "repo_*" variants.

Quoted 11 lines

config.c void git_config_set_multivar_in_file(const char *config_filename, · line 3222

Quoted 8 lines
config.c +2 -1
 void git_config_set_multivar(const char *key, const char *value,
 			     const char *value_pattern, unsigned flags)
 {
-	git_config_set_multivar_in_file(NULL, key, value, value_pattern,
+	git_config_set_multivar_in_file(git_path("config"),
+					key, value, value_pattern,
 					flags);
 }

Is this an unrelated "morally no-op" change?

Quoted 3 lines

It might have value to make caller more explicit by reducing the use of "I give NULL, you use 'config' for me", but that doesn't sound related to the addition of set_per_worktree_config_gently() helper.

Here, you're right. This one should have followed the same pattern of having the "git_*" equivalent call the "repo_*" method, but instead I incorrectly inlined some of the code.

The proper body should be

void git_config_set_multivar(const char *key, const char *value,
const char *value_pattern, unsigned flags)

{
	repo_config_set_multivar_gently(the_repository, key, value,
					value_pattern, flags);
}

to follow convention.

Thanks,
-Stolee

#108 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Junio C Hamano
Quoted 16 lines · Junio C Hamano
Quoted 14 lines · Derrick Stolee via GitGitGadget
Documentation/config/extensions.txt +6 -0
index 4e23d73cdca..bccaec7a963 100644
@@ -6,3 +6,34 @@ extensions.objectFormat::
 Note that this setting should only be set by linkgit:git-init[1] or
 linkgit:git-clone[1].  Trying to change it after initialization will not
 work and will produce hard-to-diagnose issues.
+
+extensions.worktreeConfig::
+	If enabled, then worktrees will load config settings from the
+	`$GIT_DIR/config.worktree` file in addition to the
+	`$GIT_COMMON_DIR/config` file. Note that `$GIT_COMMON_DIR` and
+	`$GIT_DIR` are the same for the main working tree, while other
Quoted 8 lines

Documentation/config/extensions.txt extensions.objectFormat:: · line 16

Quoted 2 lines
Documentation/config/extensions.txt +2 -0
+	working trees have `$GIT_DIR` equal to
+	`$GIT_COMMON_DIR/worktrees/<id>/`. The settings in the

The mixed use of "worktree" and "working tree" in this paragraph might confuse readers into thinking that the paragraph is being careful to make distinction between the two. All references to "working tree" in the above paragraph should actually be "worktree", I would think.

I generally agree. This was changed in the most-recent re-roll based on a request by Eric [1]. I'm happy to take whichever version the two of you settle on.

[1] https://lore.kernel.org/git/CAPig+cS-3CxxyPGcy_vkeN_WYTRo1b-ZhJNdPy8ARZSNKkF1Xg@mail.gmail.com/

Quoted 5 lines

Side note: "working tree" is in the glossary-content.txt, but "worktree", which is one "working tree" + repository metadata (i.e. ".git/") that may be partially shared with other "worktree"s of a single repository, is not defined.

Quoted 8 lines

This is a tangent, but I wonder why we chose to use a different filename (i.e. not "config" but "config.worktree") for this. If we were redoing multi-worktree support from scratch, we would not reuse the $GIT_DIR used by the primary worktree as $GIT_COMMON_DIR, so that all worktrees would share a single $GIT_COMMON_DIR and $GIT_COMMON_DIR/config that has stuff that is shared among all the worktrees, while per worktree stuff is in $GIT_DIR/config even for the primary worktree. But that is all water under the bridge now.

Right. I think that since the primary worktree uses $GIT_COMMON_DIR as its location for base information (like HEAD) it also means that its worktree-specific config file cannot be called "config".

Perhaps there could have been a way to split the worktrees so the primary worktree got its own directory within ".git/worktrees/", but my guess is that the design optimized for backwards compatibility:
Git clients that don't understand worktrees could still interact with the primary worktree.

Quoted 41 lines

Other than the terminology gotcha, looked sensible. Migrating automatically and/or noticing a suspicious setting may be needed to help end users, but that would not be within the scope of this step.

Attached is a "how about this?" glossary update suggestion. Most of the existing mention of "working tree" are fine as-is because they only care about what is in the "working tree", but some should be changed to "worktree" to stress the fact that they care not just the "working tree" part but also the repository metadata part that is associated with that single "working tree". The first hunk says worktree but it is clear that it is interested only in the "working tree" files.

 Documentation/glossary-content.txt | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Documentation/glossary-content.txt +2 -2
index c077971335..d816512c6a 100644
@@ -312,7 +312,7 @@ Pathspecs are used on the command line of "git ls-files", "git
 ls-tree", "git add", "git grep", "git diff", "git checkout",
 and many other commands to
 limit the scope of operations to some subset of the tree or
-worktree.  See the documentation of each command for whether
+working tree.  See the documentation of each command for whether
 paths are relative to the current directory or toplevel.  The
 pathspec syntax is as follows:
 +
@@ -446,7 +446,7 @@ exclude;;
 	interface than the <<def_plumbing,plumbing>>.
 
 [[def_per_worktree_ref]]per-worktree ref::
-	Refs that are per-<<def_working_tree,worktree>>, rather than
+	Refs that are per-<<def_worktree,worktree>>, rather than
 	global.  This is presently only <<def_HEAD,HEAD>> and any refs
 	that start with `refs/bisect/`, but might later include other
 	unusual refs.
@@ -669,3 +669,12 @@ The most notable example is `HEAD`.
 	The tree of actual checked out files.  The working tree normally
 	contains the contents of the <<def_HEAD,HEAD>> commit's tree,

Documentation/glossary-content.txt The most notable example is `HEAD`. · line 680

Quoted 10 lines
Documentation/glossary-content.txt +9 -0
 	plus any local changes that you have made but not yet committed.
+
+[[def_work_tree]]worktree::
+	A repository can have zero (i.e. bare repository) or one or
+	more worktrees attached to it. One "worktree" consists of a
+	"working tree" and repository metadata, most of which are
+	shared among other worktrees of a single repository, and
+	some of which are maintained separately per worktree
+	(e.g. the index, HEAD, per-worktree refs and per-worktree
+	configuration file)

I like this addition, except that I don't understand the "per-worktree refs" (other than HEAD). Are there other thins used by features such as merge and rebase that would appear as worktree-specific? Of course, some state for these operations is stored per-worktree, I just didn't know if any were actually "refs".

Other than that technicality, which could be completely correct, this is a good idea to include.

Thanks,
-Stolee

#97 lore raw

Re: [PATCH v5 5/5] worktree: copy sparse-checkout patterns and config on add

In reply to Derrick Stolee

Le 07/02/2022 à 15:10, Derrick Stolee a écrit :

Quoted 23 lines · Jean-Noël AVILA
Quoted 1 line · On Monday, 31 January 2022 16:00:59 CET Derrick Stolee via GitGitGadget wrote:

Hi Jean-Noël. Thanks for your attention to the translatable messages here:

Quoted 11 lines
Quoted 9 lines

error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),

       from_file, to_file);

die(_("failed to copy worktree config from '%s' to '%s'"),

     from_file, to_file);

error(_("failed to unset 'core.bare' in '%s'"), to_file);

error(_("failed to unset 'core.worktree' in '%s'"), to_file);

In the first patch of this series, you use _("unable to set '%s' in'%s'). Does it make sense to reuse this string here?

I would argue that "unable to set" is not appropriate for any of these messages. Perhaps the "failed to copy" messages might be able to use "unable to set", but the information that the config setting is coming from settings the user controlled is valuable.

Quoted 8 lines

The "failed to unset" means "we are trying to _remove_ this setting from the config file", so "unable to set" does not seem to work here.

I'm open to revisiting this if you disagree.

Thanks,
-Stolee

Hi Derrick,

Sorry for not being more precise. The first two errors were not the subject of this remark.

For the last two, this is quite surprising that the same function failing (git_config_set_in_file_gently) can lead to different error messages.

In any case, I would argue at least for shifting to :

    error(_("failed to unset '%s' in '%s'"), 'core.bare", to_file);
and
    error(_("failed to unset '%s' in '%s'"), "core.worktree", to_file);

in order to factorize the message and get the option name out of the way.

Thanks,

Jean-Noël

#98 lore raw

Re: [PATCH v5 5/5] worktree: copy sparse-checkout patterns and config on add

Quoted 39 lines · Jean-Noël Avila

Le 07/02/2022 à 15:10, Derrick Stolee a écrit :

Quoted 23 lines · Jean-Noël AVILA
Quoted 1 line · On Monday, 31 January 2022 16:00:59 CET Derrick Stolee via GitGitGadget wrote:

Hi Jean-Noël. Thanks for your attention to the translatable messages here:

Quoted 11 lines
Quoted 9 lines

error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"), from_file, to_file);

die(_("failed to copy worktree config from '%s' to '%s'"), from_file, to_file);

error(_("failed to unset 'core.bare' in '%s'"), to_file);

error(_("failed to unset 'core.worktree' in '%s'"), to_file);

In the first patch of this series, you use _("unable to set '%s' in'%s'). Does it make sense to reuse this string here?

I would argue that "unable to set" is not appropriate for any of these messages. Perhaps the "failed to copy" messages might be able to use "unable to set", but the information that the config setting is coming from settings the user controlled is valuable.

Quoted 8 lines

The "failed to unset" means "we are trying to _remove_ this setting from the config file", so "unable to set" does not seem to work here.

I'm open to revisiting this if you disagree.

Thanks,
-Stolee

Hi Derrick,

Sorry for not being more precise. The first two errors were not the subject of this remark.

For the last two, this is quite surprising that the same function failing (git_config_set_in_file_gently) can lead to different error messages.

Quoted 7 lines

In any case, I would argue at least for  shifting to :

    error(_("failed to unset '%s' in '%s'"), 'core.bare", to_file); and
    error(_("failed to unset '%s' in '%s'"), "core.worktree", to_file);

in order to factorize the message and get the option name out of the way.

Thank you for the clarification! This makes sense as a way to reduce load on translators. Sorry for misunderstanding.

Thanks,
-Stolee

#121 lore raw

Re: [PATCH v6 2/6] worktree: create init_worktree_config()

In reply to Junio C Hamano
Quoted 59 lines · Junio C Hamano

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 839

Quoted 9 lines · Derrick Stolee via GitGitGadget
worktree.c +9 -0
+static int move_config_setting(const char *key, const char *value,
+                            const char *from_file, const char *to_file)
+{
+     if (git_config_set_in_file_gently(to_file, key, value))
+             return error(_("unable to set %s in '%s'"), key, to_file);
+     if (git_config_set_in_file_gently(from_file, key, NULL))
+             return error(_("unable to unset %s in '%s'"), key, from_file);
+     return 0;
+}

Interesting.

The verb "move" in its name made me expect a "get (and remove) whatever value(s) defined out of the old file, and set them identically in the new file" sequence, but that is not what is done here. "set to this new single value in the new file and unset from the old one".

I can see the need to say "move it only when its value is X", so having the caller to extract the value before deciding to call the function (hence not "moving from old") does make sense, but then the function is misnamed---it is not "moving", it is doing something else.

Quoted 5 lines
worktree.c +5 -0
+int init_worktree_config(struct repository *r)
+{
+     int res = 0;
+     int bare = 0;
+     struct config_set cs = { { 0 } };

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 855

Quoted 10 lines
worktree.c +10 -0
+     const char *core_worktree;
+     char *common_config_file;
+     char *main_worktree_file;
+
+     /*
+      * If the extension is already enabled, then we can skip the
+      * upgrade process.
+      */
+     if (repository_format_worktree_config)
+             return 0;

OK.

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 857

Quoted 2 lines
worktree.c +2 -0
+     if ((res = git_config_set_gently("extensions.worktreeConfig", "true")))
+             return error(_("failed to set extensions.worktreeConfig setting"));

OK.

Quoted 9 lines
worktree.c +9 -0
+     common_config_file = xstrfmt("%s/config", r->commondir);
+     main_worktree_file = xstrfmt("%s/config.worktree", r->commondir);
+
+     git_configset_init(&cs);
+     git_configset_add_file(&cs, common_config_file);
+
+     /*
+      * If core.bare is true in the common config file, then we need to
+      * move it to the main worktree's config file or it will break all
Quoted 8 lines

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 870

Quoted 3 lines
worktree.c +3 -0
+      * worktrees. If it is false, then leave it in place because it
+      * _could_ be negating a global core.bare=true.
+      */

Is the assumption that the secondary worktrees are never bare, but the primary one could be (iow, adding worktrees to a bare repository would leave the original bare repository as the primary "worktree" that does not have "working tree")?

Yes, and in fact that was the case which generated the original bug report -- a bare clone where the affected individual started using git worktree add to create some non-primary worktrees (and then also used sparse-checkout in some of them).

Quoted 4 lines

I am trying to see what downsides
it tries to avoid by not moving the core.bare==false setting. Shouldn't core.bare be set to false when "worktree add" creates a new one anyway, if the secondaries are never bare?

Moving the core.bare==false setting might make sense. In the previous discussions, we tried to hypothesize about usage of old git clients and non-git clients (jgit, etc.) on the same repos, and didn't know if some of those would break if they couldn't find a core.bare setting anywhere (since they wouldn't know to look in config.worktree). We needed to migrate core.bare=true to avoid an incorrect value affecting all worktrees (and thus we figured it was worth the risk of breaking older git/non-git clients because having older clients be broken is better than having all clients including current git be broken), but the same wasn't true for core.bare=false. That said, we don't actively know of any such clients that would be hurt by such a migration.

#109 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Derrick Stolee
Quoted 6 lines · Derrick Stolee
Quoted 6 lines

+[[def_work_tree]]worktree::

Documentation/glossary-content.txt +5 -0
+	A repository can have zero (i.e. bare repository) or one or
+	more worktrees attached to it. One "worktree" consists of a
+	"working tree" and repository metadata, most of which are
+	shared among other worktrees of a single repository, and
+	some of which are maintained separately per worktree
Quoted 8 lines

Documentation/glossary-content.txt The most notable example is `HEAD`. · line 680

Quoted 2 lines
Documentation/glossary-content.txt +2 -0
+	(e.g. the index, HEAD, per-worktree refs and per-worktree
+	configuration file)

I like this addition, except that I don't understand the "per-worktree refs" (other than HEAD). Are there other thins used by features such as merge and rebase that would appear as worktree-specific? Of course, some state for these operations is stored per-worktree, I just didn't know if any were actually "refs".

"per-worktree ref" is an entry in the glossary.

[[def_per_worktree_ref]]per-worktree ref::
Refs that are per-<<def_working_tree,worktree>>, rather than global. This is presently only <<def_HEAD,HEAD>> and any refs that start with refs/bisect/, but might later include other unusual refs.

And those other things are also listed as "pseudoref".

[[def_pseudoref]]pseudoref::
Pseudorefs are a class of files under $GIT_DIR which behave like refs for the purposes of rev-parse, but which are treated specially by git...

I think the motivation of special casing refs/bisect/ is to allow use of a separate worktree for bisecting without affecting other development or another bisection. The HEAD is singled out in the description, but MERGE_HEAD and others (pseudoref) that are declared here to be files under '$GIT_DIR', when we migrate fully to other backend that may not want to have files under '$GIT_DIR' to represent them, ought to become per-worktree, for the same reason as HEAD should be per-worktree, i.e. it allows worktrees to be independent from each other and have their checkout at different commits, growing history of different branches in parallel.

#110 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

Quoted 32 lines · Junio C Hamano
Quoted 6 lines · Derrick Stolee
Quoted 6 lines

+[[def_work_tree]]worktree::

Documentation/glossary-content.txt +5 -0
+	A repository can have zero (i.e. bare repository) or one or
+	more worktrees attached to it. One "worktree" consists of a
+	"working tree" and repository metadata, most of which are
+	shared among other worktrees of a single repository, and
+	some of which are maintained separately per worktree
Quoted 8 lines

Documentation/glossary-content.txt The most notable example is `HEAD`. · line 680

Quoted 2 lines
Documentation/glossary-content.txt +2 -0
+	(e.g. the index, HEAD, per-worktree refs and per-worktree
+	configuration file)

I like this addition, except that I don't understand the "per-worktree refs" (other than HEAD). Are there other thins used by features such as merge and rebase that would appear as worktree-specific? Of course, some state for these operations is stored per-worktree, I just didn't know if any were actually "refs".

"per-worktree ref" is an entry in the glossary.

[[def_per_worktree_ref]]per-worktree ref::
Refs that are per-<<def_working_tree,worktree>>, rather than global. This is presently only <<def_HEAD,HEAD>> and any refs that start with refs/bisect/, but might later include other unusual refs.

And those other things are also listed as "pseudoref".

[[def_pseudoref]]pseudoref::
Pseudorefs are a class of files under $GIT_DIR which behave like refs for the purposes of rev-parse, but which are treated specially by git...

Quoted 10 lines

I think the motivation of special casing refs/bisect/ is to allow use of a separate worktree for bisecting without affecting other development or another bisection. The HEAD is singled out in the description, but MERGE_HEAD and others (pseudoref) that are declared here to be files under '$GIT_DIR', when we migrate fully to other backend that may not want to have files under '$GIT_DIR' to represent them, ought to become per-worktree, for the same reason as HEAD should be per-worktree, i.e. it allows worktrees to be independent from each other and have their checkout at different commits, growing history of different branches in parallel.

Thanks for this additional context! It means that I need to look around more carefully, not that your patch needs any changes.

-Stolee

#120 lore raw

Re: [PATCH v6 2/6] worktree: create init_worktree_config()

In reply to Derrick Stolee
Quoted 21 lines · Derrick Stolee
Quoted 14 lines · Junio C Hamano

worktree.c int should_prune_worktree(const char *id, struct strbuf *reason, char **wtpath, · line 839

Quoted 9 lines · Derrick Stolee via GitGitGadget
worktree.c +9 -0
+static int move_config_setting(const char *key, const char *value,
+			       const char *from_file, const char *to_file)
+{
+	if (git_config_set_in_file_gently(to_file, key, value))
+		return error(_("unable to set %s in '%s'"), key, to_file);
+	if (git_config_set_in_file_gently(from_file, key, NULL))
+		return error(_("unable to unset %s in '%s'"), key, from_file);
+	return 0;
+}

Interesting.

Quoted 5 lines

The verb "move" in its name made me expect a "get (and remove) whatever value(s) defined out of the old file, and set them identically in the new file" sequence, but that is not what is done here. "set to this new single value in the new file and unset from the old one".

Quoted 8 lines

I think this "copy into the worktree-specific config, then remove from the common file" is an important sequence of events in case a concurrent process comes in and reads the two config files in the intermediate state and does not see the config value anywhere.

But perhaps that's not actually what you are concerned about, because you're saying that the 'value' being provided does not actually guarantee that we are moving the setting.

Yes. "Why are we _ignoring_ what is in the old file when we claim to be _moving_?" was the question I had upon seeing this function.

Quoted 10 lines
Quoted 5 lines

I can see the need to say "move it only when its value is X", so having the caller to extract the value before deciding to call the function (hence not "moving from old") does make sense, but then the function is misnamed---it is not "moving", it is doing something else.

I think the end state is correct for all uses here, since we only run this after checking to see if the config value exists in the 'from_file', so 'value' is correct (and this is a static method, not a generally-useful method for config.h).

As long as this is used on a single-valued "last one wins" variable, the callers and this helper taken together will do the right thing.

Quoted 4 lines

Perhaps a "write_in_new_and_remove_from_old()" would be a better, if verbose, name. I struggle to find a less cumbersome name, and "move" seems to match the intent pretty well in the context of its use.

The name is fine as long as the requirement for the caller is made clear. A short comment to help the next reader from having to ask the same question before the helper may be sufficient.

Quoted 8 lines
Quoted 7 lines

Is the assumption that the secondary worktrees are never bare, but the primary one could be (iow, adding worktrees to a bare repository would leave the original bare repository as the primary "worktree" that does not have "working tree")? I am trying to see what downsides it tries to avoid by not moving the core.bare==false setting. Shouldn't core.bare be set to false when "worktree add" creates a new one anyway, if the secondaries are never bare?

Quoted 6 lines

Secondary worktrees cannot be bare. If Git interprets the worktree config to have core.bare=true in a secondary worktree, it errors out.

You seem to be suggesting that we should explicitly write core.bare=false into each of the worktree-specific config files. Is that right? This move is effectively the same, since 'false' is the default.

Unless there is a lower-precedence configuration file that we have to override, yes, not writing core.bare=false upon "worktree add" is fine. I simply do not know if we need to do something special in order to defeat /etc/gitconfig or $HOME/.gitconfig with the repository or the worktree specific configuration file.

Quoted 5 lines

Here, the verbal gymnastics are somewhat necessary because secondary worktrees have a .git _file_, not a git directory, so using "common Git dir" is a way to explicitly reference the Git dir. And the strangeness here is exactly that core.worktree can change this working tree to be something other than the parent of the (common) Git dir.

OK. The .git _file_ is our moral equivalent to a symbolic link, and I forgot about that.

I also wonder if we should do something like what we do for refs (i.e. the API knows which refs are per-worktree and which are global, so the callers do not have to care and just can say things like "update HEAD to this value", and "give me the value of refs/bisect/good") when repo_set_config*() is called, but that is outside the scope of this step, which is about one-time migration.

As the code for migration go, I think I am happy with what it wants to do and how it does it.

Thanks.

#125 lore raw

Re: [PATCH v6 3/6] config: add repo_config_set_worktree_gently()

In reply to Derrick Stolee
Quoted 15 lines · Derrick Stolee
Quoted 1 line · Junio C Hamano

"Derrick Stolee via GitGitGadget" <[email protected]> writes:

...

Quoted 11 lines

config.c void git_config_set_multivar_in_file(const char *config_filename, · line 3201

Quoted 9 lines
config.c +3 -2
@@ -3181,14 +3196,28 @@ void git_config_set_multivar_in_file(const char *config_filename,
 int git_config_set_multivar_gently(const char *key, const char *value,
 				   const char *value_pattern, unsigned flags)
 {
-	return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern,
-						      flags);
+	return repo_config_set_multivar_gently(the_repository, key, value,
+					       value_pattern, flags);
+}

Is this an unrelated "morally no-op" change?

Quoted 4 lines

This one is to match the pattern of how "git_*" methods should depend on their "repo_*" counterparts (with "the_repository" inserted properly). So, it's part of the standard process for creating these "repo_*" variants.

If only one of repo_config_set_multivar_gently() and git_config_set_multivar_gently() existed and we were completing the pair, then I would understand the explanation, but the title says that it is adding repo_config_set_worktree_gently(), which is not, and that is where the "unrelated" comes from.

It needs to be a separate preparatory step to add
repo_config_set_multivar_gently() before we add
repo_config_set_worktree_gently(), perhaps?

A bit higher level question is if the public part of "config-set" API functions should gain an "easy" (in the sense of curl_easy_* set of API functions) API to allow the callers to say "I do not care to find out if per-worktree configuration is in use, or this particular variable is meant to be per-worktree, just set it to this value".

On this question, I am of two minds. As certain variables (like core.sparseCheckout) should always be per-worktree just like certain refs (like HEAD) should always be per-worktree, I can understand the viewpoint that the callers _ought_ to know and explicitly say that they want to get/set in the per-worktree configuration file, but at the same time, I would think the callers should not have to care. So, I dunno.

Thanks.

#111 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Junio C Hamano
Quoted 33 lines · Junio C Hamano
Quoted 9 lines · Derrick Stolee

Documentation/glossary-content.txt The most notable example is `HEAD`. · line 680

Quoted 8 lines

+[[def_work_tree]]worktree::

Documentation/glossary-content.txt +7 -0
+    A repository can have zero (i.e. bare repository) or one or
+    more worktrees attached to it. One "worktree" consists of a
+    "working tree" and repository metadata, most of which are
+    shared among other worktrees of a single repository, and
+    some of which are maintained separately per worktree
+    (e.g. the index, HEAD, per-worktree refs and per-worktree
+    configuration file)
Quoted 5 lines

I like this addition, except that I don't understand the "per-worktree refs" (other than HEAD). Are there other thins used by features such as merge and rebase that would appear as worktree-specific? Of course, some state for these operations is stored per-worktree, I just didn't know if any were actually "refs".

"per-worktree ref" is an entry in the glossary.

[[def_per_worktree_ref]]per-worktree ref::
Refs that are per-<<def_working_tree,worktree>>, rather than global. This is presently only <<def_HEAD,HEAD>> and any refs that start with refs/bisect/, but might later include other unusual refs.

And those other things are also listed as "pseudoref".

[[def_pseudoref]]pseudoref::
Pseudorefs are a class of files under $GIT_DIR which behave like refs for the purposes of rev-parse, but which are treated specially by git...

Quoted 10 lines

I think the motivation of special casing refs/bisect/ is to allow use of a separate worktree for bisecting without affecting other development or another bisection. The HEAD is singled out in the description, but MERGE_HEAD and others (pseudoref) that are declared here to be files under '$GIT_DIR', when we migrate fully to other backend that may not want to have files under '$GIT_DIR' to represent them, ought to become per-worktree, for the same reason as HEAD should be per-worktree, i.e. it allows worktrees to be independent from each other and have their checkout at different commits, growing history of different branches in parallel.

You had me worried for a second; things would be really broken if these pseudorefs weren't per-worktree.

But testing just now, I think the pseudorefs are already per-worktree. I just did a merge in a secondary worktree, and then observed from the primary worktree that a .git/worktrees/<id>/MERGE_HEAD was created, not a .git/MERGE_HEAD. (Maybe the glossary could just spell out that these are under $GIT_DIR and _not_ $GIT_COMMON_DIR to avoid potential confusion?)

#115 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Junio C Hamano
Quoted 81 lines · Junio C Hamano
Quoted 6 lines · Derrick Stolee via GitGitGadget
Documentation/config/extensions.txt +0 -0
index 4e23d73cdca..bccaec7a963 100644
@@ -6,3 +6,34 @@ extensions.objectFormat::
 Note that this setting should only be set by linkgit:git-init[1] or

Documentation/config/extensions.txt extensions.objectFormat:: · line 16

Quoted 10 lines
Documentation/config/extensions.txt +8 -0
 linkgit:git-clone[1].  Trying to change it after initialization will not
 work and will produce hard-to-diagnose issues.
+
+extensions.worktreeConfig::
+     If enabled, then worktrees will load config settings from the
+     `$GIT_DIR/config.worktree` file in addition to the
+     `$GIT_COMMON_DIR/config` file. Note that `$GIT_COMMON_DIR` and
+     `$GIT_DIR` are the same for the main working tree, while other
+     working trees have `$GIT_DIR` equal to
+     `$GIT_COMMON_DIR/worktrees/<id>/`. The settings in the

The mixed use of "worktree" and "working tree" in this paragraph might confuse readers into thinking that the paragraph is being careful to make distinction between the two. All references to "working tree" in the above paragraph should actually be "worktree", I would think.

Side note: "working tree" is in the glossary-content.txt, but "worktree", which is one "working tree" + repository metadata (i.e. ".git/") that may be partially shared with other "worktree"s of a single repository, is not defined.

This is a tangent, but I wonder why we chose to use a different filename (i.e. not "config" but "config.worktree") for this. If we were redoing multi-worktree support from scratch, we would not reuse the $GIT_DIR used by the primary worktree as $GIT_COMMON_DIR, so that all worktrees would share a single $GIT_COMMON_DIR and $GIT_COMMON_DIR/config that has stuff that is shared among all the worktrees, while per worktree stuff is in $GIT_DIR/config even for the primary worktree. But that is all water under the bridge now.

Other than the terminology gotcha, looked sensible. Migrating automatically and/or noticing a suspicious setting may be needed to help end users, but that would not be within the scope of this step.

Attached is a "how about this?" glossary update suggestion. Most of the existing mention of "working tree" are fine as-is because they only care about what is in the "working tree", but some should be changed to "worktree" to stress the fact that they care not just the "working tree" part but also the repository metadata part that is associated with that single "working tree". The first hunk says worktree but it is clear that it is interested only in the "working tree" files.

 Documentation/glossary-content.txt | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
Documentation/glossary-content.txt +2 -2
index c077971335..d816512c6a 100644
@@ -312,7 +312,7 @@ Pathspecs are used on the command line of "git ls-files", "git
 ls-tree", "git add", "git grep", "git diff", "git checkout",
 and many other commands to
 limit the scope of operations to some subset of the tree or
-worktree.  See the documentation of each command for whether
+working tree.  See the documentation of each command for whether
 paths are relative to the current directory or toplevel.  The
 pathspec syntax is as follows:
 +
@@ -446,7 +446,7 @@ exclude;;
        interface than the <<def_plumbing,plumbing>>.
 
 [[def_per_worktree_ref]]per-worktree ref::
-       Refs that are per-<<def_working_tree,worktree>>, rather than
+       Refs that are per-<<def_worktree,worktree>>, rather than
        global.  This is presently only <<def_HEAD,HEAD>> and any refs
        that start with `refs/bisect/`, but might later include other
        unusual refs.
@@ -669,3 +669,12 @@ The most notable example is `HEAD`.
        The tree of actual checked out files.  The working tree normally
        contains the contents of the <<def_HEAD,HEAD>> commit's tree,

Documentation/glossary-content.txt The most notable example is `HEAD`. · line 680

Quoted 10 lines
Documentation/glossary-content.txt +9 -0
        plus any local changes that you have made but not yet committed.
+
+[[def_work_tree]]worktree::
+       A repository can have zero (i.e. bare repository) or one or
+       more worktrees attached to it. One "worktree" consists of a
+       "working tree" and repository metadata, most of which are
+       shared among other worktrees of a single repository, and
+       some of which are maintained separately per worktree
+       (e.g. the index, HEAD, per-worktree refs and per-worktree
+       configuration file)

We could also add pseudorefs to the list of things maintained separately in the final parenthetical comment, but otherwise looks good.

#112 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Elijah Newren
Quoted 6 lines · Elijah Newren

But testing just now, I think the pseudorefs are already per-worktree. I just did a merge in a secondary worktree, and then observed from the primary worktree that a .git/worktrees/<id>/MERGE_HEAD was created, not a .git/MERGE_HEAD. (Maybe the glossary could just spell out that these are under $GIT_DIR and _not_ $GIT_COMMON_DIR to avoid potential confusion?)

I actually think the longer-term direction is to describe that these are always per-worktree, without referring to $GIT_DIR or giving any hints that these may be represented as a file in the filesystem. That would leave the door open for the reftable backend to take them over as well as the normal refs.

#116 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Elijah Newren
Quoted 15 lines · Elijah Newren
Quoted 15 lines

[[def_per_worktree_ref]]per-worktree ref::

Documentation/glossary-content.txt +6 -1
-       Refs that are per-<<def_working_tree,worktree>>, rather than
+       Refs that are per-<<def_worktree,worktree>>, rather than
        global.  This is presently only <<def_HEAD,HEAD>> and any refs
        that start with `refs/bisect/`, but might later include other
        unusual refs.
@@ -669,3 +669,12 @@ The most notable example is `HEAD`.
        The tree of actual checked out files.  The working tree normally
        contains the contents of the <<def_HEAD,HEAD>> commit's tree,
        plus any local changes that you have made but not yet committed.
+
+[[def_work_tree]]worktree::
+       A repository can have zero (i.e. bare repository) or one or
+       more worktrees attached to it. One "worktree" consists of a
+       "working tree" and repository metadata, most of which are
Quoted 8 lines

Documentation/glossary-content.txt The most notable example is `HEAD`. · line 680

Quoted 4 lines
Documentation/glossary-content.txt +4 -0
+       shared among other worktrees of a single repository, and
+       some of which are maintained separately per worktree
+       (e.g. the index, HEAD, per-worktree refs and per-worktree
+       configuration file)

We could also add pseudorefs to the list of things maintained separately in the final parenthetical comment, but otherwise looks good.

I think what needs updating is the per_worktree_ref section. Before we say "later include other unusual refs", not so unusual pseudorefs can be mentioned there.

#126 lore raw

Re: [PATCH v6 3/6] config: add repo_config_set_worktree_gently()

In reply to Junio C Hamano
Quoted 28 lines · Junio C Hamano
Quoted 15 lines · Derrick Stolee
Quoted 1 line · Junio C Hamano

"Derrick Stolee via GitGitGadget" <[email protected]> writes:

...

Quoted 11 lines

config.c void git_config_set_multivar_in_file(const char *config_filename, · line 3201

Quoted 9 lines
config.c +3 -2
@@ -3181,14 +3196,28 @@ void git_config_set_multivar_in_file(const char *config_filename,
 int git_config_set_multivar_gently(const char *key, const char *value,
 				   const char *value_pattern, unsigned flags)
 {
-	return git_config_set_multivar_in_file_gently(NULL, key, value, value_pattern,
-						      flags);
+	return repo_config_set_multivar_gently(the_repository, key, value,
+					       value_pattern, flags);
+}

Is this an unrelated "morally no-op" change?

Quoted 4 lines

This one is to match the pattern of how "git_*" methods should depend on their "repo_*" counterparts (with "the_repository" inserted properly). So, it's part of the standard process for creating these "repo_*" variants.

If only one of repo_config_set_multivar_gently() and git_config_set_multivar_gently() existed and we were completing the pair, then I would understand the explanation, but the title says that it is adding repo_config_set_worktree_gently(), which is not, and that is where the "unrelated" comes from.

Quoted 3 lines

It needs to be a separate preparatory step to add
repo_config_set_multivar_gently() before we add
repo_config_set_worktree_gently(), perhaps?

True, they could be split. The reason to create the _multivar_ version is for the case that worktree config is not specified, so that is the only caller at the moment.

Quoted 6 lines

A bit higher level question is if the public part of "config-set" API functions should gain an "easy" (in the sense of curl_easy_* set of API functions) API to allow the callers to say "I do not care to find out if per-worktree configuration is in use, or this particular variable is meant to be per-worktree, just set it to this value".

Quoted 7 lines

On this question, I am of two minds. As certain variables (like core.sparseCheckout) should always be per-worktree just like certain refs (like HEAD) should always be per-worktree, I can understand the viewpoint that the callers _ought_ to know and explicitly say that they want to get/set in the per-worktree configuration file, but at the same time, I would think the callers should not have to care. So, I dunno.

This is an interesting idea. This would require creating a list of "should be per-worktree" config keys that are checked within the different *_config_set_* methods.

The biggest technical hurdle is that the multivar versions might need to send a subset of the given config into the worktree config and the rest to the common config.

Let's see how this progresses in the future, and whether we have more config that we believe _must_ be stored on a per- worktree basis. At that point, we can see whether the current "distributed responsibility" model is too cumbersome.

Thanks,
-Stolee

#127 lore raw

Re: [PATCH v6 3/6] config: add repo_config_set_worktree_gently()

Quoted 3 lines · Derrick Stolee

True, they could be split. The reason to create the _multivar_ version is for the case that worktree config is not specified, so that is the only caller at the moment.

Sorry, but I am not following this part.

Quoted 3 lines

This is an interesting idea. This would require creating a list of "should be per-worktree" config keys that are checked within the different *_config_set_* methods.

Yes.

Quoted 3 lines

The biggest technical hurdle is that the multivar versions might need to send a subset of the given config into the worktree config and the rest to the common config.

Yes, instead of having the caller do it.

Quoted 4 lines

Let's see how this progresses in the future, and whether we have more config that we believe _must_ be stored on a per- worktree basis. At that point, we can see whether the current "distributed responsibility" model is too cumbersome.

It is not too distributed, which is a saving grace. The callers know they are setting core.sparseCheckout* and they are responsible to call the per-worktree version. It would be like having in ref API an update_HEAD() helper for modifying HEAD, instead of having a more generic update_ref() that can modify any ref and pass "HEAD" as an argument to the latter. The caller needs to know a bit more details about what needs to happen when dealing with a special thing, but the special case knowledge is fairly concentrated.

#113 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Derrick Stolee
Quoted 16 lines · Derrick Stolee
Quoted 9 lines · Junio C Hamano

Review

Quoted 7 lines · Derrick Stolee via GitGitGadget
(quoted diff) +7 -0
+extensions.worktreeConfig::
+    If enabled, then worktrees will load config settings from the
+    `$GIT_DIR/config.worktree` file in addition to the
+    `$GIT_COMMON_DIR/config` file. Note that `$GIT_COMMON_DIR` and
+    `$GIT_DIR` are the same for the main working tree, while other
+    working trees have `$GIT_DIR` equal to
+    `$GIT_COMMON_DIR/worktrees/<id>/`. The settings in the
Quoted 5 lines

The mixed use of "worktree" and "working tree" in this paragraph might confuse readers into thinking that the paragraph is being careful to make distinction between the two. All references to "working tree" in the above paragraph should actually be "worktree", I would think.

Quoted 5 lines

I generally agree. This was changed in the most-recent re-roll based on a request by Eric [1]. I'm happy to take whichever version the two of you settle on.

[1] https://lore.kernel.org/git/CAPig+cS-3CxxyPGcy_vkeN_WYTRo1b-ZhJNdPy8ARZSNKkF1Xg@mail.gmail.com/

"request" is perhaps too strong a word considering that I led in with:

A few minor comments, which can be addressed later or not at all, and likely are not worth holding up the series...

I mentioned "worktree vs. working tree" only to point out the terminology inconsistency being introduced by the new patch; the same sort of inconsistency which had bothered Michael Haggerty enough to do something about it in bc483285b7 (Documentation/git-worktree:
consistently use term "linked working tree", 2015-07-20).

I, personally, prefer the term "worktree" for both convenience and because it better encapsulates the overall "thing" which is manipulated by the git-worktree command unlike the term "working tree" which, as Junio points out, has (perhaps) a more narrow meaning. As such, I would not be opposed to a patch series which changes "working tree" to "worktree" in documentation where appropriate, but that's outside the scope of this series.

#102 lore raw

Re: [PATCH v5 5/5] worktree: copy sparse-checkout patterns and config on add

In reply to Derrick Stolee
Quoted 10 lines · Derrick Stolee
Quoted 6 lines · Eric Sunshine

t/t2400-worktree-add.sh test_expect_success '"add" default branch of a bare repo' ' · line 187

Quoted 2 lines · Derrick Stolee via GitGitGadget
t/t2400-worktree-add.sh +2 -0
+               git config --worktree bogus.key value &&
+               git config --unset core.bare &&

Why is this being unset? (Genuine question. Am I missing something obvious?)

I'm moving it out of the common config file. Earlier commands enabled it in the config.worktree file for this working tree.

But won't the git worktree add commands which immediately follow this bit automatically drop core.bare=true from the common config file? Or am I misthinking on this? Or are you just trying to be explicit here with the manual removal?

#130 lore raw

Re: [PATCH v6 5/6] worktree: copy sparse-checkout patterns and config on add

In reply to Derrick Stolee via GitGitGadget
Quoted 63 lines · Derrick Stolee via GitGitGadget

When adding a new worktree, it is reasonable to expect that we want to use the current set of sparse-checkout settings for that new worktree. This is particularly important for repositories where the worktree would become too large to be useful. This is even more important when using partial clone as well, since we want to avoid downloading the missing blobs for files that should not be written to the new worktree.

---

builtin/worktree.c +52 -0
@@ -335,6 +335,69 @@ 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 we are using worktree config, then copy all current config
+        * 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 'core.bare' in '%s'"), to_file);
+                       if (!git_configset_get_value(&cs, "core.worktree", &core_worktree) &&
+                           git_config_set_in_file_gently(to_file,

builtin/worktree.c static int add_worktree(const char *path, const char *refname, · line 396

Quoted 10 lines
builtin/worktree.c +10 -0
+                                                         "core.worktree", NULL))
+                               error(_("failed to unset 'core.worktree' in '%s'"), to_file);
+
+                       git_configset_clear(&cs);
+               }
+
+worktree_copy_cleanup:
+               free(from_file);
+               free(to_file);
+       }

Given that add_worktree() is already overly long, a good future cleanup would be to move these two new hunks of functionality into separate functions -- copy_sparsity() and copy_config(), perhaps -- in builtin/worktree.c. This should be simple enough since (I think) the only state that needs to be passed to them is sb_repo. But such cleanup needn't hold up this series.

#136 lore raw
In reply to Eric Sunshine
Quoted 9 lines · Eric Sunshine
Quoted 2 lines · Elijah Newren

So, you clearly also read the patches in this round. Do they also
look good to you? :-)

I have not yet looked at either the patches or the range-diff, and I only scanned my eye quickly over the cover letter, but the empty bullet point made me stop and look a bit more carefully at that part (and only that part) of the cover letter. Not sure yet when I'll have time to carefully read this round.

I've now read through the series and, I think, left only one or two minor not-actionable comments.

#114 lore raw

Re: [PATCH v6 1/6] Documentation: add extensions.worktreeConfig details

In reply to Eric Sunshine
Quoted 8 lines · Eric Sunshine
Quoted 5 lines

I generally agree. This was changed in the most-recent re-roll based on a request by Eric [1]. I'm happy to take whichever version the two of you settle on.

[1] https://lore.kernel.org/git/CAPig+cS-3CxxyPGcy_vkeN_WYTRo1b-ZhJNdPy8ARZSNKkF1Xg@mail.gmail.com/

"request" is perhaps too strong a word considering that I led in with:

Quoted 8 lines

A few minor comments, which can be addressed later or not at all, and likely are not worth holding up the series...

I mentioned "worktree vs. working tree" only to point out the terminology inconsistency being introduced by the new patch; the same sort of inconsistency which had bothered Michael Haggerty enough to do something about it in bc483285b7 (Documentation/git-worktree:
consistently use term "linked working tree", 2015-07-20).

Yup, it seems both of us found mixed use of these two terms disturbing. Michael's old commit was mostly about "worktree" vs "working tree", even though 2 changes among 13 changes to the file were about updating "working directory" to "working tree", and to me it seems to made the terminology straightened up. E.g. a hunk from the change uses "a linked working tree and its administrative files"

-- remove to remove a linked worktree and its administrative files (and
- warn if the worktree is dirty)
-- mv to move or rename a worktree and update its administrative files -- list to list linked worktrees
+- remove to remove a linked working tree and its administrative files (and
+ warn if the working tree is dirty)
+- mv to move or rename a working tree and update its administrative files +- list to list linked working trees
- lock to prevent automatic pruning of administrative files (for instance,
- for a worktree on a portable device)
+ for a working tree on a portable device)

which clearly refers to things above .git as "working tree".

Quoted 7 lines

I, personally, prefer the term "worktree" for both convenience and because it better encapsulates the overall "thing" which is manipulated by the git-worktree command unlike the term "working tree" which, as Junio points out, has (perhaps) a more narrow meaning. As such, I would not be opposed to a patch series which changes "working tree" to "worktree" in documentation where appropriate, but that's outside the scope of this series.

I would welcome such changes where appropriate in both directions (I think I updated a few places in the glossary). I agree that this topic is not a place to do so.

#103 lore raw

Re: [PATCH v5 5/5] worktree: copy sparse-checkout patterns and config on add

In reply to Eric Sunshine
Quoted 9 lines · Eric Sunshine
Quoted 8 lines · Derrick Stolee
Quoted 6 lines · Eric Sunshine

t/t2400-worktree-add.sh test_expect_success '"add" default branch of a bare repo' ' · line 187

Quoted 2 lines · Derrick Stolee via GitGitGadget
t/t2400-worktree-add.sh +2 -0
+               git config --worktree bogus.key value &&
+               git config --unset core.bare &&

Why is this being unset? (Genuine question. Am I missing something obvious?)

Quoted 7 lines
Quoted 2 lines

I'm moving it out of the common config file. Earlier commands enabled it in the config.worktree file for this working tree.

But won't the git worktree add commands which immediately follow this bit automatically drop core.bare=true from the common config file? Or am I misthinking on this? Or are you just trying to be explicit here with the manual removal?

Ah. Here we are testing that bogus.key gets copied from the config.worktree file, but core.bare and core.worktree do _not_.

This is kind of like the case where we run two 'git worktree add' commands in a row. The first one moves core.bare and core.worktree into the config.worktree file. The second one attempts to copy the config.worktree file into the new worktree (but must filter out these config keys).

Thanks,
-Stolee