git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
To: git@vger.kernel.org
Cc: "Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>
Subject: [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting
Date: Tue, 10 Jan 2017 18:33:20 +0700	[thread overview]
Message-ID: <20170110113320.13119-1-pclouds@gmail.com> (raw)
In-Reply-To: <20170110112524.12870-1-pclouds@gmail.com>

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


  parent reply	other threads:[~2017-01-10 11:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Nguyễn Thái Ngọc Duy [this message]
2017-01-12 23:08   ` [PATCH/RFC 5/4] Redefine core.bare in multiple working tree setting 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170110113320.13119-1-pclouds@gmail.com \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).