git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: worley@alum.mit.edu (Dale R. Worley)
Cc: git@vger.kernel.org
Subject: Re: [git-users] Problem using detached worktrees with commands implemented in scripts
Date: Thu, 17 Oct 2013 13:08:20 -0700	[thread overview]
Message-ID: <xmqq4n8fzmmj.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <201310171909.r9HJ9mxd007908@freeze.ariadne.com> (Dale R. Worley's message of "Thu, 17 Oct 2013 15:09:48 -0400")

worley@alum.mit.edu (Dale R. Worley) writes:

> I must admit I've never seen the design (and I personally doubt that
> the design has ever been written down).  But at least the following
> commands work correctly on a detached worktree if the current
> directory contains the .git directory, because I am using them in a
> production manner:
>
>     git add

If you have this:

	/repositories/proj.git/{refs,objects,...}
	/working/trees/proj-wt1/

where proj-wt1 is a working tree for that proj.git repository, the
idea was to set these:

	GIT_DIR=/repositories/proj.git
        GIT_WORK_TREE=/working/trees/proj-wt1
        export GIT_DIR GIT_WORK_TREE

and then working in /working/trees/proj-wt1 or any of its
subdirectory should work as if you did not have these two
environment variables and had /working/trees/proj-wt1/.git instead
of /repositories/proj.git as the repository.  To make that use case
work was the motivation behind these environment variables.

	Side note: without GIT_WORK_TREE environment (or
	core.worktree), there is no way to tell where the top level
	is, so you were limited to always be at the top level of
	your working tree if you used GIT_DIR to refer to a
	repository that is not embedded in your working tree.  There
	were some changes in this area, but I do not recall the
	details offhand.

Now, when you say "the cwd contains the .git directory", do you mean

	cd /repositories
        git add ../working/trees/proj-wt1/file

updates "file" in the /repositories/proj.git/index?  Or do you mean
this?

	cd /repositories/proj.git
        git add ../../working/trees/proj-wt1/file

Or this?

	cd /repositories
	edit ../working/trees/proj-wt1/file
	git add file

Most of the commands you listed do not need to look at the actual
working tree files, so I would expect e.g. "git log" or "git log
paths..." to work but I am wondering what your definition of "works"
with respect to the pathspecs, especially when you talk about
starting Git command _outside_ the working tree (whether the working
tree has its repository embedded in it is not very relevant).

  reply	other threads:[~2013-10-17 20:08 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 20:03 [git-users] Problem using detached worktrees with commands implemented in scripts Dale R. Worley
2013-10-16 21:42 ` Junio C Hamano
2013-10-16 22:39   ` Philip Oakley
2013-10-16 23:08     ` Junio C Hamano
2013-10-17 20:11       ` Philip Oakley
2013-10-17 20:50         ` Junio C Hamano
2013-10-17 21:14           ` Philip Oakley
2013-10-17 22:38             ` Philip Oakley
2013-10-17 22:48               ` Jonathan Nieder
2013-10-18 20:40                 ` Philip Oakley
2013-10-18 22:54           ` Dale R. Worley
2013-10-17 19:09   ` Dale R. Worley
2013-10-17 20:08     ` Junio C Hamano [this message]
2013-10-18 22:25       ` Dale R. Worley
2013-10-18 22:43         ` Junio C Hamano
2013-10-21 18:51           ` Dale R. Worley
2013-10-18 22:50       ` Dale R. Worley

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=xmqq4n8fzmmj.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=worley@alum.mit.edu \
    /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).