All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC] introduce GIT_WORK_DIR environment variable
@ 2007-03-11  4:32 Matthias Lederhofer
  2007-03-11  5:34 ` Junio C Hamano
                   ` (3 more replies)
  0 siblings, 4 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11  4:32 UTC (permalink / raw)
  To: git, Nguyen Thai Ngoc Duy

This environment variable can be used with GIT_DIR to
specify the toplevel working directory.  When GIT_DIR is not
set this variable is ignored.  As for GIT_DIR there is also
the option git --work-dir which overrides the environment
variable.
---
Missing:
Documentation update but if this feature should not get accepted..
therefore I'll wait for feedback first.

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

Considerations:
Without running setup_git_directory_gently is_bare_repository and
is_inside_git_dir may return wrong values.  Except for cmd_init_db I
found no place calling on of the functions without calling
setup_git_directory_gently before.

To do:
git init should probably set bare = false when GIT_WORK_DIR is
exported.  And if the idea about configurable working directories gets
implemented it could also set this option accordingly.

---
 cache.h       |    2 +
 environment.c |    2 +
 git.c         |   12 +++++++++-
 setup.c       |   70 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 4 files changed, 80 insertions(+), 6 deletions(-)

diff --git a/cache.h b/cache.h
index ae25759..042734c 100644
--- a/cache.h
+++ b/cache.h
@@ -144,6 +144,7 @@ enum object_type {
 };
 
 #define GIT_DIR_ENVIRONMENT "GIT_DIR"
+#define GIT_WORKING_DIR_ENVIRONMENT "GIT_WORK_DIR"
 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
@@ -164,6 +165,7 @@ extern char *get_graft_file(void);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
+extern int has_working_directory;
 extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
diff --git a/environment.c b/environment.c
index 0151ad0..5c30c9b 100644
--- a/environment.c
+++ b/environment.c
@@ -61,6 +61,8 @@ int is_bare_repository(void)
 	const char *dir, *s;
 	if (0 <= is_bare_repository_cfg)
 		return is_bare_repository_cfg;
+	if (0 <= has_working_directory)
+		return !has_working_directory;
 
 	dir = get_git_dir();
 	if (!strcmp(dir, DEFAULT_GIT_DIR_ENVIRONMENT))
diff --git a/git.c b/git.c
index 04fc99a..3cf7ce2 100644
--- a/git.c
+++ b/git.c
@@ -4,7 +4,7 @@
 #include "quote.h"
 
 const char git_usage_string[] =
-	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--work-dir=GIT_WORK_DIR] [--help] COMMAND [ARGS]";
 
 static void prepend_to_path(const char *dir, int len)
 {
@@ -68,6 +68,16 @@ static int handle_options(const char*** argv, int* argc)
 			(*argc)--;
 		} else if (!prefixcmp(cmd, "--git-dir=")) {
 			setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
+		} else if (!strcmp(cmd, "--work-dir")) {
+			if (*argc < 2) {
+				fprintf(stderr, "No directory given for --work-dir.\n" );
+				usage(git_usage_string);
+			}
+			setenv(GIT_WORKING_DIR_ENVIRONMENT, (*argv)[1], 1);
+			(*argv)++;
+			(*argc)--;
+		} else if (!prefixcmp(cmd, "--work-dir=")) {
+			setenv(GIT_WORKING_DIR_ENVIRONMENT, cmd + 11, 1);
 		} else if (!strcmp(cmd, "--bare")) {
 			static char git_dir[PATH_MAX+1];
 			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
diff --git a/setup.c b/setup.c
index dda67d2..7f5d73b 100644
--- a/setup.c
+++ b/setup.c
@@ -192,6 +192,8 @@ int is_inside_git_dir(void)
 	return inside_git_dir;
 }
 
+int has_working_directory = -1;
+
 const char *setup_git_directory_gently(int *nongit_ok)
 {
 	static char cwd[PATH_MAX+1];
@@ -205,15 +207,73 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	 */
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv) {
+		struct stat st, st_work, st_git;
+		const char *gitwd;
+		char *prefix;
+		char c;
+		int len;
+
 		if (PATH_MAX - 40 < strlen(gitdirenv))
 			die("'$%s' too big", GIT_DIR_ENVIRONMENT);
-		if (is_git_directory(gitdirenv))
-			return NULL;
-		if (nongit_ok) {
-			*nongit_ok = 1;
+		if (!is_git_directory(gitdirenv)) {
+			if (nongit_ok) {
+				*nongit_ok = 1;
+				return NULL;
+			}
+			die("Not a git repository: '%s'", gitdirenv);
+		}
+
+		gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
+		if (!gitwd || stat(gitwd, &st_work))
 			return NULL;
+		if (inside_git_dir == -1 && stat(gitdirenv, &st_git))
+			die("Unable to stat git directory");
+		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		len = strlen(cwd);
+
+		prefix = cwd+len;
+		for (;;) {
+			c = *prefix;
+			*prefix = '\0';
+			if (stat(cwd, &st))
+				die("Unable to stat '%s'", cwd);
+			if (st_work.st_dev == st.st_dev &&
+			    st_work.st_ino == st.st_ino)
+				break;
+			if (inside_git_dir == -1 &&
+			    st_git.st_dev == st.st_dev &&
+			    st_git.st_ino == st.st_ino)
+				inside_git_dir = 1;
+			*prefix = c;
+
+			if (prefix == cwd+1) {
+				has_working_directory = 0;
+				return NULL;
+			}
+			while (*(--prefix) != '/')
+				; /* do nothing */
+			if (prefix == cwd)
+				prefix++;
+		}
+
+		if (chdir(cwd))
+			die("Cannot change directory to '%s'", cwd);
+
+		if (c) {
+			*prefix = c;
+			prefix++;
+			cwd[len] = '/';
+			cwd[len+1] = '\0';
+		} else {
+			prefix = NULL;
 		}
-		die("Not a git repository: '%s'", gitdirenv);
+
+		has_working_directory = 1;
+		if (inside_git_dir == -1)
+			inside_git_dir = 0;
+
+		return prefix;
 	}
 
 	if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
-- 
1.5.0.3

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11  4:32 [RFC] introduce GIT_WORK_DIR environment variable Matthias Lederhofer
@ 2007-03-11  5:34 ` Junio C Hamano
  2007-03-11  8:26   ` Andy Parkins
                     ` (2 more replies)
  2007-03-11 12:42 ` Nguyen Thai Ngoc Duy
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 39+ messages in thread
From: Junio C Hamano @ 2007-03-11  5:34 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: Nguyen Thai Ngoc Duy, git

Matthias Lederhofer <matled@gmx.net> writes:

> Missing:
> Documentation update but if this feature should not get accepted..
> therefore I'll wait for feedback first.

Did I say something about a comment like this in the past?  But
I'll let this pass this time...

> 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.

One very typical use of GIT_DIR to have the repository somewhere
other than the usual $GIT_TOP_DIR/.git is to do an initial
import from an extracted tarball into a bare repository (and
then wipe away the temporary directory that contains extracted
tarball), and that use case I understand well.

But either .git/work_dir or a configuration means you are
linking a repository with a _single_ working tree, permanently.
If you are permanently linking one repository with a _single_
working tree, is it too much bother to have that repository at
the usual $GIT_TOP_DIR/.git like everybody else?

If storage space is the issue, then doing

	$ln -s $else_where/.git .git

would be sufficient.

What's the real motivation behind all this?  

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?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11  5:34 ` Junio C Hamano
@ 2007-03-11  8:26   ` Andy Parkins
  2007-03-11 16:22   ` Matthias Lederhofer
  2007-03-11 20:37   ` Linus Torvalds
  2 siblings, 0 replies; 39+ messages in thread
From: Andy Parkins @ 2007-03-11  8:26 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Matthias Lederhofer, Nguyen Thai Ngoc Duy

On Sunday 2007, March 11, Junio C Hamano wrote:

> What's the real motivation behind all this?

Coincidentally, I found I was needing this feature just yesterday.

I wanted to keep random configuration files in a repository.  I didn't 
want the directory structure though.  The config files are, of course, 
in my home directory, however I didn't want the danger of putting 
a .git that low in my hierarchy.  Having a .git that is findable from 
any location in my tree seems a bad idea.

So; I put the repository somewhere else and set GIT_DIR.  However that 
scuppered my plans.  Trying to add a config file results in "not in a 
working directory" (of course), because even though git can find the 
repository, it has no way of knowing which directory to consider as the 
root of the working tree.

Let me put this in command form for you:

 $ cd $HOME
 $ export GIT_DIR=$HOME/gitrepos
 $ git init
 $ git add .bashrc
 fatal: add must be run in a work tree

Being able to set GIT_WORKING_DIR would have let me do this.



Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11  4:32 [RFC] introduce GIT_WORK_DIR environment variable Matthias Lederhofer
  2007-03-11  5:34 ` Junio C Hamano
@ 2007-03-11 12:42 ` Nguyen Thai Ngoc Duy
  2007-03-11 13:33   ` Matthias Lederhofer
  2007-03-11 15:56   ` [PATCH(amend)] " Matthias Lederhofer
  2007-03-11 13:27 ` [RFC] introduce GIT_WORK_DIR environment variable Nguyen Thai Ngoc Duy
  2007-03-12 11:53 ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Matthias Lederhofer
  3 siblings, 2 replies; 39+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-03-11 12:42 UTC (permalink / raw)
  To: git, Matthias Lederhofer

On 3/11/07, Matthias Lederhofer <matled@gmx.net> wrote:
> +               gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
> +               if (!gitwd || stat(gitwd, &st_work))
>                         return NULL;

I propose the following instead of the last two lines:

                if (!gitwd)
                        return NULL;
                if (stat(gitwd, &st_work))
                        die("Unable to stat git working directory %s",gitwd);

> +               if (inside_git_dir == -1 && stat(gitdirenv, &st_git))
> +                       die("Unable to stat git directory");
> +               if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
> +                       die("Unable to read current working directory");
> +               len = strlen(cwd);
> +
> +               prefix = cwd+len;
> +               for (;;) {
> +                       c = *prefix;
> +                       *prefix = '\0';
> +                       if (stat(cwd, &st))
> +                               die("Unable to stat '%s'", cwd);
> +                       if (st_work.st_dev == st.st_dev &&
> +                           st_work.st_ino == st.st_ino)
> +                               break;
> +                       if (inside_git_dir == -1 &&
> +                           st_git.st_dev == st.st_dev &&
> +                           st_git.st_ino == st.st_ino)
> +                               inside_git_dir = 1;
> +                       *prefix = c;
> +
> +                       if (prefix == cwd+1) {
> +                               has_working_directory = 0;
> +                               return NULL;

My case seems a bit complicated than usual. The working directory
(/home/pclouds/blog/data) was not a prefix of cwd (/home/pclouds/blog)
so the code failed silently at this line. If I replace
"has_working_directory = 0; return NULL;" with "strcpy(cwd,gitwd);c =
0;break;", it may work but see below

> +                       }
> +                       while (*(--prefix) != '/')
> +                               ; /* do nothing */
> +                       if (prefix == cwd)
> +                               prefix++;
> +               }
> +
> +               if (chdir(cwd))
> +                       die("Cannot change directory to '%s'", cwd);
> +

If cwd changed and GIT_DIR is a relative path, git can no longer
access GIT_DIR properly.
-- 
Duy

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11  4:32 [RFC] introduce GIT_WORK_DIR environment variable Matthias Lederhofer
  2007-03-11  5:34 ` Junio C Hamano
  2007-03-11 12:42 ` Nguyen Thai Ngoc Duy
@ 2007-03-11 13:27 ` Nguyen Thai Ngoc Duy
  2007-03-11 15:05   ` [PATCH] rev-parse: --is-bare-repository option Matthias Lederhofer
  2007-03-12 11:53 ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Matthias Lederhofer
  3 siblings, 1 reply; 39+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-03-11 13:27 UTC (permalink / raw)
  To: git, Matthias Lederhofer

On 3/11/07, Matthias Lederhofer <matled@gmx.net> wrote:
> diff --git a/environment.c b/environment.c
> index 0151ad0..5c30c9b 100644
> --- a/environment.c
> +++ b/environment.c
> @@ -61,6 +61,8 @@ int is_bare_repository(void)
>         const char *dir, *s;
>         if (0 <= is_bare_repository_cfg)
>                 return is_bare_repository_cfg;
> +       if (0 <= has_working_directory)
> +               return !has_working_directory;
>
>         dir = get_git_dir();
>         if (!strcmp(dir, DEFAULT_GIT_DIR_ENVIRONMENT))

Um.. git-sh-setup.sh may need special treatment because its
is_bare_directory doesn't call this function.
-- 
Duy

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 12:42 ` Nguyen Thai Ngoc Duy
@ 2007-03-11 13:33   ` Matthias Lederhofer
  2007-03-11 13:46     ` Nguyen Thai Ngoc Duy
  2007-03-11 15:56   ` [PATCH(amend)] " Matthias Lederhofer
  1 sibling, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11 13:33 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git

Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> My case seems a bit complicated than usual. The working directory
> (/home/pclouds/blog/data) was not a prefix of cwd (/home/pclouds/blog)
> so the code failed silently at this line. If I replace
> "has_working_directory = 0; return NULL;" with "strcpy(cwd,gitwd);c =
> 0;break;", it may work but see below

If you're outside the specifed working directory the
is_bare_repository will return true, just as if you don't have a
working directory.  Do you expect anything else or doesn't this work?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 13:33   ` Matthias Lederhofer
@ 2007-03-11 13:46     ` Nguyen Thai Ngoc Duy
  2007-03-11 14:05       ` Matthias Lederhofer
  0 siblings, 1 reply; 39+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-03-11 13:46 UTC (permalink / raw)
  To: Matthias Lederhofer, git

On 3/11/07, Matthias Lederhofer <matled@gmx.net> wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> > My case seems a bit complicated than usual. The working directory
> > (/home/pclouds/blog/data) was not a prefix of cwd (/home/pclouds/blog)
> > so the code failed silently at this line. If I replace
> > "has_working_directory = 0; return NULL;" with "strcpy(cwd,gitwd);c =
> > 0;break;", it may work but see below
>
> If you're outside the specifed working directory the
> is_bare_repository will return true, just as if you don't have a
> working directory.  Do you expect anything else or doesn't this work?

Yes I expected it to move the specified working directory as described
in the previous mail (copied/pasted below). However the patch requires
me to be in workdir somewhere already (which is fine if that is your
expectation). If that's the case, maybe you should tell users
something about GIT_WORK_DIR not applicable.

> Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> > By the way, is it plausible to add --git-workdir option to specify
> > working directory? With that option, I won't need to _chdir_ to the
> > working directory, run git commands and _chdir back_.
>
> http://article.gmane.org/gmane.comp.version-control.git/38382
> Since I did not need this feature that much and no one replied that
> there is any interest I did not look any further into it.

-- 
Duy

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 13:46     ` Nguyen Thai Ngoc Duy
@ 2007-03-11 14:05       ` Matthias Lederhofer
  2007-03-11 14:18         ` Nguyen Thai Ngoc Duy
  0 siblings, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11 14:05 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git

Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> Yes I expected it to move the specified working directory as described
> in the previous mail (copied/pasted below). However the patch requires
> me to be in workdir somewhere already (which is fine if that is your
> expectation). If that's the case, maybe you should tell users
> something about GIT_WORK_DIR not applicable.

Let's say we have GIT_DIR=/tmp/git GIT_WORK_DIR=/tmp/foo and are in
/tmp.  You want `git add bar` to chdir to /tmp/foo and add the file
bar from /tmp/foo?

> >Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> >> By the way, is it plausible to add --git-workdir option to specify
> >> working directory? With that option, I won't need to _chdir_ to the
> >> working directory, run git commands and _chdir back_.
I thought you meant the chdir to the toplevel directory when you're in
a subdirectory.  For this case I'd rather suggest
mygit() {
    old=$(pwd)
    cd "$MYTOPDIR"
    git "$@"
    ret=$?
    cd "$old"
    return $ret
}

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 14:05       ` Matthias Lederhofer
@ 2007-03-11 14:18         ` Nguyen Thai Ngoc Duy
  0 siblings, 0 replies; 39+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-03-11 14:18 UTC (permalink / raw)
  To: Matthias Lederhofer, git

On 3/11/07, Matthias Lederhofer <matled@gmx.net> wrote:
> Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> > Yes I expected it to move the specified working directory as described
> > in the previous mail (copied/pasted below). However the patch requires
> > me to be in workdir somewhere already (which is fine if that is your
> > expectation). If that's the case, maybe you should tell users
> > something about GIT_WORK_DIR not applicable.
>
> Let's say we have GIT_DIR=/tmp/git GIT_WORK_DIR=/tmp/foo and are in
> /tmp.  You want `git add bar` to chdir to /tmp/foo and add the file
> bar from /tmp/foo?

Yes. I wanted it for easy scripting but it's not very intuitive from
command line. I'd take it back.

>
> > >Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> > >> By the way, is it plausible to add --git-workdir option to specify
> > >> working directory? With that option, I won't need to _chdir_ to the
> > >> working directory, run git commands and _chdir back_.
> I thought you meant the chdir to the toplevel directory when you're in
> a subdirectory.  For this case I'd rather suggest
> mygit() {
>     old=$(pwd)
>     cd "$MYTOPDIR"
>     git "$@"
>     ret=$?
>     cd "$old"
>     return $ret
> }
>
Thanks, will try

-- 
Duy

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH] rev-parse: --is-bare-repository option
  2007-03-11 13:27 ` [RFC] introduce GIT_WORK_DIR environment variable Nguyen Thai Ngoc Duy
@ 2007-03-11 15:05   ` Matthias Lederhofer
  0 siblings, 0 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11 15:05 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> Um.. git-sh-setup.sh may need special treatment because its
> is_bare_directory doesn't call this function.
Here is rev-parse --is-bare-repository to fix this.

I'm not sure if git-sh-setup.sh:is_bare_repository should do other
checks if git-rev-parse --is-bare-repository fails.
---
 Documentation/git-rev-parse.txt |    7 +++++++
 builtin-rev-parse.c             |    5 +++++
 git-sh-setup.sh                 |    6 +-----
 git-svn.perl                    |    2 +-
 4 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Documentation/git-rev-parse.txt b/Documentation/git-rev-parse.txt
index ccc66aa..d024d93 100644
--- a/Documentation/git-rev-parse.txt
+++ b/Documentation/git-rev-parse.txt
@@ -89,6 +89,13 @@ OPTIONS
 --git-dir::
 	Show `$GIT_DIR` if defined else show the path to the .git directory.
 
+--is-inside-git-dir::
+	When the current working directory is below the repository
+	directory print "true", otherwise "false".
+
+--is-bare-repository::
+	When the repository is bare print "true", otherwise "false".
+
 --short, --short=number::
 	Instead of outputting the full SHA1 values of object names try to
 	abbreviate them to a shorter unique name. When no length is specified
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 37addb2..71d5162 100644
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
@@ -352,6 +352,11 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
 						: "false");
 				continue;
 			}
+			if (!strcmp(arg, "--is-bare-repository")) {
+				printf("%s\n", is_bare_repository() ? "true"
+						: "false");
+				continue;
+			}
 			if (!prefixcmp(arg, "--since=")) {
 				show_datestring("--max-age=", arg+8);
 				continue;
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index f24c7f2..9ac657a 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -29,11 +29,7 @@ set_reflog_action() {
 }
 
 is_bare_repository () {
-	git-config --bool --get core.bare ||
-	case "$GIT_DIR" in
-	.git | */.git) echo false ;;
-	*) echo true ;;
-	esac
+	git-rev-parse --is-bare-repository
 }
 
 cd_to_toplevel () {
diff --git a/git-svn.perl b/git-svn.perl
index 326e89f..ea5da95 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -559,7 +559,7 @@ sub post_fetch_checkout {
 	my $index = $ENV{GIT_INDEX_FILE} || "$ENV{GIT_DIR}/index";
 	return if -f $index;
 
-	chomp(my $bare = `git config --bool --get core.bare`);
+	chomp(my $bare = `git rev-parse --is-bare-repository`);
 	return if $bare eq 'true';
 	return if command_oneline(qw/rev-parse --is-inside-git-dir/) eq 'true';
 	command_noisy(qw/read-tree -m -u -v HEAD HEAD/);
-- 
1.5.0.3.355.g8488f-dirty

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH(amend)] introduce GIT_WORK_DIR environment variable
  2007-03-11 12:42 ` Nguyen Thai Ngoc Duy
  2007-03-11 13:33   ` Matthias Lederhofer
@ 2007-03-11 15:56   ` Matthias Lederhofer
  2007-03-11 16:25     ` Nguyen Thai Ngoc Duy
  2007-03-11 21:29     ` [PATCH] use $GIT_DIR/workdir as working directory with $GIT_DIR Matthias Lederhofer
  1 sibling, 2 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11 15:56 UTC (permalink / raw)
  To: git, Nguyen Thai Ngoc Duy

This environment variable can be used with GIT_DIR to
specify the toplevel working directory.  When GIT_DIR is not
set this variable is ignored.  As for GIT_DIR there is also
the option git --work-dir which overrides the environment
variable.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
New patch, this should go with the 'rev-parse --is-bare-repository
option' patch.

Documentation added, is_bare_repository check fixed, relative GIT_DIR
fix.  Becaus GIT_DIR is expanded to a full path setup_git_env should
be called after setup_git_directory_gently.  I searched for the
callers of setup_git_directory_gently and think this is fulfilled.

Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> I propose the following instead of the last two lines:
> 
>                if (!gitwd)
>                        return NULL;
>                if (stat(gitwd, &st_work))
>                        die("Unable to stat git working directory %s",gitwd);
It's in this new patch.

> If cwd changed and GIT_DIR is a relative path, git can no longer
> access GIT_DIR properly.
This too.
---
 Documentation/git.txt |   16 ++++++++-
 cache.h               |    2 +
 environment.c         |   11 +++++-
 git.c                 |   12 ++++++-
 setup.c               |   92 +++++++++++++++++++++++++++++++++++++++++++-----
 5 files changed, 119 insertions(+), 14 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index e875e83..d2f5d27 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -10,7 +10,8 @@ SYNOPSIS
 --------
 [verse]
 'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]
-    [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]
+    [--bare] [--git-dir=GIT_DIR] [--work-dir=GIT_WORK_DIR]
+    [--help] COMMAND [ARGS]
 
 DESCRIPTION
 -----------
@@ -81,6 +82,13 @@ OPTIONS
 	Set the path to the repository. This can also be controlled by
 	setting the GIT_DIR environment variable.
 
+--work-dir=<path>::
+	Set the path to the toplevel working directory.  The value will
+	be used only in combination with $GIT_DIR or '--git-dir'.
+	Without this option git will assume that the current directory
+	is also the toplevel directory.  This can also be controlled by
+	setting the GIT_WORK_DIR environment variable.
+
 --bare::
 	Same as --git-dir=`pwd`.
 
@@ -325,6 +333,12 @@ git so take care if using Cogito etc.
 	specifies a path to use instead of the default `.git`
 	for the base of the repository.
 
+'GIT_WORK_DIR'::
+	Set the path to the toplevel working directory.  The value will
+	be used only in combination with $GIT_DIR or '--git-dir'.
+	Without this environment variable git will assume that the
+	current directory is also the toplevel directory.
+
 git Commits
 ~~~~~~~~~~~
 'GIT_AUTHOR_NAME'::
diff --git a/cache.h b/cache.h
index f172d02..e3ca087 100644
--- a/cache.h
+++ b/cache.h
@@ -144,6 +144,7 @@ enum object_type {
 };
 
 #define GIT_DIR_ENVIRONMENT "GIT_DIR"
+#define GIT_WORKING_DIR_ENVIRONMENT "GIT_WORK_DIR"
 #define DEFAULT_GIT_DIR_ENVIRONMENT ".git"
 #define DB_ENVIRONMENT "GIT_OBJECT_DIRECTORY"
 #define INDEX_ENVIRONMENT "GIT_INDEX_FILE"
@@ -164,6 +165,7 @@ extern char *get_graft_file(void);
 
 #define ALTERNATE_DB_ENVIRONMENT "GIT_ALTERNATE_OBJECT_DIRECTORIES"
 
+extern int has_working_directory;
 extern const char **get_pathspec(const char *prefix, const char **pathspec);
 extern const char *setup_git_directory_gently(int *);
 extern const char *setup_git_directory(void);
diff --git a/environment.c b/environment.c
index 0151ad0..7bf6a87 100644
--- a/environment.c
+++ b/environment.c
@@ -59,8 +59,15 @@ static void setup_git_env(void)
 int is_bare_repository(void)
 {
 	const char *dir, *s;
-	if (0 <= is_bare_repository_cfg)
-		return is_bare_repository_cfg;
+	/* definitely bare */
+	if (is_bare_repository_cfg == 1)
+		return 1;
+	/* GIT_WORK_DIR is set, bare if cwd is outside */
+	if (has_working_directory >= 0)
+		return !has_working_directory;
+	/* configuration says it is not bare */
+	if (is_bare_repository_cfg == 0)
+		return 0;
 
 	dir = get_git_dir();
 	if (!strcmp(dir, DEFAULT_GIT_DIR_ENVIRONMENT))
diff --git a/git.c b/git.c
index fe2b74a..8a73648 100644
--- a/git.c
+++ b/git.c
@@ -4,7 +4,7 @@
 #include "quote.h"
 
 const char git_usage_string[] =
-	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]";
+	"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--work-dir=GIT_WORK_DIR] [--help] COMMAND [ARGS]";
 
 static void prepend_to_path(const char *dir, int len)
 {
@@ -68,6 +68,16 @@ static int handle_options(const char*** argv, int* argc)
 			(*argc)--;
 		} else if (!prefixcmp(cmd, "--git-dir=")) {
 			setenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);
+		} else if (!strcmp(cmd, "--work-dir")) {
+			if (*argc < 2) {
+				fprintf(stderr, "No directory given for --work-dir.\n" );
+				usage(git_usage_string);
+			}
+			setenv(GIT_WORKING_DIR_ENVIRONMENT, (*argv)[1], 1);
+			(*argv)++;
+			(*argc)--;
+		} else if (!prefixcmp(cmd, "--work-dir=")) {
+			setenv(GIT_WORKING_DIR_ENVIRONMENT, cmd + 11, 1);
 		} else if (!strcmp(cmd, "--bare")) {
 			static char git_dir[PATH_MAX+1];
 			setenv(GIT_DIR_ENVIRONMENT, getcwd(git_dir, sizeof(git_dir)), 1);
diff --git a/setup.c b/setup.c
index a45ea83..ebf628e 100644
--- a/setup.c
+++ b/setup.c
@@ -192,28 +192,100 @@ int is_inside_git_dir(void)
 	return inside_git_dir;
 }
 
+int has_working_directory = -1;
+
 const char *setup_git_directory_gently(int *nongit_ok)
 {
 	static char cwd[PATH_MAX+1];
 	const char *gitdirenv;
 	int len, offset;
 
-	/*
-	 * If GIT_DIR is set explicitly, we're not going
-	 * to do any discovery, but we still do repository
-	 * validation.
-	 */
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv) {
+		struct stat st, st_work, st_git;
+		const char *gitwd;
+		char *prefix;
+		char c;
+		int len;
+
 		if (PATH_MAX - 40 < strlen(gitdirenv))
 			die("'$%s' too big", GIT_DIR_ENVIRONMENT);
-		if (is_git_directory(gitdirenv))
-			return NULL;
-		if (nongit_ok) {
-			*nongit_ok = 1;
+		if (!is_git_directory(gitdirenv)) {
+			if (nongit_ok) {
+				*nongit_ok = 1;
+				return NULL;
+			}
+			die("Not a git repository: '%s'", gitdirenv);
+		}
+
+		/* check for working directory */
+		gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
+		if (!gitwd)
 			return NULL;
+		if (stat(gitwd, &st_work))
+			die("Unable to stat git working directory '%s'", gitwd);
+		if (inside_git_dir == -1 && stat(gitdirenv, &st_git))
+			die("Unable to stat git directory");
+		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		len = strlen(cwd);
+
+		prefix = cwd+len;
+		for (;;) {
+			c = *prefix;
+			*prefix = '\0';
+			if (stat(cwd, &st))
+				die("Unable to stat '%s'", cwd);
+			if (st_work.st_dev == st.st_dev &&
+			    st_work.st_ino == st.st_ino)
+				break;
+			if (inside_git_dir == -1 &&
+			    st_git.st_dev == st.st_dev &&
+			    st_git.st_ino == st.st_ino)
+				inside_git_dir = 1;
+			*prefix = c;
+
+			if (prefix == cwd+1) {
+				has_working_directory = 0;
+				return NULL;
+			}
+			while (*(--prefix) != '/')
+				; /* do nothing */
+			if (prefix == cwd)
+				prefix++;
+		}
+
+		/*
+		 * if GIT_DIR is no absolute path it wont work anymore after
+		 * changing the directory, therefore expand it to an absolute
+		 * path
+		 */
+		if (gitdirenv[0] != '/') {
+			char buf[PATH_MAX];
+			if (chdir(gitdirenv))
+				die("Cannot change directory to '%s'",
+				    gitdirenv);
+			if (!getcwd(buf, sizeof(buf)) || buf[0] != '/')
+				die("Unable to read current working directory");
+			setenv(GIT_DIR_ENVIRONMENT, buf, 1);
+		}
+		if (chdir(cwd))
+			die("Cannot change directory to '%s'", cwd);
+
+		if (c) {
+			*prefix = c;
+			prefix++;
+			cwd[len] = '/';
+			cwd[len+1] = '\0';
+		} else {
+			prefix = NULL;
 		}
-		die("Not a git repository: '%s'", gitdirenv);
+
+		has_working_directory = 1;
+		if (inside_git_dir == -1)
+			inside_git_dir = 0;
+
+		return prefix;
 	}
 
 	if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
-- 
1.5.0.3.356.gafc9e-dirty

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11  5:34 ` Junio C Hamano
  2007-03-11  8:26   ` Andy Parkins
@ 2007-03-11 16:22   ` Matthias Lederhofer
  2007-03-11 20:10     ` Junio C Hamano
  2007-03-11 20:37   ` Linus Torvalds
  2 siblings, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11 16:22 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
> Matthias Lederhofer <matled@gmx.net> 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.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH(amend)] introduce GIT_WORK_DIR environment variable
  2007-03-11 15:56   ` [PATCH(amend)] " Matthias Lederhofer
@ 2007-03-11 16:25     ` Nguyen Thai Ngoc Duy
  2007-03-11 21:29     ` [PATCH] use $GIT_DIR/workdir as working directory with $GIT_DIR Matthias Lederhofer
  1 sibling, 0 replies; 39+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-03-11 16:25 UTC (permalink / raw)
  To: git, Matthias Lederhofer

On 3/11/07, Matthias Lederhofer <matled@gmx.net> wrote:
> This environment variable can be used with GIT_DIR to
> specify the toplevel working directory.  When GIT_DIR is not
> set this variable is ignored.  As for GIT_DIR there is also
> the option git --work-dir which overrides the environment
> variable.
>
> Signed-off-by: Matthias Lederhofer <matled@gmx.net>

Works for me.

-- 
Duy

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 16:22   ` Matthias Lederhofer
@ 2007-03-11 20:10     ` Junio C Hamano
  2007-03-11 21:43       ` Johannes Schindelin
  0 siblings, 1 reply; 39+ messages in thread
From: Junio C Hamano @ 2007-03-11 20:10 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: git

Matthias Lederhofer <matled@gmx.net> writes:

> 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.

That's fine.  Will you constantly work inside that webserver exposed
working tree, though?  I suspect the operation you would do
there would only be "GIT_DIR=/some/where/else git checkout -f"
to refresh the published copy, so I do not think even GIT_WORK_DIR
is needed for that use case (just to make sure, I am not opposed
to having GIT_WORK_DIR -- my "why bother" is about having the
equivalent in .git/work_dir or .git/config).

> 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 :)

That is really a historical mention.  The current Porcelain-ish
depend on that "default" layout (I know you know that after
seeing what setup_git_directory does), and I think GIT_DIR
should not be taught to new people as such.

> 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.

Why does read-only directory have changes to begin with???

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11  5:34 ` Junio C Hamano
  2007-03-11  8:26   ` Andy Parkins
  2007-03-11 16:22   ` Matthias Lederhofer
@ 2007-03-11 20:37   ` Linus Torvalds
  2007-03-11 21:04     ` Junio C Hamano
  2 siblings, 1 reply; 39+ messages in thread
From: Linus Torvalds @ 2007-03-11 20:37 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthias Lederhofer, Nguyen Thai Ngoc Duy, git



On Sat, 10 Mar 2007, Junio C Hamano wrote:
> Matthias Lederhofer <matled@gmx.net> 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.

I actually like this feature. Let me explain why I think it's a great 
feature:

> But either .git/work_dir or a configuration means you are
> linking a repository with a _single_ working tree, permanently.
> If you are permanently linking one repository with a _single_
> working tree, is it too much bother to have that repository at
> the usual $GIT_TOP_DIR/.git like everybody else?

I'll tell you why: it makes tons of sense to have the git repository 
linked to exactly one working tree, *but the reverse is not necessarily 
always true*!

In other words, it can be a 1:n relationship.

You can have one working tree that is related to *multiple* git 
repositories.

That sounds insane, but I actually think it works, and makes tons of 
sense. Think something as simple as your own home directory.

It's possible that you want to track your music collection with git, but 
say that your music collection is a few different subdirectories or files 
in your home directory: maybe you track your "Music" directory (which 
contains the actual mp3 files or whatever), but maybe you'd like the same 
repository to *also* track things like your configuration file for 
whatever mp3-player you're using (".xmms"? Whatever).

So let's say that you have a git repository for tracking all that. The 
"working tree" for that git repository would be your home directory.

Now, imagine that you *also* want to track something else in git, that you 
*also* have in your home directory. Say your ".bashrc" files etc. They 
have nothing to do with your music tracking setup, so you don't want to 
track it in the same git repository, and you want to have a totally 
different .git/index file for those. But again, the *working*tree* is 
actually your home directory.

So allowing you to set the working tree associated with a particular git 
repository actually solves that problem. They can both share the same 
working tree (you'd want to track disjunct parts of the working tree, of 
course), which means that the working tree obviously does *not* want to 
have a .git/ directory in it. And to track your music changes, you'd just 
do

	cd music-repository
	git add music/
	git commit

to add any new files, and you'd be all set (or something like this).

There are other cases than just your home directory where you might want 
to track disjoint filesets in different git repositories. Things like /etc 
fall under the same "many unrelated things in the same working tree" 
setup.

So I actually think it makes tons of sense to allow a way to set the 
working tree for a git repository, and go the other way.

		Linus

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 20:37   ` Linus Torvalds
@ 2007-03-11 21:04     ` Junio C Hamano
  2007-03-11 21:13       ` Linus Torvalds
                         ` (2 more replies)
  0 siblings, 3 replies; 39+ messages in thread
From: Junio C Hamano @ 2007-03-11 21:04 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Matthias Lederhofer, Nguyen Thai Ngoc Duy, git

Linus Torvalds <torvalds@linux-foundation.org> writes:

> So let's say that you have a git repository for tracking all that. The 
> "working tree" for that git repository would be your home directory.
>
> Now, imagine that you *also* want to track something else in git, that you 
> *also* have in your home directory. Say your ".bashrc" files etc. They 
> have nothing to do with your music tracking setup, so you don't want to 
> track it in the same git repository, and you want to have a totally 
> different .git/index file for those. But again, the *working*tree* is 
> actually your home directory.

That is a good example usage schenario; we would need to think
about what to do with .gitignore (and .gitattributes if we will
have that in-tree), though.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 21:04     ` Junio C Hamano
@ 2007-03-11 21:13       ` Linus Torvalds
  2007-03-12  8:08       ` A.J. Rossini
  2007-04-01  7:42       ` Andy Parkins
  2 siblings, 0 replies; 39+ messages in thread
From: Linus Torvalds @ 2007-03-11 21:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthias Lederhofer, Nguyen Thai Ngoc Duy, git



On Sun, 11 Mar 2007, Junio C Hamano wrote:
> 
> That is a good example usage schenario; we would need to think
> about what to do with .gitignore (and .gitattributes if we will
> have that in-tree), though.

Good point. That's a real problem.

I guess you could say that for this kind of usage scenario you only want 
to use the per-repository .git/ignore file, or maybe have some way of 
specifying the name of the .gitignore file per repository.

Hmm. I'm not sure it was a great idea. I still like the concept, but 
you're right, it's not without its problems.

		Linus

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH] use $GIT_DIR/workdir as working directory with $GIT_DIR
  2007-03-11 15:56   ` [PATCH(amend)] " Matthias Lederhofer
  2007-03-11 16:25     ` Nguyen Thai Ngoc Duy
@ 2007-03-11 21:29     ` Matthias Lederhofer
  2007-03-13 23:10       ` [PATCH] core.workdir config variable Matthias Lederhofer
  1 sibling, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-11 21:29 UTC (permalink / raw)
  To: git

$GIT_DIR/workdir will be used as fallback if $GIT_WORK_DIR is not set

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 Documentation/repository-layout.txt |    4 ++
 setup.c                             |   64 ++++++++++++++++++++++++++++++++---
 2 files changed, 63 insertions(+), 5 deletions(-)

diff --git a/Documentation/repository-layout.txt b/Documentation/repository-layout.txt
index 0459bd9..8a88080 100644
--- a/Documentation/repository-layout.txt
+++ b/Documentation/repository-layout.txt
@@ -179,3 +179,7 @@ shallow::
 	and maintained by shallow clone mechanism.  See `--depth`
 	option to gitlink:git-clone[1] and gitlink:git-fetch[1].
 
+workdir::
+	Directory to be used as toplevel working directory when GIT_DIR
+	is set.  If this is a file the first line will be used as the
+	name of the directory.  This can be overriden by GIT_WORK_DIR.
diff --git a/setup.c b/setup.c
index ebf628e..a8b9fae 100644
--- a/setup.c
+++ b/setup.c
@@ -192,6 +192,64 @@ int is_inside_git_dir(void)
 	return inside_git_dir;
 }
 
+static int stat_git_work_dir(struct stat *st)
+{
+	char workdir[PATH_MAX], cwd[PATH_MAX];
+	const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
+	const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
+	int offset;
+	FILE *fp;
+
+	if (gitwd) {
+		if (!stat(gitwd, st))
+			return 1;
+		die("Unable to stat git working directory '%s'", gitwd);
+	}
+
+	/* setup_git_directory_gently: PATH_MAX - 40 >= strlen(gitdirenv) */
+	strcpy(workdir, gitdir);
+	strcat(workdir, "/workdir");
+
+	if (stat(workdir, st))
+		return 0;
+	if (st->st_mode & S_IFDIR)
+		return 1;
+	if (!(st->st_mode & S_IFREG))
+		die("GIT_DIR/workdir is neither a file nor a directory");
+
+	/* GIT_DIR/workdir is a file */
+	fp = fopen(workdir, "r");
+	if (!fp)
+		die("Unable to open '%s'", workdir);
+	if (!fgets(workdir, sizeof(workdir), fp))
+		die("Reading working directory from '%s' failed", workdir);
+	fclose(fp);
+	/* remove newline character(s) */
+	offset = strlen(workdir)-1;
+	while (offset >= 0 && (workdir[offset] == '\r' ||
+			workdir[offset] == '\n'))
+		--offset;
+	workdir[offset+1] = '\0';
+
+	/* relative path: change to gitdir for stat */
+	if (workdir[0] != '/') {
+		if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		if (chdir(gitdir))
+			die("Cannot change directory to '%s'", gitdir);
+	}
+
+	if (stat(workdir, st))
+		die("Unable to stat directory from GIT_DIR/workdir");
+	if (!(st->st_mode & S_IFDIR))
+		die("GIT_DIR/workdir does not point to a directory");
+
+	if (workdir[0] != '/' && chdir(cwd))
+		die("Cannot come back to cwd");
+
+	return 1;
+}
+
 int has_working_directory = -1;
 
 const char *setup_git_directory_gently(int *nongit_ok)
@@ -203,7 +261,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv) {
 		struct stat st, st_work, st_git;
-		const char *gitwd;
 		char *prefix;
 		char c;
 		int len;
@@ -219,11 +276,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 		}
 
 		/* check for working directory */
-		gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
-		if (!gitwd)
+		if (!stat_git_work_dir(&st_work))
 			return NULL;
-		if (stat(gitwd, &st_work))
-			die("Unable to stat git working directory '%s'", gitwd);
 		if (inside_git_dir == -1 && stat(gitdirenv, &st_git))
 			die("Unable to stat git directory");
 		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
-- 
1.5.0.3.357.g0b2cd

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 20:10     ` Junio C Hamano
@ 2007-03-11 21:43       ` Johannes Schindelin
  0 siblings, 0 replies; 39+ messages in thread
From: Johannes Schindelin @ 2007-03-11 21:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthias Lederhofer, git

Hi,

On Sun, 11 Mar 2007, Junio C Hamano wrote:

> Why does read-only directory have changes to begin with???

Tracking (parts of) /etc/, I change as root, but commit as another user 
(to prevent accidental corruption).

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 21:04     ` Junio C Hamano
  2007-03-11 21:13       ` Linus Torvalds
@ 2007-03-12  8:08       ` A.J. Rossini
  2007-04-01  7:42       ` Andy Parkins
  2 siblings, 0 replies; 39+ messages in thread
From: A.J. Rossini @ 2007-03-12  8:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

On 3/11/07, Junio C Hamano <junkio@cox.net> wrote:
> Linus Torvalds <torvalds@linux-foundation.org> writes:
>
> > So let's say that you have a git repository for tracking all that. The
> > "working tree" for that git repository would be your home directory.
> >
> > Now, imagine that you *also* want to track something else in git, that you
> > *also* have in your home directory. Say your ".bashrc" files etc. They
> > have nothing to do with your music tracking setup, so you don't want to
> > track it in the same git repository, and you want to have a totally
> > different .git/index file for those. But again, the *working*tree* is
> > actually your home directory.
>
> That is a good example usage schenario; we would need to think
> about what to do with .gitignore (and .gitattributes if we will
> have that in-tree), though.

Modulo problems like above, isn't this just a solid solution to the
modules problem?   (not only directory-level modules, but intertwined
(in the sense of repositories) files within a directory).

And wouldn't the cheap hack just to be to have a pecking order for
determining attributes?  (i.e. a master file with metadata which is
owned by the working directory, not the repository, to decide which
repository to look at for which files).

Ouch, but Junio's right, it's still painful, ugly and problematic.

best,
-tony

blindglobe@gmail.com
Muttenz, Switzerland.
"Commit early,commit often, and commit in a repository from which we
can easily roll-back your mistakes" (AJR, 4Jan05).

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-11  4:32 [RFC] introduce GIT_WORK_DIR environment variable Matthias Lederhofer
                   ` (2 preceding siblings ...)
  2007-03-11 13:27 ` [RFC] introduce GIT_WORK_DIR environment variable Nguyen Thai Ngoc Duy
@ 2007-03-12 11:53 ` Matthias Lederhofer
  2007-03-12 12:12   ` Joshua N Pritikin
  2007-03-12 19:23   ` [PATCH(amend)] " Matthias Lederhofer
  3 siblings, 2 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 11:53 UTC (permalink / raw)
  To: git

git-init will always put an absolute path in
GIT_DIR/workdir, relative paths are resolved from the
directory git-init was called from.

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
I found this static char path[PATH_MAX] even though path is neither
reused nor returned.  If there is any reason to have this as a static
buffer please change this back to 'static char'
---
 builtin-init-db.c |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index 4df9fd0..f0b4444 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -176,12 +176,13 @@ static void copy_templates(const char *git_dir, int len, const char *template_di
 static int create_default_files(const char *git_dir, const char *template_path)
 {
 	unsigned len = strlen(git_dir);
-	static char path[PATH_MAX];
+	char path[PATH_MAX], workdir[PATH_MAX];
 	unsigned char sha1[20];
 	struct stat st1;
 	char repo_version_string[10];
 	int reinit;
 	int filemode;
+	const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
 
 	if (len > sizeof(path)-50)
 		die("insane git directory %s", git_dir);
@@ -252,7 +253,42 @@ static int create_default_files(const char *git_dir, const char *template_path)
 	}
 	git_config_set("core.filemode", filemode ? "true" : "false");
 
-	if (is_bare_repository()) {
+	/* make gitwd an absolute path */
+	if (gitwd && gitwd[0] != '/') {
+		char cwd[PATH_MAX];
+
+		if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		if (chdir(gitwd)) {
+			fprintf(stderr, "warning: chdir to specified relative "
+				"working directory failed, ignoring\n");
+			gitwd = NULL;
+		}
+		else if (!getcwd(workdir, sizeof(workdir)) || workdir[0] != '/')
+			die("Unable to read current working directory");
+		else {
+			gitwd = workdir;
+			if (chdir(cwd))
+				die("Cannot come back to cwd");
+		}
+	}
+
+	if (gitwd) {
+		FILE *fp = NULL;
+
+		path[len] = 0;
+		strcpy(path + len, "workdir");
+		if (!(fp = fopen(path, "w")))
+			die("Cannot open GIT_DIR/workdir");
+		fprintf(fp, "%s\n", gitwd);
+		fclose(fp);
+
+		git_config_set("core.bare", "false");
+		/* allow template config file to override the default */
+		if (log_all_ref_updates == -1)
+		    git_config_set("core.logallrefupdates", "true");
+	}
+	else if (is_bare_repository()) {
 		git_config_set("core.bare", "true");
 	}
 	else {
-- 
1.5.0.3.1006.gd633

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 11:53 ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Matthias Lederhofer
@ 2007-03-12 12:12   ` Joshua N Pritikin
  2007-03-12 12:52     ` Matthias Lederhofer
  2007-03-12 13:12     ` Matthias Lederhofer
  2007-03-12 19:23   ` [PATCH(amend)] " Matthias Lederhofer
  1 sibling, 2 replies; 39+ messages in thread
From: Joshua N Pritikin @ 2007-03-12 12:12 UTC (permalink / raw)
  To: git

On Mon, Mar 12, 2007 at 12:53:50PM +0100, Matthias Lederhofer wrote:
> git-init will always put an absolute path in
> GIT_DIR/workdir, relative paths are resolved from the
> directory git-init was called from.

Does that mean I can't move my GIT trees around without changing a 
config entry? What is that an improvement?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 12:12   ` Joshua N Pritikin
@ 2007-03-12 12:52     ` Matthias Lederhofer
  2007-03-12 13:12     ` Matthias Lederhofer
  1 sibling, 0 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 12:52 UTC (permalink / raw)
  To: Joshua N Pritikin; +Cc: git

Joshua N Pritikin <jpritikin@pobox.com> wrote:
> On Mon, Mar 12, 2007 at 12:53:50PM +0100, Matthias Lederhofer wrote:
> > git-init will always put an absolute path in
> > GIT_DIR/workdir, relative paths are resolved from the
> > directory git-init was called from.
> 
> Does that mean I can't move my GIT trees around without changing a 
> config entry? What is that an improvement?
Only when using $GIT_DIR.  $GIT_DIR/workdir is only the default value
for $GIT_WORK_DIR.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 12:12   ` Joshua N Pritikin
  2007-03-12 12:52     ` Matthias Lederhofer
@ 2007-03-12 13:12     ` Matthias Lederhofer
  2007-03-12 13:36       ` Nguyen Thai Ngoc Duy
  1 sibling, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 13:12 UTC (permalink / raw)
  To: Joshua N Pritikin; +Cc: git

Joshua N Pritikin <jpritikin@pobox.com> wrote:
> On Mon, Mar 12, 2007 at 12:53:50PM +0100, Matthias Lederhofer wrote:
> > git-init will always put an absolute path in
> > GIT_DIR/workdir, relative paths are resolved from the
> > directory git-init was called from.
> 
> Does that mean I can't move my GIT trees around without changing a 
> config entry? What is that an improvement?

And for the decision to put an absolute path there by default:

Putting $GIT_WORK_DIR as is into $GIT_DIR/workdir is probably not what
the user expects because the content of $GIT_DIR/workdir is
interpreted relative to $GIT_DIR, not the current working directory.
Example:

    /tmp$ mkdir repository working_directory
    /tmp$ git --git-dir=repository --work-dir=working_directory init

If git init puts 'working_directory' into $GIT_DIR/workdir it would
make the associated working directory $GIT_DIR/working_directory =
/tmp/repository/working_directory and not /tmp/working_directory.

The alternative to use

    /tmp$ git --git-dir=repository --work-dir=../working_directory init

seems quite confusing to me.

If you've any other idea to solve this please tell me.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 13:12     ` Matthias Lederhofer
@ 2007-03-12 13:36       ` Nguyen Thai Ngoc Duy
  2007-03-12 14:08         ` Matthias Lederhofer
  0 siblings, 1 reply; 39+ messages in thread
From: Nguyen Thai Ngoc Duy @ 2007-03-12 13:36 UTC (permalink / raw)
  To: git, Matthias Lederhofer

On 3/12/07, Matthias Lederhofer <matled@gmx.net> wrote:
> Putting $GIT_WORK_DIR as is into $GIT_DIR/workdir is probably not what
> the user expects because the content of $GIT_DIR/workdir is
> interpreted relative to $GIT_DIR, not the current working directory.
> Example:
>
>     /tmp$ mkdir repository working_directory
>     /tmp$ git --git-dir=repository --work-dir=working_directory init
>
> If git init puts 'working_directory' into $GIT_DIR/workdir it would
> make the associated working directory $GIT_DIR/working_directory =
> /tmp/repository/working_directory and not /tmp/working_directory.
>
> The alternative to use
>
>     /tmp$ git --git-dir=repository --work-dir=../working_directory init
>
> seems quite confusing to me.
>
> If you've any other idea to solve this please tell me.

Let users create $GIT_DIR/workdir themselves. Your way may be less
confusing to you but might be more confusing to me because I _might_
expect a relative workdir setting (for example I move the repository
and the working directory together to another place).

-- 
Duy

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 13:36       ` Nguyen Thai Ngoc Duy
@ 2007-03-12 14:08         ` Matthias Lederhofer
  2007-03-12 17:31           ` Junio C Hamano
  0 siblings, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 14:08 UTC (permalink / raw)
  To: Nguyen Thai Ngoc Duy; +Cc: git

Nguyen Thai Ngoc Duy <pclouds@gmail.com> wrote:
> Let users create $GIT_DIR/workdir themselves. Your way may be less
> confusing to you but might be more confusing to me because I _might_
> expect a relative workdir setting (for example I move the repository
> and the working directory together to another place).

Well, without this patch you havo to do one of these:

    /tmp$ mkdir repository working_directory
    /tmp$ git --git-dir=repository init
    /tmp$ git --git-dir=repository config core.bare false
    /tmp$ echo ../working_directory > repository/workdir

or

    /tmp$ mkdir repository working_directory
    /tmp/repository$ cd repository
    /tmp$ git init
    /tmp/repository$ mv .git/* .
    /tmp/repository$ rmdir .git
    /tmp$ echo ../working_directory > repository/workdir

Where the second example is probably better because git init creates a
bare repository in the first case which might have more settings
different from a 'normal' repository (it actually sets also
core.logallrefupdates = true which probably should be added to the
first example).

With this patch you'd have to do

    /tmp$ mkdir repository working_directory
    /tmp$ git --git-dir=repository --work-dir=working_directory init
    /tmp$ echo ../working_directory > repository/workdir

in case you really want a relative path.

Because the first two ways are so long I think git init should have
some way to handle this case.

I don't want to put $GIT_WORK_DIR 'as is' to $GIT_DIR/workdir because
$GIT_WORK_DIR is normally interpreted as relative path to the current
working directory and not relative to $GIT_DIR.

Perhaps we could add another flag to git init which will be used 'as is'
for $GIT_DIR/workdir:
    git --git-dir=repository init --work-dir=../working_directory

Other things I can think of:

    Add a --not-bare flag to git init:
    $ git --git-dir=repository init --not-bare
    $ echo ../working_directory > repository/workdir

    Tell the user what to do in case the path should be relative:
    $ git --git-dir=repository --work-dir=working_directory init
    You specified a relative working directory and git has
    automatically expanded this to /tmp/working_directory.  If you
    prefer a relative path you can do:
        echo relative_path > repository/workdir

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 14:08         ` Matthias Lederhofer
@ 2007-03-12 17:31           ` Junio C Hamano
  2007-03-12 18:08             ` Matthias Lederhofer
  0 siblings, 1 reply; 39+ messages in thread
From: Junio C Hamano @ 2007-03-12 17:31 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: git, Nguyen Thai Ngoc Duy

Matthias Lederhofer <matled@gmx.net> 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.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 17:31           ` Junio C Hamano
@ 2007-03-12 18:08             ` Matthias Lederhofer
  2007-03-12 19:18               ` [PATCH] always interpret GIT_WORK_DIR relative to $GIT_DIR Matthias Lederhofer
  2007-03-12 20:05               ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Junio C Hamano
  0 siblings, 2 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 18:08 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
> Matthias Lederhofer <matled@gmx.net> 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.

You're right,  this seems to be much better.

I just thought that GIT_WORK_DIR should be relative to the current
working directory because it's more intuitive, e.g.

    $ git --git-dir=/path/to/repo.git --work-dir=../.. add a

where ../.. matches the path to the toplevel working directory from
cwd.  But this definitely is annoying when changing directories.

I'll go and fix this.  Do you prefer an amended patch or just a patch
on top?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH] always interpret GIT_WORK_DIR relative to $GIT_DIR
  2007-03-12 18:08             ` Matthias Lederhofer
@ 2007-03-12 19:18               ` Matthias Lederhofer
  2007-03-12 19:53                 ` [PATCH] GIT_WORK_DIR: documentation for relative path Matthias Lederhofer
  2007-03-12 20:05               ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Junio C Hamano
  1 sibling, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 19:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 setup.c |   39 +++++++++++++++++++++++----------------
 1 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/setup.c b/setup.c
index a8b9fae..f8c020e 100644
--- a/setup.c
+++ b/setup.c
@@ -192,16 +192,36 @@ int is_inside_git_dir(void)
 	return inside_git_dir;
 }
 
+static int stat_relative(const char *base, const char *path, struct stat *st)
+{
+	char cwd[PATH_MAX];
+	int ret;
+
+	if (path[0] != '/') {
+		if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		if (chdir(base))
+			die("Cannot change directory to '%s'", base);
+	}
+
+	ret = stat(path, st);
+
+	if (path[0] != '/' && chdir(cwd))
+		die("Cannot come back to cwd");
+
+	return ret;
+}
+
 static int stat_git_work_dir(struct stat *st)
 {
-	char workdir[PATH_MAX], cwd[PATH_MAX];
+	char workdir[PATH_MAX];
 	const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
 	const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
 	int offset;
 	FILE *fp;
 
 	if (gitwd) {
-		if (!stat(gitwd, st))
+		if (!stat_relative(gitdir, gitwd, st))
 			return 1;
 		die("Unable to stat git working directory '%s'", gitwd);
 	}
@@ -231,21 +251,8 @@ static int stat_git_work_dir(struct stat *st)
 		--offset;
 	workdir[offset+1] = '\0';
 
-	/* relative path: change to gitdir for stat */
-	if (workdir[0] != '/') {
-		if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
-			die("Unable to read current working directory");
-		if (chdir(gitdir))
-			die("Cannot change directory to '%s'", gitdir);
-	}
-
-	if (stat(workdir, st))
+	if (stat_relative(gitdir, workdir, st))
 		die("Unable to stat directory from GIT_DIR/workdir");
-	if (!(st->st_mode & S_IFDIR))
-		die("GIT_DIR/workdir does not point to a directory");
-
-	if (workdir[0] != '/' && chdir(cwd))
-		die("Cannot come back to cwd");
 
 	return 1;
 }
-- 
1.5.0.3.1007.g7ff7

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH(amend)] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 11:53 ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Matthias Lederhofer
  2007-03-12 12:12   ` Joshua N Pritikin
@ 2007-03-12 19:23   ` Matthias Lederhofer
  1 sibling, 0 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 19:23 UTC (permalink / raw)
  To: git

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
It's much easier when $GIT_WORK_DIR is always interpreted relative to
$GIT_DIR.
---
 builtin-init-db.c |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/builtin-init-db.c b/builtin-init-db.c
index 4df9fd0..8d0065c 100644
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
@@ -182,6 +182,7 @@ static int create_default_files(const char *git_dir, const char *template_path)
 	char repo_version_string[10];
 	int reinit;
 	int filemode;
+	const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
 
 	if (len > sizeof(path)-50)
 		die("insane git directory %s", git_dir);
@@ -252,10 +253,21 @@ static int create_default_files(const char *git_dir, const char *template_path)
 	}
 	git_config_set("core.filemode", filemode ? "true" : "false");
 
-	if (is_bare_repository()) {
+	if (is_bare_repository() && !gitwd) {
 		git_config_set("core.bare", "true");
 	}
 	else {
+		if (gitwd) {
+			FILE *fp = NULL;
+
+			path[len] = 0;
+			strcpy(path + len, "workdir");
+			if (!(fp = fopen(path, "w")))
+				die("Cannot open GIT_DIR/workdir");
+			fprintf(fp, "%s\n", gitwd);
+			fclose(fp);
+		}
+
 		git_config_set("core.bare", "false");
 		/* allow template config file to override the default */
 		if (log_all_ref_updates == -1)
-- 
1.5.0.3.1007.g7ff7

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH] GIT_WORK_DIR: documentation for relative path
  2007-03-12 19:18               ` [PATCH] always interpret GIT_WORK_DIR relative to $GIT_DIR Matthias Lederhofer
@ 2007-03-12 19:53                 ` Matthias Lederhofer
  0 siblings, 0 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 19:53 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
 Documentation/git.txt |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/Documentation/git.txt b/Documentation/git.txt
index d2f5d27..177adf5 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -83,11 +83,13 @@ OPTIONS
 	setting the GIT_DIR environment variable.
 
 --work-dir=<path>::
-	Set the path to the toplevel working directory.  The value will
-	be used only in combination with $GIT_DIR or '--git-dir'.
-	Without this option git will assume that the current directory
-	is also the toplevel directory.  This can also be controlled by
-	setting the GIT_WORK_DIR environment variable.
+	Set the path to the toplevel working directory.  If the path is
+	relative it is interpreted from $GIT_DIR, not the current
+	working directory.  The value will be used only in combination
+	with $GIT_DIR or '--git-dir'.  Without this option git will
+	assume that the current working directory is also the toplevel
+	directory.  This can also be controlled by setting the
+	GIT_WORK_DIR environment variable.
 
 --bare::
 	Same as --git-dir=`pwd`.
@@ -334,10 +336,12 @@ git so take care if using Cogito etc.
 	for the base of the repository.
 
 'GIT_WORK_DIR'::
-	Set the path to the toplevel working directory.  The value will
-	be used only in combination with $GIT_DIR or '--git-dir'.
-	Without this environment variable git will assume that the
-	current directory is also the toplevel directory.
+	Set the path to the toplevel working directory.  If the path is
+	relative it is interpreted from $GIT_DIR, not the current
+	working directory.  The value will be used only in combination
+	with $GIT_DIR or '--git-dir'.  Without this environment variable
+	git will assume that the current working directory is also the
+	toplevel directory.
 
 git Commits
 ~~~~~~~~~~~
-- 
1.5.0.3.1007.g7ff7

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 18:08             ` Matthias Lederhofer
  2007-03-12 19:18               ` [PATCH] always interpret GIT_WORK_DIR relative to $GIT_DIR Matthias Lederhofer
@ 2007-03-12 20:05               ` Junio C Hamano
  2007-03-12 20:40                 ` Matthias Lederhofer
  1 sibling, 1 reply; 39+ messages in thread
From: Junio C Hamano @ 2007-03-12 20:05 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: git

Matthias Lederhofer <matled@gmx.net> writes:

> I just thought that GIT_WORK_DIR should be relative to the current
> working directory because it's more intuitive, e.g.
>
>     $ git --git-dir=/path/to/repo.git --work-dir=../.. add a
>
> where ../.. matches the path to the toplevel working directory from
> cwd.  But this definitely is annoying when changing directories.

Not so fast.  That was a trick suggestion, only meant to see if
you have thought through the issues, and you did not have to
agree with me so quickly ;-).  What I was pointing out was
merely that specifying the top as a path relative to the cwd in
permanent basis was not useful if you are going to cd around,
which is a tautology.

For a one-shot thing, I would agree that being able to say "I am
in Documentation/howto directory of the whole thing, so I can
name the top of my working tree as ../.." is far more useful and
natural than having to say "ehhhh, what is the top of the
working tree relative to my repository???".  If it is not a
one-shot thing and the user expects to cd around, then:

	$ GIT_WORK_DIR=$(pwd)/../..; export GIT_WORK_DIR
	$ git foo ...; git bar ...;

would be more natural, so I do not expect the semantics of
relative path would be a big issue in reality, as long as we
make it clear that it is relative to cwd.

By the way, I do not find your command line example intuitive at
all, whether the --work-dir= parameter is relative or absolute.
Do you honestry expect that loooong command line is something
people would use in real life?

With $GIT_DIR/workdir support, I would expect that people would
do (if what is done is only to add one file and nothing else):

	$ GIT_DIR=/path/to/repo.git git add a

And without $GIT_DIR/workdir support:

	$ GIT_DIR=/path/to/repo.git GIT_WORK_DIR=../.. git add a

If the user is going to work in the working tree for extended
period of time, cd'ing around and running multiple git commands:

	$ GIT_DIR=/path/to/repo.git; export GIT_DIR
        $ git foo ; git bar ; cd subdir ; git baz ; ...

And without $GIT_DIR/workdir support, perhaps the user would do:

	$ GIT_DIR=/path/to/repo.git; export GIT_DIR
	$ GIT_WORK_DIR=$(pwd)/../..; export GIT_WORK_DIR
        $ git foo ; git bar ; cd subdir ; git baz ; ...

What I am getting at is that I personally feel that --git-dir=
option is already an unnecessary redundancy that is there only
to confuse new people by having more than one way to do the same
thing, and --work-dir= option seems to be only adding to the
same confusion.  Do we really want that as an option?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set
  2007-03-12 20:05               ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Junio C Hamano
@ 2007-03-12 20:40                 ` Matthias Lederhofer
  0 siblings, 0 replies; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-12 20:40 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

Junio C Hamano <junkio@cox.net> wrote:
> Matthias Lederhofer <matled@gmx.net> writes:
> 
> > I just thought that GIT_WORK_DIR should be relative to the current
> > working directory because it's more intuitive, e.g.
> >
> >     $ git --git-dir=/path/to/repo.git --work-dir=../.. add a
> >
> > where ../.. matches the path to the toplevel working directory from
> > cwd.  But this definitely is annoying when changing directories.
> 
> Not so fast.  That was a trick suggestion, only meant to see if
> you have thought through the issues, and you did not have to
> agree with me so quickly ;-).

Well, I have no strong feelings for either handling because I'll
probably always use `pwd`/relative/path anyway.

Is there anything more to this decision than this?

GIT_WORK_DIR relative to cwd:
    git --work-dir <path> [..] is more intuitive

GIT_WORK_DIR relative to $GIT_DIR:
    $GIT_DIR/workdir and $GIT_WORK_DIR are interpreted exactly the
    same way, which primarily makes it easier to implement git init
    with --work-dir :-)

> By the way, I do not find your command line example intuitive at
> all, whether the --work-dir= parameter is relative or absolute.
> Do you honestry expect that loooong command line is something
> people would use in real life?

For one-shot things I prefer --git-dir and --work-dir over
GIT_DIR and GIT_WORK_DIR because they are lowercase and for
GIT_WORK_DIR it's even shorter; and all the examples were one-shot
things (well, one used the same --git-dir twice).

^ permalink raw reply	[flat|nested] 39+ messages in thread

* [PATCH] core.workdir config variable
  2007-03-11 21:29     ` [PATCH] use $GIT_DIR/workdir as working directory with $GIT_DIR Matthias Lederhofer
@ 2007-03-13 23:10       ` Matthias Lederhofer
  2007-03-13 23:57         ` [PATCH(amend)] " Matthias Lederhofer
  0 siblings, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-13 23:10 UTC (permalink / raw)
  To: Junio C Hamano, git

core.workdir is used as default value for $GIT_WORK_DIR

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
This one replaces the 'use $GIT_DIR/workdir as working directory with
$GIT_DIR' patch and uses core.workdir instead.  This patch gets
core.workdir only for setup.c from the configuration file.  Perhaps
this should be handled in git_default_config like most other core.*
variables.

I just noticed that dying if the specified workdir is invalid can
cause trouble too:

    $ export GIT_DIR=/path/to/repository
    $ git config core.workdir /non-existent
    $ git config core.workdir ../workdir
    fatal: Unable to stat git working directory '/non-existent'

Workaround is either to edit the file manually or do:

    $ git --work-dir=. config core.workdir ../workdir

---
 Documentation/config.txt |    4 +++
 setup.c                  |   53 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5408dd6..663d82d 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -162,6 +162,10 @@ repository that ends in "/.git" is assumed to be not bare (bare =
 false), while all other repositories are assumed to be bare (bare
 = true).
 
+core.workdir::
+	Directory to be used as toplevel working directory when GIT_DIR
+	is set.  This can be overriden by GIT_WORK_DIR.
+
 core.logAllRefUpdates::
 	Updates to a ref <ref> is logged to the file
 	"$GIT_DIR/logs/<ref>", by appending the new and old
diff --git a/setup.c b/setup.c
index ebf628e..913c4b4 100644
--- a/setup.c
+++ b/setup.c
@@ -192,6 +192,53 @@ int is_inside_git_dir(void)
 	return inside_git_dir;
 }
 
+static char **git_work_dir;
+
+static int git_workdir_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "core.workdir")) {
+		strlcpy(value, *git_work_dir, PATH_MAX);
+	}
+	return 0;
+}
+
+static int stat_git_work_dir(struct stat *st)
+{
+	char workdir[PATH_MAX], cwd[PATH_MAX];
+	const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
+	const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
+
+	if (gitwd) {
+		if (!stat(gitwd, st))
+			return 1;
+		die("Unable to stat git working directory '%s'", gitwd);
+	}
+
+	/* get workdir from config */
+	workdir[0] = '\0';
+	git_work_dir = workdir;
+	git_config(git_workdir_config);
+	git_workdir_config = NULL;
+	if (!workdir[0])
+		return 0;
+
+	/* relative path: change to gitdir for stat */
+	if (workdir[0] != '/') {
+		if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		if (chdir(gitdir))
+			die("Cannot change directory to '%s'", gitdir);
+	}
+
+	if (stat(workdir, st))
+		die("Unable to stat git working directory '%s'", workdir);
+
+	if (workdir[0] != '/' && chdir(cwd))
+		die("Cannot come back to cwd");
+
+	return 1;
+}
+
 int has_working_directory = -1;
 
 const char *setup_git_directory_gently(int *nongit_ok)
@@ -203,7 +250,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv) {
 		struct stat st, st_work, st_git;
-		const char *gitwd;
 		char *prefix;
 		char c;
 		int len;
@@ -219,11 +265,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 		}
 
 		/* check for working directory */
-		gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
-		if (!gitwd)
+		if (!stat_git_work_dir(&st_work))
 			return NULL;
-		if (stat(gitwd, &st_work))
-			die("Unable to stat git working directory '%s'", gitwd);
 		if (inside_git_dir == -1 && stat(gitdirenv, &st_git))
 			die("Unable to stat git directory");
 		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
-- 
1.5.0.3.970.ge984-dirty

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* [PATCH(amend)] core.workdir config variable
  2007-03-13 23:10       ` [PATCH] core.workdir config variable Matthias Lederhofer
@ 2007-03-13 23:57         ` Matthias Lederhofer
  2007-03-14  6:01           ` Shawn O. Pearce
  0 siblings, 1 reply; 39+ messages in thread
From: Matthias Lederhofer @ 2007-03-13 23:57 UTC (permalink / raw)
  To: Junio C Hamano, git

core.workdir is used as default value for $GIT_WORK_DIR

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
---
Sorry, the last one was totally broken.  Testing without recompiling
isn't good..
---
 Documentation/config.txt |    4 +++
 setup.c                  |   53 +++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/Documentation/config.txt b/Documentation/config.txt
index 5408dd6..663d82d 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -162,6 +162,10 @@ repository that ends in "/.git" is assumed to be not bare (bare =
 false), while all other repositories are assumed to be bare (bare
 = true).
 
+core.workdir::
+	Directory to be used as toplevel working directory when GIT_DIR
+	is set.  This can be overriden by GIT_WORK_DIR.
+
 core.logAllRefUpdates::
 	Updates to a ref <ref> is logged to the file
 	"$GIT_DIR/logs/<ref>", by appending the new and old
diff --git a/setup.c b/setup.c
index ebf628e..208124f 100644
--- a/setup.c
+++ b/setup.c
@@ -192,6 +192,53 @@ int is_inside_git_dir(void)
 	return inside_git_dir;
 }
 
+static char *git_work_dir;
+
+static int git_workdir_config(const char *var, const char *value)
+{
+	if (!strcmp(var, "core.workdir")) {
+		strlcpy(git_work_dir, value, PATH_MAX);
+	}
+	return 0;
+}
+
+static int stat_git_work_dir(struct stat *st)
+{
+	char workdir[PATH_MAX], cwd[PATH_MAX];
+	const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
+	const char *gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
+
+	if (gitwd) {
+		if (!stat(gitwd, st))
+			return 1;
+		die("Unable to stat git working directory '%s'", gitwd);
+	}
+
+	/* get workdir from config */
+	workdir[0] = '\0';
+	git_work_dir = workdir;
+	git_config(git_workdir_config);
+	git_work_dir = NULL;
+	if (!workdir[0])
+		return 0;
+
+	/* relative path: change to gitdir for stat */
+	if (workdir[0] != '/') {
+		if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+			die("Unable to read current working directory");
+		if (chdir(gitdir))
+			die("Cannot change directory to '%s'", gitdir);
+	}
+
+	if (stat(workdir, st))
+		die("Unable to stat git working directory '%s'", workdir);
+
+	if (workdir[0] != '/' && chdir(cwd))
+		die("Cannot come back to cwd");
+
+	return 1;
+}
+
 int has_working_directory = -1;
 
 const char *setup_git_directory_gently(int *nongit_ok)
@@ -203,7 +250,6 @@ const char *setup_git_directory_gently(int *nongit_ok)
 	gitdirenv = getenv(GIT_DIR_ENVIRONMENT);
 	if (gitdirenv) {
 		struct stat st, st_work, st_git;
-		const char *gitwd;
 		char *prefix;
 		char c;
 		int len;
@@ -219,11 +265,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 		}
 
 		/* check for working directory */
-		gitwd = getenv(GIT_WORKING_DIR_ENVIRONMENT);
-		if (!gitwd)
+		if (!stat_git_work_dir(&st_work))
 			return NULL;
-		if (stat(gitwd, &st_work))
-			die("Unable to stat git working directory '%s'", gitwd);
 		if (inside_git_dir == -1 && stat(gitdirenv, &st_git))
 			die("Unable to stat git directory");
 		if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
-- 
gitgui.0.6.3.g4bccd

^ permalink raw reply related	[flat|nested] 39+ messages in thread

* Re: [PATCH(amend)] core.workdir config variable
  2007-03-13 23:57         ` [PATCH(amend)] " Matthias Lederhofer
@ 2007-03-14  6:01           ` Shawn O. Pearce
  2007-03-14  7:48             ` Junio C Hamano
  0 siblings, 1 reply; 39+ messages in thread
From: Shawn O. Pearce @ 2007-03-14  6:01 UTC (permalink / raw)
  To: Matthias Lederhofer; +Cc: Junio C Hamano, git

Matthias Lederhofer <matled@gmx.net> wrote:
> core.workdir is used as default value for $GIT_WORK_DIR
...
> -- 
> gitgui.0.6.3.g4bccd

Really?  gitgui generates emails now?  ;-)

Matthias, your git binaries were built with an older (pre 1.5.0)
git-describe in the path.  This caused the version number to be
incorrectly determined, due to an old bug in git-describe.

Recompiling with your "gitgui.0.6.3" git-describe should get
the correct version number, as that is most definately after the
git-describe bug fix.

-- 
Shawn.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH(amend)] core.workdir config variable
  2007-03-14  6:01           ` Shawn O. Pearce
@ 2007-03-14  7:48             ` Junio C Hamano
  2007-03-14 14:20               ` Shawn O. Pearce
  0 siblings, 1 reply; 39+ messages in thread
From: Junio C Hamano @ 2007-03-14  7:48 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: Matthias Lederhofer, git

"Shawn O. Pearce" <spearce@spearce.org> writes:

> Matthias Lederhofer <matled@gmx.net> wrote:
>> core.workdir is used as default value for $GIT_WORK_DIR
> ...
>> -- 
>> gitgui.0.6.3.g4bccd
>
> Really?  gitgui generates emails now?  ;-)

It might not be a bad idea actually.  You let people make
commits.  Why not let them pick commits, run format-patch and
drive send-email for them from the UI?

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [PATCH(amend)] core.workdir config variable
  2007-03-14  7:48             ` Junio C Hamano
@ 2007-03-14 14:20               ` Shawn O. Pearce
  0 siblings, 0 replies; 39+ messages in thread
From: Shawn O. Pearce @ 2007-03-14 14:20 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthias Lederhofer, git

Junio C Hamano <junkio@cox.net> wrote:
> "Shawn O. Pearce" <spearce@spearce.org> writes:
> 
> > Matthias Lederhofer <matled@gmx.net> wrote:
> >> core.workdir is used as default value for $GIT_WORK_DIR
> > ...
> >> -- 
> >> gitgui.0.6.3.g4bccd
> >
> > Really?  gitgui generates emails now?  ;-)
> 
> It might not be a bad idea actually.  You let people make
> commits.  Why not let them pick commits, run format-patch and
> drive send-email for them from the UI?

No, its not.  There's a lot of stuff I want to put into there;
that just happens to be one of them.  ;-)

-- 
Shawn.

^ permalink raw reply	[flat|nested] 39+ messages in thread

* Re: [RFC] introduce GIT_WORK_DIR environment variable
  2007-03-11 21:04     ` Junio C Hamano
  2007-03-11 21:13       ` Linus Torvalds
  2007-03-12  8:08       ` A.J. Rossini
@ 2007-04-01  7:42       ` Andy Parkins
  2 siblings, 0 replies; 39+ messages in thread
From: Andy Parkins @ 2007-04-01  7:42 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Linus Torvalds, Matthias Lederhofer,
	Nguyen Thai Ngoc Duy

On Sunday 2007, March 11, Junio C Hamano wrote:

> That is a good example usage schenario; we would need to think
> about what to do with .gitignore (and .gitattributes if we will
> have that in-tree), though.

While it's not solveable yet; if git gets gitattributes support, then 
it's easy.  As long as there is a way of specifying attributes in the 
config (which I'm sure there will be), in the music repository you 
would have (syntax being made up on the spot)

[attribute "gitattributesfile"]
  path = .gitattribute-music
[attribute "gitignorefile"]
  path = .gitignore-music

Then in the config repository:

[attribute "gitattributesfile"]
  path = .gitattribute-config
[attribute "gitignorefile"]
  path = .gitignore-config



Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com

^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2007-04-01  7:45 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-11  4:32 [RFC] introduce GIT_WORK_DIR environment variable Matthias Lederhofer
2007-03-11  5:34 ` Junio C Hamano
2007-03-11  8:26   ` Andy Parkins
2007-03-11 16:22   ` Matthias Lederhofer
2007-03-11 20:10     ` Junio C Hamano
2007-03-11 21:43       ` Johannes Schindelin
2007-03-11 20:37   ` Linus Torvalds
2007-03-11 21:04     ` Junio C Hamano
2007-03-11 21:13       ` Linus Torvalds
2007-03-12  8:08       ` A.J. Rossini
2007-04-01  7:42       ` Andy Parkins
2007-03-11 12:42 ` Nguyen Thai Ngoc Duy
2007-03-11 13:33   ` Matthias Lederhofer
2007-03-11 13:46     ` Nguyen Thai Ngoc Duy
2007-03-11 14:05       ` Matthias Lederhofer
2007-03-11 14:18         ` Nguyen Thai Ngoc Duy
2007-03-11 15:56   ` [PATCH(amend)] " Matthias Lederhofer
2007-03-11 16:25     ` Nguyen Thai Ngoc Duy
2007-03-11 21:29     ` [PATCH] use $GIT_DIR/workdir as working directory with $GIT_DIR Matthias Lederhofer
2007-03-13 23:10       ` [PATCH] core.workdir config variable Matthias Lederhofer
2007-03-13 23:57         ` [PATCH(amend)] " Matthias Lederhofer
2007-03-14  6:01           ` Shawn O. Pearce
2007-03-14  7:48             ` Junio C Hamano
2007-03-14 14:20               ` Shawn O. Pearce
2007-03-11 13:27 ` [RFC] introduce GIT_WORK_DIR environment variable Nguyen Thai Ngoc Duy
2007-03-11 15:05   ` [PATCH] rev-parse: --is-bare-repository option Matthias Lederhofer
2007-03-12 11:53 ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Matthias Lederhofer
2007-03-12 12:12   ` Joshua N Pritikin
2007-03-12 12:52     ` Matthias Lederhofer
2007-03-12 13:12     ` Matthias Lederhofer
2007-03-12 13:36       ` Nguyen Thai Ngoc Duy
2007-03-12 14:08         ` Matthias Lederhofer
2007-03-12 17:31           ` Junio C Hamano
2007-03-12 18:08             ` Matthias Lederhofer
2007-03-12 19:18               ` [PATCH] always interpret GIT_WORK_DIR relative to $GIT_DIR Matthias Lederhofer
2007-03-12 19:53                 ` [PATCH] GIT_WORK_DIR: documentation for relative path Matthias Lederhofer
2007-03-12 20:05               ` [PATCH] git-init: set up GIT_DIR/workdir if GIT_WORK_DIR is set Junio C Hamano
2007-03-12 20:40                 ` Matthias Lederhofer
2007-03-12 19:23   ` [PATCH(amend)] " Matthias Lederhofer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.