git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v5 0/4] Per-worktree config file support
@ 2017-01-10 11:25 Nguyễn Thái Ngọc Duy
  2017-01-10 11:25 ` [PATCH v5 1/4] config: read per-worktree config files Nguyễn Thái Ngọc Duy
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2017-01-10 11:25 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, git, Jens.Lehmann, larsxschneider, sbeller,
	mhagger, max, Nguyễn Thái Ngọc Duy

Let's get this rolling again. To refresh your memory because it's half
a year since v4 [1], this is about letting each worktree in multi
worktree setup has their own config settings. The most prominent ones
are core.worktree, used by submodules, and core.sparseCheckout.

This time I'm not touching submodules at all. I'm leaving it in the
good hands of "submodule people". All I'm providing is mechanism. How
you use it is up to you. So the series benefits sparse checkout users
only.

Not much has changed from v4, except that the migration to new config
layout is done automatically _update_ a config variable with "git
config --worktree".

I think this one is more or less ready. I have an RFC follow-up patch
about core.bare, but that could be handled separately.

[1] http://public-inbox.org/git/20160720172419.25473-1-pclouds@gmail.com/

Nguyễn Thái Ngọc Duy (4):
  config: read per-worktree config files
  config: --worktree for manipulating per-worktree config file
  config: automatically migrate to new config layout when --worktree is used
  t2029: add tests for per-worktree config

 Documentation/config.txt               | 11 ++++-
 Documentation/git-config.txt           | 26 ++++++++---
 Documentation/git-worktree.txt         | 37 +++++++++++++++
 Documentation/gitrepository-layout.txt |  8 ++++
 builtin/config.c                       | 16 ++++++-
 cache.h                                |  2 +
 config.c                               |  7 +++
 environment.c                          |  1 +
 setup.c                                |  5 ++-
 t/t2029-worktree-config.sh (new +x)    | 82 ++++++++++++++++++++++++++++++++++
 worktree.c                             | 40 +++++++++++++++++
 worktree.h                             |  6 +++
 12 files changed, 230 insertions(+), 11 deletions(-)
 create mode 100755 t/t2029-worktree-config.sh

-- 
2.8.2.524.g6ff3d78


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

* [PATCH v5 1/4] config: read per-worktree config files
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
@ 2017-01-10 11:25 ` Nguyễn Thái Ngọc Duy
  2017-01-10 11:25 ` [PATCH v5 2/4] config: --worktree for manipulating per-worktree config file Nguyễn Thái Ngọc Duy
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2017-01-10 11:25 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, git, Jens.Lehmann, larsxschneider, sbeller,
	mhagger, max, Nguyễn Thái Ngọc Duy

A new repo extension is added, worktreeConfig. When it is present:

 - Repository config reading by default includes $GIT_DIR/config _and_
   $GIT_DIR/config.worktree. "config" file remains shared in multiple
   worktree setup.

 - The special treatment for core.bare and core.worktree, to stay
   effective only in main worktree, is gone. These config files are
   supposed to be in config.worktree.

This extension is most useful in multiple worktree setup because you
now have an option to store per-worktree config (which is either
.git/config.worktree for main worktree, or
.git/worktrees/xx/config.worktree for linked ones).

This extension can be used in single worktree mode, even though it's
pretty much useless (but this can happen after you remove all linked
worktrees and move back to single worktree).

"git config" reads from both "config" and "config.worktree" by default
(i.e. without either --user, --file...) when this extension is
present. Default writes (not implemented in this patch) still go to
"config", not "config.worktree". A new option --worktree is added for
that (*).

Since a new repo extension is introduced, existing git binaries should
refuse to access to the repo (both from main and linked worktrees). So
they will not misread the config file (i.e. skip the config.worktree
part). They may still accidentally write to the config file anyway if
they use with "git config --file <path>".

This design places a bet on the assumption that the majority of config
variables are shared so it is the default mode. A safer move would be
default writes go to per-worktree file, so that accidental changes are
isolated.

(*) "git config --worktree" points back to "config" file when this
    extension is not present so that it works in any setup.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/config.txt               | 11 +++++++++--
 Documentation/git-config.txt           |  4 ++++
 Documentation/git-worktree.txt         | 31 +++++++++++++++++++++++++++++++
 Documentation/gitrepository-layout.txt |  8 ++++++++
 cache.h                                |  2 ++
 config.c                               |  7 +++++++
 environment.c                          |  1 +
 setup.c                                |  5 ++++-
 8 files changed, 66 insertions(+), 3 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 30cb946..c508386 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -2,8 +2,9 @@ CONFIGURATION FILE
 ------------------
 
 The Git configuration file contains a number of variables that affect
-the Git commands' behavior. The `.git/config` file in each repository
-is used to store the configuration for that repository, and
+the Git commands' behavior. The files `.git/config` and optionally
+`config.worktree` (see `extensions.worktreeConfig` below) are each
+repository is used to store the configuration for that repository, and
 `$HOME/.gitconfig` is used to store a per-user configuration as
 fallback values for the `.git/config` file. The file `/etc/gitconfig`
 can be used to store a system-wide default configuration.
@@ -264,6 +265,12 @@ advice.*::
 		show directions on how to proceed from the current state.
 --
 
+extensions.worktreeConfig::
+	If set, by default "git config" reads from both "config" and
+	"config.worktree" file in that order. In multiple working
+	directory mode, "config" file is shared while
+	"config.worktree" is per-working directory.
+
 core.fileMode::
 	Tells Git if the executable bit of files in the working tree
 	is to be honored.
diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 83f86b9..806873c 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -253,6 +253,10 @@ $XDG_CONFIG_HOME/git/config::
 $GIT_DIR/config::
 	Repository specific configuration file.
 
+$GIT_DIR/config.worktree::
+	This is optional and is only searched when
+	`extensions.worktreeConfig` is present in $GIT_DIR/config.
+
 If no further options are given, all reading options will read all of these
 files that are available. If the global or the system-wide configuration
 file are not available they will be ignored. If the repository configuration
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index e257c19..329a673 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -136,6 +136,37 @@ working trees, it can be used to identify worktrees. 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.
 
+CONFIGURATION FILE
+------------------
+By default, the repository "config" file is shared across all working
+directories. If the config variables `core.bare` or `core.worktree`
+are already present in the config file, they will be applied to the
+main working directory only.
+
+In order to have configuration specific to working directories, you
+can turn on "worktreeConfig" extension, e.g.:
+
+------------
+$ git config extensions.worktreeConfig true
+------------
+
+In this mode, specific configuration stays in the path pointed by `git
+rev-parse --git-path config.worktree`. You can add or update
+configuration in this file with `git config --worktree`. Git before
+version 2.13 will refuse to access repositories with this extension.
+
+Note that in this file, the exception for `core.bare` and
+`core.worktree` is gone. If you have them before, you need to move
+them to the `config.worktree` of the main working directory. You may
+also take this opportunity to move other configuration that you do not
+want to share to all working directories:
+
+ - `core.worktree` and `core.bare` should never be shared
+
+ - `core.sparseCheckout` is recommended per working directory, unless
+   you are sure you always use sparse checkout for all working
+   directories.
+
 DETAILS
 -------
 Each linked working tree has a private sub-directory in the repository's
diff --git a/Documentation/gitrepository-layout.txt b/Documentation/gitrepository-layout.txt
index a5f99cb..fee2557 100644
--- a/Documentation/gitrepository-layout.txt
+++ b/Documentation/gitrepository-layout.txt
@@ -143,6 +143,11 @@ config::
 	if $GIT_COMMON_DIR is set and "$GIT_COMMON_DIR/config" will be
 	used instead.
 
+config.worktree::
+	Working directory specific configuration file for the main
+	working directory in multiple working directory setup (see
+	linkgit:git-worktree[1]).
+
 branches::
 	A slightly deprecated way to store shorthands to be used
 	to specify a URL to 'git fetch', 'git pull' and 'git push'.
@@ -276,6 +281,9 @@ worktrees/<id>/link::
 	file. It is used to detect if the linked repository is
 	manually removed.
 
+worktrees/<id>/config.worktree::
+	Working directory specific configuration file.
+
 SEE ALSO
 --------
 linkgit:git-init[1],
diff --git a/cache.h b/cache.h
index a50a61a..c621a35 100644
--- a/cache.h
+++ b/cache.h
@@ -777,10 +777,12 @@ extern int grafts_replace_parents;
 #define GIT_REPO_VERSION 0
 #define GIT_REPO_VERSION_READ 1
 extern int repository_format_precious_objects;
+extern int repository_format_worktree_config;
 
 struct repository_format {
 	int version;
 	int precious_objects;
+	int worktree_config;
 	int is_bare;
 	char *work_tree;
 	struct string_list unknown_extensions;
diff --git a/config.c b/config.c
index 83fdecb..a461e68 100644
--- a/config.c
+++ b/config.c
@@ -1307,6 +1307,13 @@ static int do_git_config_sequence(config_fn_t fn, void *data)
 	if (repo_config && !access_or_die(repo_config, R_OK, 0))
 		ret += git_config_from_file(fn, repo_config, data);
 
+	if (repository_format_worktree_config) {
+		char *path = git_pathdup("config.worktree");
+		if (!access_or_die(path, R_OK, 0))
+			ret += git_config_from_file(fn, path, data);
+		free(path);
+	}
+
 	current_parsing_scope = CONFIG_SCOPE_CMDLINE;
 	if (git_config_from_parameters(fn, data) < 0)
 		die(_("unable to parse command-line config"));
diff --git a/environment.c b/environment.c
index 0935ec6..df1be15 100644
--- a/environment.c
+++ b/environment.c
@@ -26,6 +26,7 @@ int warn_ambiguous_refs = 1;
 int warn_on_object_refname_ambiguity = 1;
 int ref_paranoia = -1;
 int repository_format_precious_objects;
+int repository_format_worktree_config;
 const char *git_commit_encoding;
 const char *git_log_output_encoding;
 const char *apply_default_whitespace;
diff --git a/setup.c b/setup.c
index fe572b8..69efe45 100644
--- a/setup.c
+++ b/setup.c
@@ -389,6 +389,8 @@ static int check_repo_format(const char *var, const char *value, void *vdata)
 			;
 		else if (!strcmp(ext, "preciousobjects"))
 			data->precious_objects = git_config_bool(var, value);
+		else if (!strcmp(ext, "worktreeconfig"))
+			data->worktree_config = git_config_bool(var, value);
 		else
 			string_list_append(&data->unknown_extensions, ext);
 	} else if (strcmp(var, "core.bare") == 0) {
@@ -432,8 +434,9 @@ static int check_repository_format_gently(const char *gitdir, int *nongit_ok)
 	}
 
 	repository_format_precious_objects = candidate.precious_objects;
+	repository_format_worktree_config = candidate.worktree_config;
 	string_list_clear(&candidate.unknown_extensions, 0);
-	if (!has_common) {
+	if (!has_common || repository_format_worktree_config) {
 		if (candidate.is_bare != -1) {
 			is_bare_repository_cfg = candidate.is_bare;
 			if (is_bare_repository_cfg == 1)
-- 
2.8.2.524.g6ff3d78


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

* [PATCH v5 2/4] config: --worktree for manipulating per-worktree config file
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
  2017-01-10 11:25 ` [PATCH v5 1/4] config: read per-worktree config files Nguyễn Thái Ngọc Duy
@ 2017-01-10 11:25 ` Nguyễn Thái Ngọc Duy
  2017-01-10 16:52   ` Stefan Beller
  2017-01-10 11:25 ` [PATCH v5 3/4] config: automatically migrate to new config layout when --worktree is used Nguyễn Thái Ngọc Duy
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2017-01-10 11:25 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, git, Jens.Lehmann, larsxschneider, sbeller,
	mhagger, max, Nguyễn Thái Ngọc Duy

As noted in the previous commit, "git config" without options will read
both per-worktree and per-repo by default. --worktree is needed to read
just per-worktree config. Writing goes to per-repo by default though,
unless --worktree is given.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-config.txt | 22 +++++++++++++++-------
 builtin/config.c             | 15 ++++++++++++++-
 2 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt
index 806873c..ead33a8 100644
--- a/Documentation/git-config.txt
+++ b/Documentation/git-config.txt
@@ -47,13 +47,15 @@ checks or transformations are performed on the value.
 
 When reading, the values are read from the system, global and
 repository local configuration files by default, and options
-`--system`, `--global`, `--local` and `--file <filename>` can be
-used to tell the command to read from only that location (see <<FILES>>).
+`--system`, `--global`, `--local`, `--worktree` and
+`--file <filename>` can be used to tell the command to read from only
+that location (see <<FILES>>).
 
 When writing, the new value is written to the repository local
 configuration file by default, and options `--system`, `--global`,
-`--file <filename>` can be used to tell the command to write to
-that location (you can say `--local` but that is the default).
+`--worktree`, `--file <filename>` can be used to tell the command to
+write to that location (you can say `--local` but that is the
+default).
 
 This command will fail with non-zero status upon error.  Some exit
 codes are:
@@ -133,6 +135,11 @@ from all available files.
 +
 See also <<FILES>>.
 
+--worktree::
+	Similar to `--local` except that `.git/config.worktree` is
+	read from or written to if `extensions.worktreeConfig` is
+	present. If not it's the same as `--local`.
+
 -f config-file::
 --file config-file::
 	Use the given config file instead of the one specified by GIT_CONFIG.
@@ -275,9 +282,10 @@ configuration file. Note that this also affects options like `--replace-all`
 and `--unset`. *'git config' will only ever change one file at a time*.
 
 You can override these rules either by command-line options or by environment
-variables. The `--global` and the `--system` options will limit the file used
-to the global or system-wide file respectively. The `GIT_CONFIG` environment
-variable has a similar effect, but you can specify any filename you want.
+variables. The `--global`, `--system` and `--worktree` options will limit
+the file used to the global, system-wide or per-worktree file respectively.
+The `GIT_CONFIG` environment variable has a similar effect, but you
+can specify any filename you want.
 
 
 ENVIRONMENT
diff --git a/builtin/config.c b/builtin/config.c
index 05843a0..7d390af 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -4,6 +4,7 @@
 #include "parse-options.h"
 #include "urlmatch.h"
 #include "quote.h"
+#include "worktree.h"
 
 static const char *const builtin_config_usage[] = {
 	N_("git config [<options>]"),
@@ -23,6 +24,7 @@ static char key_delim = ' ';
 static char term = '\n';
 
 static int use_global_config, use_system_config, use_local_config;
+static int use_worktree_config;
 static struct git_config_source given_config_source;
 static int actions, types;
 static int end_null;
@@ -56,6 +58,7 @@ static struct option builtin_config_options[] = {
 	OPT_BOOL(0, "global", &use_global_config, N_("use global config file")),
 	OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
 	OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
+	OPT_BOOL(0, "worktree", &use_worktree_config, N_("use per-worktree config file")),
 	OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
 	OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
 	OPT_GROUP(N_("Action")),
@@ -490,6 +493,7 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
 	if (use_global_config + use_system_config + use_local_config +
+	    use_worktree_config +
 	    !!given_config_source.file + !!given_config_source.blob > 1) {
 		error("only one config file at a time.");
 		usage_with_options(builtin_config_usage, builtin_config_options);
@@ -524,7 +528,16 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 		given_config_source.file = git_etc_gitconfig();
 	else if (use_local_config)
 		given_config_source.file = git_pathdup("config");
-	else if (given_config_source.file) {
+	else if (use_worktree_config) {
+		struct worktree **worktrees = get_worktrees(0);
+		if (repository_format_worktree_config)
+			given_config_source.file = git_pathdup("config.worktree");
+		else if (worktrees[0] && worktrees[1]) {
+			die("BUG: migration is not supported yet");
+		} else
+			given_config_source.file = git_pathdup("config");
+		free_worktrees(worktrees);
+	} else if (given_config_source.file) {
 		if (!is_absolute_path(given_config_source.file) && prefix)
 			given_config_source.file =
 				xstrdup(prefix_filename(prefix,
-- 
2.8.2.524.g6ff3d78


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

* [PATCH v5 3/4] config: automatically migrate to new config layout when --worktree is used
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
  2017-01-10 11:25 ` [PATCH v5 1/4] config: read per-worktree config files Nguyễn Thái Ngọc Duy
  2017-01-10 11:25 ` [PATCH v5 2/4] config: --worktree for manipulating per-worktree config file Nguyễn Thái Ngọc Duy
@ 2017-01-10 11:25 ` Nguyễn Thái Ngọc Duy
  2017-01-10 11:25 ` [PATCH v5 4/4] t2029: add tests for per-worktree config Nguyễn Thái Ngọc Duy
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2017-01-10 11:25 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, git, Jens.Lehmann, larsxschneider, sbeller,
	mhagger, max, Nguyễn Thái Ngọc Duy

It's not fun to ask the user to set extensions.worktreeConfig manually.
It's error-prone too. So we do it automatically whenever anybody sets a
per-worktree config with "git config" (support for builtin commands is
coming later).

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-worktree.txt |  6 ++++++
 builtin/config.c               |  3 ++-
 worktree.c                     | 40 ++++++++++++++++++++++++++++++++++++++++
 worktree.h                     |  6 ++++++
 4 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 329a673..f5aad0a 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -167,6 +167,12 @@ want to share to all working directories:
    you are sure you always use sparse checkout for all working
    directories.
 
+When `git config --worktree` is used to set a configuration variable
+in multiple working directory setup, `extensions.worktreeConfig` will
+be automatically set. The two variables `core.worktree` and
+`core.bare` if present will be moved to `config.worktree` of the main
+working tree.
+
 DETAILS
 -------
 Each linked working tree has a private sub-directory in the repository's
diff --git a/builtin/config.c b/builtin/config.c
index 7d390af..9dafefd 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -533,7 +533,8 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 		if (repository_format_worktree_config)
 			given_config_source.file = git_pathdup("config.worktree");
 		else if (worktrees[0] && worktrees[1]) {
-			die("BUG: migration is not supported yet");
+			migrate_worktree_config();
+			given_config_source.file = git_pathdup("config.worktree");
 		} else
 			given_config_source.file = git_pathdup("config");
 		free_worktrees(worktrees);
diff --git a/worktree.c b/worktree.c
index eb61212..d8c9d85 100644
--- a/worktree.c
+++ b/worktree.c
@@ -380,3 +380,43 @@ const struct worktree *find_shared_symref(const char *symref,
 
 	return existing;
 }
+
+void migrate_worktree_config(void)
+{
+	struct strbuf worktree_path = STRBUF_INIT;
+	struct strbuf main_path = STRBUF_INIT;
+	struct repository_format format;
+
+	assert(repository_format_worktree_config == 0);
+
+	strbuf_git_common_path(&worktree_path, "config.worktree");
+	strbuf_git_path(&main_path, "config");
+
+	read_repository_format(&format, main_path.buf);
+	assert(format.worktree_config == 0);
+
+	if (format.is_bare >= 0) {
+		git_config_set_in_file(worktree_path.buf,
+				       "core.bare", "true");
+		git_config_set_in_file(main_path.buf,
+				       "core.bare", NULL);
+	}
+	if (format.work_tree) {
+		git_config_set_in_file(worktree_path.buf,
+				       "core.worktree",
+				       format.work_tree);
+		git_config_set_in_file(main_path.buf,
+				       "core.worktree", NULL);
+	}
+
+	git_config_set_in_file(main_path.buf,
+			       "extensions.worktreeConfig", "true");
+	if (format.version == 0)
+		git_config_set_in_file(main_path.buf,
+				       "core.repositoryFormatVersion", "1");
+
+	repository_format_worktree_config = 1;
+
+	strbuf_release(&main_path);
+	strbuf_release(&worktree_path);
+}
diff --git a/worktree.h b/worktree.h
index d59ce1f..cf82676 100644
--- a/worktree.h
+++ b/worktree.h
@@ -76,4 +76,10 @@ extern const char *worktree_git_path(const struct worktree *wt,
 				     const char *fmt, ...)
 	__attribute__((format (printf, 2, 3)));
 
+/*
+ * Called to add extensions.worktreeConfig to $GIT_DIR/config and move
+ * main worktree specific config variables to $GIT_DIR/config.worktree.
+ */
+extern void migrate_worktree_config(void);
+
 #endif
-- 
2.8.2.524.g6ff3d78


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

* [PATCH v5 4/4] t2029: add tests for per-worktree config
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  2017-01-10 11:25 ` [PATCH v5 3/4] config: automatically migrate to new config layout when --worktree is used Nguyễn Thái Ngọc Duy
@ 2017-01-10 11:25 ` Nguyễn Thái Ngọc Duy
  2017-01-10 11:33 ` [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting Nguyễn Thái Ngọc Duy
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2017-01-10 11:25 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, git, Jens.Lehmann, larsxschneider, sbeller,
	mhagger, max, Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 t/t2029-worktree-config.sh (new +x) | 82 +++++++++++++++++++++++++++++++++++++
 1 file changed, 82 insertions(+)
 create mode 100755 t/t2029-worktree-config.sh

diff --git a/t/t2029-worktree-config.sh b/t/t2029-worktree-config.sh
new file mode 100755
index 0000000..4ebdf13
--- /dev/null
+++ b/t/t2029-worktree-config.sh
@@ -0,0 +1,82 @@
+#!/bin/sh
+
+test_description="config file in multi worktree"
+
+. ./test-lib.sh
+
+cmp_config() {
+	if [ "$1" = "-C" ]; then
+		shift &&
+		GD="-C $1" &&
+		shift
+	else
+		GD=
+	fi &&
+	echo "$1" >expected &&
+	shift &&
+	git $GD config "$@" >actual &&
+	test_cmp expected actual
+}
+
+test_expect_success 'setup' '
+	test_commit start &&
+	git config --worktree per.worktree is-ok &&
+	git worktree add wt1 &&
+	git worktree add wt2 &&
+	git config --worktree per.worktree is-ok &&
+	cmp_config true extensions.worktreeConfig
+'
+
+test_expect_success 'config is shared as before' '
+	git config this.is shared &&
+	cmp_config shared this.is &&
+	cmp_config -C wt1 shared this.is &&
+	cmp_config -C wt2 shared this.is
+'
+
+test_expect_success 'config is shared (set from another worktree)' '
+	git -C wt1 config that.is also-shared &&
+	cmp_config also-shared that.is &&
+	cmp_config -C wt1 also-shared that.is &&
+	cmp_config -C wt2 also-shared that.is
+'
+
+test_expect_success 'config private to main worktree' '
+	git config --worktree this.is for-main &&
+	cmp_config for-main this.is &&
+	cmp_config -C wt1 shared this.is &&
+	cmp_config -C wt2 shared this.is
+'
+
+test_expect_success 'config private to linked worktree' '
+	git -C wt1 config --worktree this.is for-wt1 &&
+	cmp_config for-main this.is &&
+	cmp_config -C wt1 for-wt1 this.is &&
+	cmp_config -C wt2 shared this.is
+'
+
+test_expect_success 'core.bare no longer for main only' '
+	git config core.bare true &&
+	cmp_config true core.bare &&
+	cmp_config -C wt1 true core.bare &&
+	cmp_config -C wt2 true core.bare &&
+	git config --unset core.bare
+'
+
+test_expect_success 'config.worktree no longer read without extension' '
+	git config --unset extensions.worktreeConfig &&
+	cmp_config shared this.is &&
+	cmp_config -C wt1 shared this.is &&
+	cmp_config -C wt2 shared this.is
+'
+
+test_expect_success 'config --worktree migrate core.bare and core.worktree' '
+	git config core.bare true &&
+	git config --worktree foo.bar true &&
+	cmp_config true extensions.worktreeConfig &&
+	cmp_config true foo.bar &&
+	cmp_config true core.bare &&
+	! git -C wt1 config core.bare
+'
+
+test_done
-- 
2.8.2.524.g6ff3d78


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

* [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  2017-01-10 11:25 ` [PATCH v5 4/4] t2029: add tests for per-worktree config Nguyễn Thái Ngọc Duy
@ 2017-01-10 11:33 ` Nguyễn Thái Ngọc Duy
  2017-01-12 23:08   ` Junio C Hamano
  2017-01-10 11:41 ` [PATCH v5 0/4] Per-worktree config file support Duy Nguyen
  2017-01-10 17:01 ` Stefan Beller
  6 siblings, 1 reply; 13+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2017-01-10 11:33 UTC (permalink / raw)
  To: git; +Cc: Nguyễn Thái Ngọc Duy

When core.bare was added, time was simpler, we only had one worktree
associated to one repository. The situation gets a bit complicated when
multiple worktrees are added. If core.bare is set in the per-repo config
file, should all worktrees see this variable?

Since core.bare affects worktree-related commands (e.g. you are not
supposed to run "git status" when core.bare is true because no worktree
is supposed to link to the repository), when multi worktree is added,
core.bare is evaluated true by the main worktree only. Other worktrees
simply do not see core.bare even if it's there.

With per-worktree configuration in place, core.bare is moved to main
worktree's private config file. But it does not really make sense
because this is about _repository_. Instead we could leave core.bare in
the per-repo config and change/extend its definition from:

   If true this repository is assumed to be 'bare' and has no working
   directory associated with it.

to

   If true this repository is assumed to be 'bare' and has no _main_
   working directory associated with it.

In other words, linked worktrees are not covered by core.bare. This
definition is the same as before when it comes to single worktree setup.

A plus of this definition is, it allows a setup where we only have
linked worktrees (e.g. core.bare set to true, and the main repo is
tucked somewhere safe), which makes all worktrees equal again because
"the special one" is gone.

This patch is incomplete. I need to go through all is_bare_repository()
calls and adjust their behavior. But I wanted to run the idea through
the community first..

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/config.txt       | 2 +-
 Documentation/git-worktree.txt | 7 +++----
 t/t2029-worktree-config.sh     | 4 ++--
 worktree.c                     | 6 ------
 4 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index c508386..ff146be 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -484,7 +484,7 @@ core.preferSymlinkRefs::
 	expect HEAD to be a symbolic link.
 
 core.bare::
-	If true this repository is assumed to be 'bare' and has no
+	If true this repository is assumed to be 'bare' and has no main
 	working directory associated with it.  If this is the case a
 	number of commands that require a working directory will be
 	disabled, such as linkgit:git-add[1] or linkgit:git-merge[1].
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index f5aad0a..a331d0a 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -161,7 +161,7 @@ them to the `config.worktree` of the main working directory. You may
 also take this opportunity to move other configuration that you do not
 want to share to all working directories:
 
- - `core.worktree` and `core.bare` should never be shared
+ - `core.worktree` should never be shared
 
  - `core.sparseCheckout` is recommended per working directory, unless
    you are sure you always use sparse checkout for all working
@@ -169,9 +169,8 @@ want to share to all working directories:
 
 When `git config --worktree` is used to set a configuration variable
 in multiple working directory setup, `extensions.worktreeConfig` will
-be automatically set. The two variables `core.worktree` and
-`core.bare` if present will be moved to `config.worktree` of the main
-working tree.
+be automatically set. The variable `core.worktree` if present will be
+moved to `config.worktree` of the main working tree.
 
 DETAILS
 -------
diff --git a/t/t2029-worktree-config.sh b/t/t2029-worktree-config.sh
index 4ebdf13..dc84c94 100755
--- a/t/t2029-worktree-config.sh
+++ b/t/t2029-worktree-config.sh
@@ -70,13 +70,13 @@ test_expect_success 'config.worktree no longer read without extension' '
 	cmp_config -C wt2 shared this.is
 '
 
-test_expect_success 'config --worktree migrate core.bare and core.worktree' '
+test_expect_success 'config --worktree migrate core.worktree' '
 	git config core.bare true &&
 	git config --worktree foo.bar true &&
 	cmp_config true extensions.worktreeConfig &&
 	cmp_config true foo.bar &&
 	cmp_config true core.bare &&
-	! git -C wt1 config core.bare
+	cmp_config -C wt1 true core.bare
 '
 
 test_done
diff --git a/worktree.c b/worktree.c
index d8c9d85..c07cc50 100644
--- a/worktree.c
+++ b/worktree.c
@@ -395,12 +395,6 @@ void migrate_worktree_config(void)
 	read_repository_format(&format, main_path.buf);
 	assert(format.worktree_config == 0);
 
-	if (format.is_bare >= 0) {
-		git_config_set_in_file(worktree_path.buf,
-				       "core.bare", "true");
-		git_config_set_in_file(main_path.buf,
-				       "core.bare", NULL);
-	}
 	if (format.work_tree) {
 		git_config_set_in_file(worktree_path.buf,
 				       "core.worktree",
-- 
2.8.2.524.g6ff3d78


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

* Re: [PATCH v5 0/4] Per-worktree config file support
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  2017-01-10 11:33 ` [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting Nguyễn Thái Ngọc Duy
@ 2017-01-10 11:41 ` Duy Nguyen
  2017-01-10 17:01 ` Stefan Beller
  6 siblings, 0 replies; 13+ messages in thread
From: Duy Nguyen @ 2017-01-10 11:41 UTC (permalink / raw)
  To: Git Mailing List
  Cc: Junio C Hamano, Michael J Gruber, Jens Lehmann, Lars Schneider,
	Stefan Beller, Michael Haggerty, Max Kirillov,
	Nguyễn Thái Ngọc Duy

On Tue, Jan 10, 2017 at 6:25 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> Not much has changed from v4, except that the migration to new config
> layout is done automatically _update_ a config variable with "git
> config --worktree".

I accidentally two words that may make it hard to understand this
sentence. It should be "... is done automatically when you update.."
-- 
Duy

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

* Re: [PATCH v5 2/4] config: --worktree for manipulating per-worktree config file
  2017-01-10 11:25 ` [PATCH v5 2/4] config: --worktree for manipulating per-worktree config file Nguyễn Thái Ngọc Duy
@ 2017-01-10 16:52   ` Stefan Beller
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Beller @ 2017-01-10 16:52 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git@vger.kernel.org, Junio C Hamano, Michael J Gruber,
	Jens Lehmann, Lars Schneider, Michael Haggerty, Max Kirillov

> +               if (repository_format_worktree_config)
> +                       given_config_source.file = git_pathdup("config.worktree");
> +               else if (worktrees[0] && worktrees[1]) {
> +                       die("BUG: migration is not supported yet");
> +               } else
> +                       given_config_source.file = git_pathdup("config");

nit: inconsistent use uf braces for single statements here.
I mean the braces are needed in the BUG case, as otherwise we'd
have a dangling else, but then you could put the brace in the else case as well.
This nit doesn't warrant a reroll on its own.

> +               free_worktrees(worktrees);
> +       } else if (given_config_source.file) {
>                 if (!is_absolute_path(given_config_source.file) && prefix)
>                         given_config_source.file =
>                                 xstrdup(prefix_filename(prefix,
> --
> 2.8.2.524.g6ff3d78
>

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

* Re: [PATCH v5 0/4] Per-worktree config file support
  2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  2017-01-10 11:41 ` [PATCH v5 0/4] Per-worktree config file support Duy Nguyen
@ 2017-01-10 17:01 ` Stefan Beller
  2017-01-19 12:09   ` Duy Nguyen
  6 siblings, 1 reply; 13+ messages in thread
From: Stefan Beller @ 2017-01-10 17:01 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy
  Cc: git@vger.kernel.org, Junio C Hamano, Michael J Gruber,
	Jens Lehmann, Lars Schneider, Michael Haggerty, Max Kirillov

On Tue, Jan 10, 2017 at 3:25 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> Let's get this rolling again. To refresh your memory because it's half
> a year since v4 [1], this is about letting each worktree in multi
> worktree setup has their own config settings. The most prominent ones
> are core.worktree, used by submodules, and core.sparseCheckout.

Thanks for getting this rolling again.

>
> This time I'm not touching submodules at all. I'm leaving it in the
> good hands of "submodule people". All I'm providing is mechanism. How
> you use it is up to you. So the series benefits sparse checkout users
> only.

As one of the "submodule people", I have no complaints here.

>
> Not much has changed from v4, except that the migration to new config
> layout is done automatically _update_ a config variable with "git
> config --worktree".
>
> I think this one is more or less ready. I have an RFC follow-up patch
> about core.bare, but that could be handled separately.

I have read through the series and think the design is sound for worktrees
(though I have little knowledge about them).

---
Now even further:

So to build on top of this series, I'd like to make submodules usable
with worktrees (i.e. shared object store, only clone/fetch once and
all worktrees
benefit from it), the big question is how to get the underlying data
model right.

Would a submodule go into the superprojects

    .git/worktrees/<worktree-name>/modules/<submodule-name>/

or rather

    .git/modules<submodule-name>/worktrees/<worktree-name>

Or both (one of them being a gitlink file pointing at the other?)

I have not made up my mind, as I haven't laid out all cases that are
relevant here.

Thanks,
Stefan


>
> [1] http://public-inbox.org/git/20160720172419.25473-1-pclouds@gmail.com/
>
> Nguyễn Thái Ngọc Duy (4):
>   config: read per-worktree config files
>   config: --worktree for manipulating per-worktree config file
>   config: automatically migrate to new config layout when --worktree is used
>   t2029: add tests for per-worktree config
>
>  Documentation/config.txt               | 11 ++++-
>  Documentation/git-config.txt           | 26 ++++++++---
>  Documentation/git-worktree.txt         | 37 +++++++++++++++
>  Documentation/gitrepository-layout.txt |  8 ++++
>  builtin/config.c                       | 16 ++++++-
>  cache.h                                |  2 +
>  config.c                               |  7 +++
>  environment.c                          |  1 +
>  setup.c                                |  5 ++-
>  t/t2029-worktree-config.sh (new +x)    | 82 ++++++++++++++++++++++++++++++++++
>  worktree.c                             | 40 +++++++++++++++++
>  worktree.h                             |  6 +++
>  12 files changed, 230 insertions(+), 11 deletions(-)
>  create mode 100755 t/t2029-worktree-config.sh
>
> --
> 2.8.2.524.g6ff3d78
>

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

* Re: [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting
  2017-01-10 11:33 ` [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting Nguyễn Thái Ngọc Duy
@ 2017-01-12 23:08   ` Junio C Hamano
  2017-01-19 12:02     ` Duy Nguyen
  0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2017-01-12 23:08 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> With per-worktree configuration in place, core.bare is moved to main
> worktree's private config file. But it does not really make sense
> because this is about _repository_. Instead we could leave core.bare in
> the per-repo config and change/extend its definition from:
>
>    If true this repository is assumed to be 'bare' and has no working
>    directory associated with it.
>
> to
>
>    If true this repository is assumed to be 'bare' and has no _main_
>    working directory associated with it.
>
> In other words, linked worktrees are not covered by core.bare. This
> definition is the same as before when it comes to single worktree setup.

Up to this point, I think it is not _wrong_ per-se, but it does not
say anything about secondary worktrees.  Some may have their own
working tree, others may be bare, and there is no way for programs
to discover if a particular secondary worktree has or lacks its own
working tree.

Granted, "git worktree" porcelain may be incapable of creating a
secondary worktree without a working tree, but I think the
underlying repository layout still is capable of expressing such a
secondary worktree.

So there still is something else necessary, I suspect, to make the
definition complete.  Perhaps core.bare should be set in
per-worktree configuration for all worktrees including the primary
one, and made the definition/explanation of core.bare to be
"definition of this variable, if done, must be done in per-worktree
config file.  If set to true, the worktree is 'bare' and has no
working directory associated with it"?  That makes things even more
equal, as there is truly no "special one" at that point.

I dunno.

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

* Re: [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting
  2017-01-12 23:08   ` Junio C Hamano
@ 2017-01-19 12:02     ` Duy Nguyen
  0 siblings, 0 replies; 13+ messages in thread
From: Duy Nguyen @ 2017-01-19 12:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

Thanks. I'll shelve this for now, maybe sleep on it for a while. The
series is complete without this patch by the way, if you want to pick
it up.

On Fri, Jan 13, 2017 at 6:08 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> With per-worktree configuration in place, core.bare is moved to main
>> worktree's private config file. But it does not really make sense
>> because this is about _repository_. Instead we could leave core.bare in
>> the per-repo config and change/extend its definition from:
>>
>>    If true this repository is assumed to be 'bare' and has no working
>>    directory associated with it.
>>
>> to
>>
>>    If true this repository is assumed to be 'bare' and has no _main_
>>    working directory associated with it.
>>
>> In other words, linked worktrees are not covered by core.bare. This
>> definition is the same as before when it comes to single worktree setup.
>
> Up to this point, I think it is not _wrong_ per-se, but it does not
> say anything about secondary worktrees.  Some may have their own
> working tree, others may be bare, and there is no way for programs
> to discover if a particular secondary worktree has or lacks its own
> working tree.
>
> Granted, "git worktree" porcelain may be incapable of creating a
> secondary worktree without a working tree, but I think the
> underlying repository layout still is capable of expressing such a
> secondary worktree.
>
> So there still is something else necessary, I suspect, to make the
> definition complete.  Perhaps core.bare should be set in
> per-worktree configuration for all worktrees including the primary
> one, and made the definition/explanation of core.bare to be
> "definition of this variable, if done, must be done in per-worktree
> config file.  If set to true, the worktree is 'bare' and has no
> working directory associated with it"?  That makes things even more
> equal, as there is truly no "special one" at that point.
>
> I dunno.



-- 
Duy

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

* Re: [PATCH v5 0/4] Per-worktree config file support
  2017-01-10 17:01 ` Stefan Beller
@ 2017-01-19 12:09   ` Duy Nguyen
  2017-01-19 20:03     ` Stefan Beller
  0 siblings, 1 reply; 13+ messages in thread
From: Duy Nguyen @ 2017-01-19 12:09 UTC (permalink / raw)
  To: Stefan Beller
  Cc: git@vger.kernel.org, Junio C Hamano, Michael J Gruber,
	Jens Lehmann, Lars Schneider, Michael Haggerty, Max Kirillov

On Wed, Jan 11, 2017 at 12:01 AM, Stefan Beller <sbeller@google.com> wrote:
> On Tue, Jan 10, 2017 at 3:25 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> Let's get this rolling again. To refresh your memory because it's half
>> a year since v4 [1], this is about letting each worktree in multi
>> worktree setup has their own config settings. The most prominent ones
>> are core.worktree, used by submodules, and core.sparseCheckout.
>
> Thanks for getting this rolling again.
>
>>
>> This time I'm not touching submodules at all. I'm leaving it in the
>> good hands of "submodule people". All I'm providing is mechanism. How
>> you use it is up to you. So the series benefits sparse checkout users
>> only.
>
> As one of the "submodule people", I have no complaints here.
>
>>
>> Not much has changed from v4, except that the migration to new config
>> layout is done automatically _update_ a config variable with "git
>> config --worktree".
>>
>> I think this one is more or less ready. I have an RFC follow-up patch
>> about core.bare, but that could be handled separately.
>
> I have read through the series and think the design is sound for worktrees
> (though I have little knowledge about them).

Submodules and multi worktrees start to look very similar, the more I
think about it. Well, except that multi worktree does not separate odb
and config files, maybe. And we have already seen both have a need to
share code (like the moving .git dir operation). I suspect I'll learn
more about submodules along the way, and you worktrees ;-)

> Now even further:
>
> So to build on top of this series, I'd like to make submodules usable
> with worktrees (i.e. shared object store, only clone/fetch once and
> all worktrees
> benefit from it), the big question is how to get the underlying data
> model right.
>
> Would a submodule go into the superprojects
>
>     .git/worktrees/<worktree-name>/modules/<submodule-name>/
>
> or rather
>
>     .git/modules<submodule-name>/worktrees/<worktree-name>
>
> Or both (one of them being a gitlink file pointing at the other?)
>
> I have not made up my mind, as I haven't laid out all cases that are
> relevant here.

I would go with a conservative step first, keep submodules
per-worktree. After it's sorted out. You can change the layout (e.g.
as a config extension). The latter probably has some complication (but
yeah sharing would be a big plus).
-- 
Duy

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

* Re: [PATCH v5 0/4] Per-worktree config file support
  2017-01-19 12:09   ` Duy Nguyen
@ 2017-01-19 20:03     ` Stefan Beller
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Beller @ 2017-01-19 20:03 UTC (permalink / raw)
  To: Duy Nguyen
  Cc: git@vger.kernel.org, Junio C Hamano, Michael J Gruber,
	Jens Lehmann, Lars Schneider, Michael Haggerty, Max Kirillov

On Thu, Jan 19, 2017 at 4:09 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> On Wed, Jan 11, 2017 at 12:01 AM, Stefan Beller <sbeller@google.com> wrote:
>> On Tue, Jan 10, 2017 at 3:25 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>>> Let's get this rolling again. To refresh your memory because it's half
>>> a year since v4 [1], this is about letting each worktree in multi
>>> worktree setup has their own config settings. The most prominent ones
>>> are core.worktree, used by submodules, and core.sparseCheckout.
>>
>> Thanks for getting this rolling again.
>>
>>>
>>> This time I'm not touching submodules at all. I'm leaving it in the
>>> good hands of "submodule people". All I'm providing is mechanism. How
>>> you use it is up to you. So the series benefits sparse checkout users
>>> only.
>>
>> As one of the "submodule people", I have no complaints here.
>>
>>>
>>> Not much has changed from v4, except that the migration to new config
>>> layout is done automatically _update_ a config variable with "git
>>> config --worktree".
>>>
>>> I think this one is more or less ready. I have an RFC follow-up patch
>>> about core.bare, but that could be handled separately.
>>
>> I have read through the series and think the design is sound for worktrees
>> (though I have little knowledge about them).
>
> Submodules and multi worktrees start to look very similar, the more I
> think about it. Well, except that multi worktree does not separate odb
> and config files, maybe.

Similar to worktrees submodules can appear and disappear without
affecting the project/main tree. (though the mechanism is different,
for submodules, you'd checkout a version that doesn't have the submodule,
whereas for worktrees the user explicitely says: "I don't want to see this
worktree any more")

> And we have already seen both have a need to
> share code (like the moving .git dir operation). I suspect I'll learn
> more about submodules along the way, and you worktrees ;-)

I sure hope so.

>
>> Now even further:
>>
>> So to build on top of this series, I'd like to make submodules usable
>> with worktrees (i.e. shared object store, only clone/fetch once and
>> all worktrees
>> benefit from it), the big question is how to get the underlying data
>> model right.
>>
>> Would a submodule go into the superprojects
>>
>>     .git/worktrees/<worktree-name>/modules/<submodule-name>/
>>
>> or rather
>>
>>     .git/modules<submodule-name>/worktrees/<worktree-name>
>>
>> Or both (one of them being a gitlink file pointing at the other?)
>>
>> I have not made up my mind, as I haven't laid out all cases that are
>> relevant here.
>
> I would go with a conservative step first, keep submodules
> per-worktree. After it's sorted out. You can change the layout (e.g.
> as a config extension). The latter probably has some complication (but
> yeah sharing would be a big plus).

The sharing is what we are asked for as it would "make
submodules usable" (compared to the repo tool, which
doesn't have object sharing AFAIK). ;)

Currently I am leaning to put the worktree directory first and the
submodules within, i.e.

.git/worktrees/<worktree-name>/modules/<submodule-name>/

but in that directory, we'd only have the per-worktree
specific stuff, the object store would live with the superprojects
main worktree, i.e. at .git/modules/<submodule-name> we'd have
the main git dir for the submodule.

Thanks,
Stefan

> --
> Duy

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

end of thread, other threads:[~2017-01-19 20:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-10 11:25 [PATCH v5 0/4] Per-worktree config file support Nguyễn Thái Ngọc Duy
2017-01-10 11:25 ` [PATCH v5 1/4] config: read per-worktree config files Nguyễn Thái Ngọc Duy
2017-01-10 11:25 ` [PATCH v5 2/4] config: --worktree for manipulating per-worktree config file Nguyễn Thái Ngọc Duy
2017-01-10 16:52   ` Stefan Beller
2017-01-10 11:25 ` [PATCH v5 3/4] config: automatically migrate to new config layout when --worktree is used Nguyễn Thái Ngọc Duy
2017-01-10 11:25 ` [PATCH v5 4/4] t2029: add tests for per-worktree config Nguyễn Thái Ngọc Duy
2017-01-10 11:33 ` [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting Nguyễn Thái Ngọc Duy
2017-01-12 23:08   ` Junio C Hamano
2017-01-19 12:02     ` Duy Nguyen
2017-01-10 11:41 ` [PATCH v5 0/4] Per-worktree config file support Duy Nguyen
2017-01-10 17:01 ` Stefan Beller
2017-01-19 12:09   ` Duy Nguyen
2017-01-19 20:03     ` Stefan Beller

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

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

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