Code

lock_ref_sha1_basic does not remove empty directories on BSD
authorDennis Stosberg <dennis@stosberg.net>
Mon, 2 Oct 2006 17:23:53 +0000 (19:23 +0200)
committerJunio C Hamano <junkio@cox.net>
Tue, 3 Oct 2006 08:02:27 +0000 (01:02 -0700)
lock_ref_sha1_basic relies on errno beeing set to EISDIR by the
call to read() in resolve_ref() to detect directories.  But calling
read() on a directory under NetBSD returns EPERM, and even succeeds
for local filesystems on FreeBSD.

Signed-off-by: Dennis Stosberg <dennis@stosberg.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
refs.c

diff --git a/refs.c b/refs.c
index 5e653141ceb8183cfb7922c3ad89fd1a0110647a..98327d798375d2bc966f877af227a03070ce5d1b 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -42,6 +42,12 @@ const char *resolve_ref(const char *path, unsigned char *sha1, int reading)
                        }
                }
 
+               /* Is it a directory? */
+               if (S_ISDIR(st.st_mode)) {
+                       errno = EISDIR;
+                       return NULL;
+               }
+
                /*
                 * Anything else, just open it and try to use it as
                 * a ref