Subject: Re: [RFC] introduce GIT_WORK_DIR environment variable

From: Matthias Lederhofer <[email-masked]>
Date: Sun, 11 Mar 2007 17:22:01 +0100

Junio C Hamano <[email-masked]> wrote:
> Matthias Lederhofer <[email-masked]> writes:
> > Idea:
> > Add some way to configure tho working directory for one repository
> > and set GIT_WORK_DIR automatically when GIT_DIR is used.  I think of:
> >  * a subdirectory in the repository directory
> >    e.g. .git/work_dir which is supposed to be a symlink (or a textfile
> >    containing the path for windows compatibility?)
> > or
> >  * a configuration variable
> 
> I am not sure why you bother.  Obviously I am missing a few
> useful use cases you and Nguyen have in mind.

For example have the checkout of a git repository publicly available
(e.g. on a webserver).  The .git directory containing all the history
should probably not go there (especially if it tracks scripts).  Sure,
setting strict permissions solves this too in most cases but anyway
it's nice to have the option to move the repository away.

Additionally when reading the man page about GIT_DIR it says 'the
default value is .git', which sounds a bit like "hey, if you don't
like the name you're free to change it", but as soon as you change it
you run into problems because git behaves strange in subdirectories :)

> But either .git/work_dir or a configuration means you are
> linking a repository with a _single_ working tree, permanently.

Well, this would only be the default value for convenience with
GIT_WORK_DIR/--work-dir still overriding this value.  You'd only have
to set GIT_DIR=~/src/website and work on the website without setting
the second environment variable too.

> I've heard read-only working tree in the past, but that cannot
> be it.  If the working tree is read-only and if you are telling
> git to always use that read-only working tree when using that
> particular repository, what useful git operations are you doing
> while in that working tree?

The tools to inspect (git diff, ..) and track (git add, ..) work fine.
So one could easily (without copying stuff around) track changes of a
read-only directory.