qyz committed cb626bc

lock_ref_sha1_basic does not remove empty directories on BSD

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 <>
Signed-off-by: Junio C Hamano <>

Comments (0)

Files changed (1)

+		/* 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