[PATCH] setup.c: Improve 'Not a git repository' messages

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

 



Changed message "Not a git repository (or any of the parent directories)"
to the more precise message "No <.git> repository in <path> or its parent
directories".

If a filesystem boundary is encountered with
GIT_DISCOVERY_ACROSS_FILESYSTEM not set, the warning now goes first.
The warning is suppressed when search was stopped at $HOME to not confuse
users using a crypto home volume (assuming that users having a repository
at /home or / know what they are doing).

Thanks to Duy, Jonathan, Sverre and Josh for commenting.

Signed-off-by: Ralf Ebert <ralf@xxxxxxxxxxxx>
---
 setup.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/setup.c b/setup.c
index 2769160..adabdd8 100644
--- a/setup.c
+++ b/setup.c
@@ -431,7 +431,8 @@ const char *setup_git_directory_gently(int *nongit_ok)
 				*nongit_ok = 1;
 				return NULL;
 			}
-			die("Not a git repository (or any of the parent directories): %s", DEFAULT_GIT_DIR_ENVIRONMENT);
+			die("No %s repository in %s or its parent directories",
+				DEFAULT_GIT_DIR_ENVIRONMENT, cwd);
 		}
 		if (one_filesystem) {
 			if (stat("..", &buf)) {
@@ -445,9 +446,14 @@ const char *setup_git_directory_gently(int *nongit_ok)
 					*nongit_ok = 1;
 					return NULL;
 				}
-				cwd[offset] = '\0';
-				die("Not a git repository (or any parent up to mount parent %s)\n"
-				"Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).", cwd);
+				const char *home = getenv("HOME");
+				if (home == NULL || strncmp(home, cwd, offset) != 0) {
+					warning("Stopped searching for %s at %.*s "
+						"as GIT_DISCOVERY_ACROSS_FILESYSTEM is not set",
+						DEFAULT_GIT_DIR_ENVIRONMENT, offset, cwd);
+				}
+				die("No %s repository in %s or its parent directories",
+					DEFAULT_GIT_DIR_ENVIRONMENT, cwd);
 			}
 		}
 		if (chdir("..")) {
-- 
1.7.2.1.96.gb740

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