Skip to contentSkip to conversation

BUG: git --bare log HEAD

PATCH In review Han-Wen Nienhuys 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

Signature · 1 line
 Han-Wen Nienhuys - [email protected] - http://www.xs4all.nl/~hanwen
#1 lore raw

PATCH 1/1 Do not verify filenames in a bare repository

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.

---

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(-)
setup.c +3 -0
index cc97f9f..7181560 100644
@@ -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;
Signature · 1 line
1.5.0.rc1.g38843-dirty
#2 lore raw

Re: [PATCH] Do not verify filenames in a bare repository

This feels very sane. Thanks.

A handful tests to make sure it catches the cases wants to catch and it does not hiccup with the cases it shouldn't catch would be appropriate, though.

#3 lore raw

Re: [PATCH] Do not verify filenames in a bare repository

Hi,

Quoted 1 line · Junio C Hamano

This feels very sane. Thanks.

I changed my mind. A saner check would be if the current directory starts with GIT_DIR, so that even (cd .git; git show HEAD) still works.

Quoted 3 lines

A handful tests to make sure it catches the cases wants to catch and it does not hiccup with the cases it shouldn't catch would be appropriate, though.

Sure. I'll resend in a few minutes.

Ciao,
Dscho