Re: [PATCH 2/2] Add support for GIT_ONE_FILESYSTEM

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

 



On 3/17/10, Lars R. Damerow <lars@xxxxxxxxx> wrote:
>  @@ -422,6 +429,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
>                         }
>                         die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
>                 }
>  +               if (one_filesystem) {
>  +                       if (stat("..", &buf))
>  +                               die_errno("failed to stat '%s/..'", getcwd(err_cwd, sizeof(err_cwd)-1));
>  +                       if (buf.st_dev != current_device)
>  +                               die("Not a git repository (or any parent up to %s/..)\n"
>  +                                       "Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is set.",
>  +                                       getcwd(err_cwd, sizeof(err_cwd)-1));
>  +               }
>                 if (chdir(".."))
>                         die_errno("Cannot change to '%s/..'", cwd);
>         }

It should not die() if nongit_ok != NULL (gentle mode). Maybe
something like this on top:

diff --git a/setup.c b/setup.c
index 500c03e..625fb35 100644
--- a/setup.c
+++ b/setup.c
@@ -499,10 +499,17 @@ static const char
*setup_git_directory_gently_1(int *nongit_ok)
 		if (one_filesystem) {
 			if (stat("..", &buf))
 				die_errno("failed to stat '%s/..'", getcwd(err_cwd, sizeof(err_cwd)-1));
-			if (buf.st_dev != current_device)
+			if (buf.st_dev != current_device) {
+				if (nongit_ok) {
+					if (chdir(cwd))
+						die_errno("Cannot come back to cwd");
+					*nongit_ok = 1;
+					return NULL;
+				}
 				die("Not a git repository (or any parent up to %s/..)\n"
 					"Stopping at filesystem boundary since GIT_ONE_FILESYSTEM is set.",
 					getcwd(err_cwd, sizeof(err_cwd)-1));
+			}
 		}
 		if (chdir(".."))
 			die_errno("Cannot change to '%s/..'", cwd);

Another thing. Is err_cwd needed? I think "cwd" can be used, like
die_errno("Cannot change to %s/..", cwd) above. Hmm.. that die_errno
needs "cwd[offset] = '\0';" first. Maybe you can fix it too ;-)
-- 
Duy
--
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]