Re: I don't want the .git directory next to my code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Thu, 17 Jan 2008, Linus Torvalds wrote:

> Ok, here's the ugliest idea *ever*:

Okay, you won.

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

> +			}
> +		}
>  		chdir("..");
>  		do {
>  			if (!offset) {

Ciao,
Dscho

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux