Re: contrib/workdir/git-new-workdir broken in 1.7.10 after introducing gitfiles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> As you analyzed correctly, core.worktree lets a GIT_DIR to declare that
> there is a single working tree associated with it. It fundamentally is
> incompatible with new-workdir, which is a hack to let more than one
> working tree associated with a single GIT_DIR.
>
> I however do not think a simplistic "unset core.worktree" is a good
> suggestion, though, as we do not know why the original repository has
> that variable set pointing at somewhere.  Blindly removing it will break
> the use of the original repository.  If somebody _really_ wants to use
> new-workdir for whatever reason in such a setting, I would imagine that
> doing something like this:
> ...
> may work.

I am too lazy to try it out myself, but a hack something along the line
of the attached patch _might_ turn out to work well.

At least, it gives an incentive to people to update to more recent
versions of git ;-)  I dunno.

-- >8 --
Subject: new-workdir: use its own config file

Instead of letting a new workdir share the same config, we simply
include the original config and override core.worktree in it.  This
obviously changes the behaviour from the traditional workdir, by making
any update to the config in a workdir private to that workdir and not
reflected back to the original repository.  Because a workdir is
supposed to be just a peek only window to check out a branch that is
different from the main working tree, and you are not expected to modify
the config file in any way (e.g. you do not create a new branch with
remote configuration in a workdir), it may not be a huge issue.

Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
---
 contrib/workdir/git-new-workdir |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/contrib/workdir/git-new-workdir b/contrib/workdir/git-new-workdir
index 75e8b25..1d49258 100755
--- a/contrib/workdir/git-new-workdir
+++ b/contrib/workdir/git-new-workdir
@@ -63,7 +63,7 @@ mkdir -p "$new_workdir/.git" || die "unable to create \"$new_workdir\"!"
 # create the links to the original repo.  explicitly exclude index, HEAD and
 # logs/HEAD from the list since they are purely related to the current working
 # directory, and should not be shared.
-for x in config refs logs/refs objects info hooks packed-refs remotes rr-cache svn
+for x in refs logs/refs objects info hooks packed-refs remotes rr-cache svn
 do
 	case $x in
 	*/*)
@@ -77,6 +77,12 @@ done
 cd "$new_workdir"
 # copy the HEAD from the original repository as a default branch
 cp "$git_dir/HEAD" .git/HEAD
+cat >".git/config" <<EOF
+[include]
+	path = "$git_dir/config"
+[core]
+	worktree = "$(pwd)"
+EOF
 # checkout the branch (either the same as HEAD from the original repository, or
 # the one that was asked for)
 git checkout -f $branch



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]