git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH/RFC v2] More readable 'Not a git repository' messages

From
Ralf Ebert <info@ralfebert.de>
Date
Aug 13, 2010, 17:25 UTC
Message-ID
<i43v6e$q00$1@dough.gmane.org>
In-Reply-To
<i3pdkj$hut$1@dough.gmane.org>
* State the folder concerned with the operation
* GIT_DISCOVERY_ACROSS_FILESYSTEM warning goes first
* Supressed 'filesystem boundary' warning for $HOME (crypto home volumes
   are common, having a git repository at $HOME is uncommon)
* Improved wording of the messages
Signed-off-by: Ralf Ebert <info@ralfebert.de>
---
  setup.c |   12 ++++++++----
  1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/setup.c b/setup.c
index 2769160..dc4f2da 100644
--- a/setup.c
+++ b/setup.c
@@ -431,7 +431,7 @@ 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("%s is not in a git repository", cwd);
  		}
  		if (one_filesystem) {
  			if (stat("..", &buf)) {
@@ -445,9 +445,13 @@ 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 repository at %.*s "
+							"as GIT_DISCOVERY_ACROSS_FILESYSTEM is not set", offset, cwd);
+				}
+				die("%s is not in a git repository", cwd);
  			}
  		}
  		if (chdir("..")) {
-- 
1.7.2.1.96.g07594.dirty
Previous: Joshua JuranNext: Joshua Juran
Message 10 of 13 in “More readable 'Not a git repository' messages”
  1. More readable 'Not a git repository' messagesRalf Ebert, Aug 9, 2010
  2. Nguyen Thai Ngoc DuyAug 9, 2010
  3. Ralf EbertAug 9, 2010
  4. Jonathan NiederAug 9, 2010
  5. Ralf EbertAug 9, 2010
  6. Nguyen Thai Ngoc DuyAug 10, 2010
  7. Sverre RabbelierAug 10, 2010
  8. Jared HanceAug 10, 2010
  9. Joshua JuranAug 10, 2010
  10. More readable 'Not a git repository' messagesRalf Ebert, Aug 13, 2010
  11. Joshua JuranAug 13, 2010
  12. setup.c: Improve 'Not a git repository' messagesRalf Ebert, Aug 15, 2010
  13. Jonathan NiederAug 15, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.