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

[PATCH] Do not verify filenames in a bare repository

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 20, 2007, 00:52 UTC
Message-ID
<Pine.LNX.4.63.0701200149010.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<eoqc09$454$2@sea.gmane.org>

For example, it makes no sense to check the presence of a file named "HEAD" when calling "git log HEAD" in a bare repository.

Noticed by Han-Wen Nienhuys.
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
---
	On Fri, 19 Jan 2007, Han-Wen Nienhuys wrote:
	> of course, when --bare is used, then HEAD is not ambiguous.
	> 
	> 
	> [lilydev@haring .git]$ git --bare log HEAD
	> fatal: ambiguous argument 'HEAD': both revision and filename
	> Use '--' to separate filenames from revisions
	Note that it would still fail in your case, since saying "--bare" 
	does not get picked up if the current directory is named ".git".
	I was close to sending a patch which sets the environment variable
	"GIT_IS_BARE" when calling git with "--bare", and checking that, 
	but decided against it: it is more likely you are about to shoot 
	yourself in the foot, because real bare repositories are not named 
	".git".
 setup.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/setup.c b/setup.c
index cc97f9f..7181560 100644
--- a/setup.c
+++ b/setup.c
@@ -95,6 +95,9 @@ void verify_non_filename(const char *prefix, const char *arg)
 	const char *name;
 	struct stat st;
 
+	if (is_bare_repository())
+		return;
+
 	if (*arg == '-')
 		return; /* flag */
 	name = prefix ? prefix_filename(prefix, strlen(prefix), arg) : arg;
-- 
1.5.0.rc1.g38843-dirty
Previous: Han-Wen NienhuysNext: Junio C Hamano
Message 2 of 4 in “BUG: git --bare log HEAD”
  1. Han-Wen NienhuysJan 19, 2007
  2. Do not verify filenames in a bare repositoryJohannes Schindelin, Jan 20, 2007
  3. Junio C HamanoJan 20, 2007
  4. Johannes SchindelinJan 20, 2007

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.