git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jens Lehmann <Jens.Lehmann@web.de>
To: Antonin Hildebrand <antonin@hildebrand.cz>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: contrib/workdir/git-new-workdir broken in 1.7.10 after introducing gitfiles
Date: Sat, 21 Apr 2012 20:45:23 +0200	[thread overview]
Message-ID: <4F930043.1080506@web.de> (raw)
In-Reply-To: <CAHsq6J6JOTYfEtK0Z=_qfMFf9N1DWQ4zx46YhBbNu-1gEMyfog@mail.gmail.com>

Am 20.04.2012 22:16, schrieb Antonin Hildebrand:
> Hi there,
> 
> I'm just solving same problem as described here in the question:
> http://stackoverflow.com/questions/4115817/duplicate-submodules-with-git
> 
> I wanted to try proposed solution, but git-new-workdir does not work
> in latest release 1.7.10.
> 
> The problem are plaintext .git files pointing to the root
> "superproject" .git directory. The script has not been updated to deal
> with this new situation.

The problem is not the gitfile, but the core.worktree setting. And
I don't see how that script can be updated to deal with the new
situation. Since 1.7.8 the core.worktree setting is used to point
from the submodules .git directory to its work tree. And as
git-new-worktree just links the config file, it inherits the
core.worktree setting too, so that will always point to the first
work tree even when in the new workdir. And if git-new-worktree
would change core.worktree, the first work tree will stop working.

I'm not sure why git-new-workdir is used here anyways, the only reason
I can think of is to save some disk space. So use a regular submodule
there and everything should work for you (at the expense of having the
same object store on disk twice).

But it seems like a check is missing in the git-new-workdir script if
the core.worktree setting is used, as it will never do what it is meant
to when that is set and doesn't point to the target directory. Maybe
something like the patch below?

What I worry about is that after this change it will give users who
follow the above mentioned recipe a misleading advice, as following it
will make the first submodule stop working. But from the perspective of
git-new-workdir this change makes sense, and maybe we have to fix the
stackoverflow recipe instead ... on the other hand, problems like this
could be the avoided if we'd use the "if we reached thru a gitfile,
then the working tree is where you found that gitfile" setup logic
outlined in
http://permalink.gmane.org/gmane.comp.version-control.git/188007

Opinions?

----8<-----
Subject: [PATCH] git-new-workdir: Suggest unsetting the core.worktree setting

Linking to a repository that has the core.worktree option set can only
work when that core.worktree setting already points to the new-workdir.
In all other cases strange things will happen, as new-workdir will be
overridden by that setting.

So just die when that setting is found and tell the user why and that he
should remove it.

Reported-by: Antonin Hildebrand <antonin@hildebrand.cz>
Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
---
 contrib/workdir/git-new-workdir |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 75e8b25..90cc207 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -41,6 +41,14 @@ then
 		" remove from \"$git_dir/config\" to use $0"
 fi

+# don't link to a repository that has core.worktree defined
+coreworktree=$(git --git-dir="$git_dir" config --get core.worktree)
+if test -n "$coreworktree"
+then
+	die "\"$git_dir\" has core.worktree set to \"$coreworktree\"," \
+		" remove from \"$git_dir/config\" to use $0"
+fi
+
 # don't link to a workdir
 if test -h "$git_dir/config"
 then
-- 
1.7.10.208.gb5e6d

  reply	other threads:[~2012-04-21 18:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 20:16 contrib/workdir/git-new-workdir broken in 1.7.10 after introducing gitfiles Antonin Hildebrand
2012-04-21 18:45 ` Jens Lehmann [this message]
2012-04-21 19:51   ` Junio C Hamano
2012-04-22  3:56     ` Antonin Hildebrand
2012-04-22  4:41     ` Junio C Hamano
2012-04-22 18:32       ` Jens Lehmann
2012-04-22 18:58       ` Mark Levedahl

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

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

  git send-email \
    --in-reply-to=4F930043.1080506@web.de \
    --to=jens.lehmann@web.de \
    --cc=antonin@hildebrand.cz \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
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 NNTP newsgroup(s).