Re: I don't want the .git directory next to my code.
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Jan 17, 2008, 17:49 UTC
- Message-ID
- <alpine.LSU.1.00.0801171748520.5731@racer.site>
- In-Reply-To
- <alpine.LFD.1.00.0801170849070.14959@woody.linux-foundation.org>
Hi,
On Thu, 17 Jan 2008, Linus Torvalds wrote:
> Ok, here's the ugliest idea *ever*:
Okay, you won.
Show 31 quoted lines
> diff --git a/setup.c b/setup.c
> index adede16..97865f4 100644
> --- a/setup.c
> +++ b/setup.c
> @@ -1,5 +1,6 @@
> #include "cache.h"
> #include "dir.h"
> +#include <attr/xattr.h>
>
> static int inside_git_dir = -1;
> static int inside_work_tree = -1;
> @@ -302,6 +303,9 @@ const char *setup_git_directory_gently(int *nongit_ok)
> */
> offset = len = strlen(cwd);
> for (;;) {
> + int attr_len;
> + static char git_dir[PATH_MAX];
> +
> if (is_git_directory(DEFAULT_GIT_DIR_ENVIRONMENT))
> break;
> if (is_git_directory(".")) {
> @@ -312,6 +316,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
> check_repository_format_gently(nongit_ok);
> return NULL;
> }
> + attr_len = getxattr(".", "user.git-dir", git_dir, sizeof(git_dir)-1);
> + if (attr_len > 0) {
> + git_dir[attr_len] = 0;
> + if (is_git_directory(git_dir)) {
> + setenv(GIT_DIR_ENVIRONMENT, git_dir, 1);
> + break;What's this break all about?
Show 5 quoted lines
> + }
> + }
> chdir("..");
> do {
> if (!offset) {Ciao, Dscho