git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ralf Ebert" <ralf@ralfebert.de>
To: git@vger.kernel.org
Cc: Ralf Ebert <ralf@ralfebert.de>
Subject: [PATCH] setup.c: Improve 'Not a git repository' messages
Date: Sun, 15 Aug 2010 04:55:21 +0200	[thread overview]
Message-ID: <1281840921-1996-1-git-send-email-ralf@ralfebert.de> (raw)
In-Reply-To: <i43v6e$q00$1@dough.gmane.org>

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@ralfebert.de>
---
 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

  parent reply	other threads:[~2010-08-15  3:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-09 17:24 [PATCH] More readable 'Not a git repository' messages Ralf Ebert
2010-08-09 22:14 ` Nguyen Thai Ngoc Duy
2010-08-09 22:44   ` Ralf Ebert
2010-08-09 23:01     ` Jonathan Nieder
2010-08-09 23:34       ` Ralf Ebert
2010-08-10 11:31         ` Nguyen Thai Ngoc Duy
2010-08-10  2:49 ` Sverre Rabbelier
2010-08-10 15:52 ` Jared Hance
2010-08-10 22:34   ` Joshua Juran
2010-08-13 17:25 ` [PATCH/RFC v2] " Ralf Ebert
2010-08-13 17:30   ` Joshua Juran
2010-08-15  2:55   ` Ralf Ebert [this message]
2010-08-15  3:36     ` [PATCH] setup.c: Improve " Jonathan Nieder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1281840921-1996-1-git-send-email-ralf@ralfebert.de \
    --to=ralf@ralfebert.de \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).