# [PATCH] setup.c:verify_non_filename(): don't die unnecessarily while disambiguating

2 messages from 2007-08-06 to 2007-08-06. Participants: Junio C Hamano, Shawn O. Pearce.
Thread: https://gitlist.dev/t/9402

## Junio C Hamano, 2007-08-06 07:24

Subject: [PATCH] setup.c:verify_non_filename(): don't die unnecessarily while disambiguating
Message-ID: <7vk5s9dt2b.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vk5s9dt2b.fsf%40assigned-by-dhcp.cox.net

```
If you have a working tree _file_ "foo", attempt to refer to a
branch "foo/bar" without -- to disambiguate, like this:

	$ git log foo/bar

tried to make sure that foo/bar cannot be naming a working tree
file "foo/bar" (in which case we would say "which one do you
want?  A rev or a working tree file?  clarify with -- please").
We run lstat("foo/bar") to check that.  If it does not succeed,
there is no ambiguity.

That is good.  But we also checked the error status for the
lstat() and expected it to fail with ENOENT.  For this
particular case, however, it fails with ENOTDIR.  That one
should be treated as "expected error" as well.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * This was from a real-life experience Shawn had.

 setup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/setup.c b/setup.c
index a45ea83..2b8e8c0 100644
--- a/setup.c
+++ b/setup.c
@@ -103,7 +103,7 @@ void verify_non_filename(const char *prefix, const char *arg)
 	if (!lstat(name, &st))
 		die("ambiguous argument '%s': both revision and filename\n"
 		    "Use '--' to separate filenames from revisions", arg);
-	if (errno != ENOENT)
+	if (errno != ENOENT && errno != ENOTDIR)
 		die("'%s': %s", arg, strerror(errno));
 }
 
-- 
1.5.3.rc4.15.ga2c3d

```

## Shawn O. Pearce, 2007-08-06 08:03

Subject: Re: [PATCH] setup.c:verify_non_filename(): don't die unnecessarily while disambiguating
Message-ID: <20070806080301.GL9527@spearce.org>
URL: https://gitlist.dev/e/20070806080301.GL9527%40spearce.org
In-Reply-To: <7vk5s9dt2b.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano <gitster@pobox.com> wrote:
> If you have a working tree _file_ "foo", attempt to refer to a
> branch "foo/bar" without -- to disambiguate, like this:
> 
> 	$ git log foo/bar
> ---
> 
>  * This was from a real-life experience Shawn had.

Ack.  I have done this many times, and every time I thought I was
going nuts.  Until Junio found this bug tonight.  Many thanks.

-- 
Shawn.

```
