Subject: Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set

From: Junio C Hamano <[email-masked]>
Date: Mon, 12 Mar 2007 10:31:26 -0700

Matthias Lederhofer <[email-masked]> writes:

> ... because
> $GIT_WORK_DIR is normally interpreted as relative path to the current
> working directory and not relative to $GIT_DIR.

Well, it could be that _that_ handling of the environment
variable is what needs to be fixed.

If you are using $GIT_DIR, you are working in a subdirectory,
say, Documentation/, and you are using a relative path to
specify GIT_WORK_DIR, then you would need to do this, right?

	$ GIT_DIR=/src/git/git.git ;# top of repository
        $ export GIT_DIR
        $ cd /work/git/git.git ;# go to top of working tree
	$ cd Documentation ;# I want to work in here...

        $ GIT_WORK_DIR=.. ;# toplevel is .. relative to here
        $ export GIT_WORK_DIR
        $ hack hack ; git commit

        $ cd .. ;# Now I want to update the toplevel
        $ GIT_WORK_DIR=. ;# oops I need to update this env
	$ hack hack ; git commit

        $ cd t ;# Now to testcase
        $ GIT_WORK_DIR=.. ;# oops again

If $GIT_WORK_DIR is given absolute you do not have to worry
about this problem, but if you allow giving relative path, it
seems to me that it would be more useful to make it relative to
GIT_DIR.  Then you would need to set it just once, at the same
time when you set and export GIT_DIR, and keep working in that
working tree.

The same goes for $GIT_DIR/workdir.