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

bogus "fatal: Not a git repository"

From
Linus Torvalds <torvalds@osdl.org>
Date
May 25, 2006, 15:22 UTC
Message-ID
<Pine.LNX.4.64.0605250804390.5623@g5.osdl.org>

I was just testing that "git ls-remote" change by Junio, and when you're not in a git repository, it gives this totally bogus warning. The _target_ obviously has to be a git repository, but there's no reason why you'd have to be in a local git repo when doing an ls-remote.

The reason is commit 73136b2e8a8ee024320c5ac6a0f14f912432bf03 by Dscho: it adds calls to git-repo-config in git-parse-remote.sh to get the remote shorthands etc.

Now, either we should just hide and ignore the error from git-repo-config (probably bad, because some errors _are_ valid - like git-repo-config failing due to bad syntax in the config file), or we should just make git-repo-config quietly handle the case of not being in a git repository.

This does the latter: just quietly accepting (and doing nothing - trying to set a value will result in the lock-file failing) our lot in life sounds better than dying with a bogus error message.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
diff --git a/repo-config.c b/repo-config.c
index 127afd7..08fc4cc 100644
--- a/repo-config.c
+++ b/repo-config.c
@@ -108,7 +108,8 @@ static int get_value(const char* key_, c
 
 int main(int argc, const char **argv)
 {
-	setup_git_directory();
+	int nongit = 0;
+	setup_git_directory_gently(&nongit);
 
 	while (1 < argc) {
 		if (!strcmp(argv[1], "--int"))
Next: Johannes Schindelin
Message 1 of 2 in “bogus "fatal: Not a git repository"”
  1. Linus TorvaldsMay 25, 2006
  2. Johannes SchindelinMay 25, 2006

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.