* [PATCH] lock_ref_sha1_basic does not remove empty directories on BSD
@ 2006-10-02 17:23 Dennis Stosberg
2006-10-03 4:14 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Dennis Stosberg @ 2006-10-02 17:23 UTC (permalink / raw)
To: git
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>
---
refs.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/refs.c b/refs.c
index aa4c4e0..305c1a9 100644
--- a/refs.c
+++ b/refs.c
@@ -234,6 +234,12 @@ const char *resolve_ref(const char *ref,
}
}
+ /* 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
--
1.4.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lock_ref_sha1_basic does not remove empty directories on BSD
2006-10-02 17:23 [PATCH] lock_ref_sha1_basic does not remove empty directories on BSD Dennis Stosberg
@ 2006-10-03 4:14 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2006-10-03 4:14 UTC (permalink / raw)
To: Dennis Stosberg; +Cc: git
Dennis Stosberg <dennis@stosberg.net> writes:
> 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>
Thanks.
I've always wondered about the code that follows where you
patched. It relies on either open() on a directory to fail, or
read() from a file descriptor to return something other than
what starts with 40-byte hexadecimal (or "ref: blah") to skip
directories.
You might probably meant the patch primarily to fix the leftover
empty directories issue in "next", but it is also the right
thing to do for "master" (and even for "maint"), I think.
I'll apply it to "master" and then merge it into "next".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-10-03 4:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-02 17:23 [PATCH] lock_ref_sha1_basic does not remove empty directories on BSD Dennis Stosberg
2006-10-03 4:14 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).