{"thread":{"id":"5787","subject":"[PATCH] lock_ref_sha1_basic does not remove empty directories on BSD","startedAt":"2006-10-02T17:23:53Z","lastAt":"2006-10-03T04:14:46Z","messageCount":2,"participants":["Dennis Stosberg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"28110","messageId":"20061002172353.G44b12bbc@leonov.stosberg.net","threadId":"5787","inReplyTo":null,"subject":"[PATCH] lock_ref_sha1_basic does not remove empty directories on BSD","fromName":"Dennis Stosberg","fromEmail":"dennis@stosberg.net","sentAt":"2006-10-02T17:23:53Z","receivedAt":"2006-10-02T17:23:53Z","isPatch":true,"sender":{"key":"dennis@stosberg.net","avatar":null},"body":"lock_ref_sha1_basic relies on errno beeing set to EISDIR by the\ncall to read() in resolve_ref() to detect directories.  But calling\nread() on a directory under NetBSD returns EPERM, and even succeeds\nfor local filesystems on FreeBSD.\n\nSigned-off-by: Dennis Stosberg <dennis@stosberg.net>\n---\n refs.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex aa4c4e0..305c1a9 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -234,6 +234,12 @@ const char *resolve_ref(const char *ref,\n \t\t\t}\n \t\t}\n \n+\t\t/* Is it a directory? */\n+\t\tif (S_ISDIR(st.st_mode)) {\n+\t\t\terrno = EISDIR;\n+\t\t\treturn NULL;\n+\t\t}\n+\n \t\t/*\n \t\t * Anything else, just open it and try to use it as\n \t\t * a ref\n-- \n1.4.2\n"},{"id":"28128","messageId":"7vu02mt4qx.fsf@assigned-by-dhcp.cox.net","threadId":"5787","inReplyTo":"20061002172353.G44b12bbc@leonov.stosberg.net","subject":"Re: [PATCH] lock_ref_sha1_basic does not remove empty directories on BSD","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-10-03T04:14:46Z","receivedAt":"2006-10-03T04:14:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dennis Stosberg <dennis@stosberg.net> writes:\n\n> lock_ref_sha1_basic relies on errno beeing set to EISDIR by the\n> call to read() in resolve_ref() to detect directories.  But calling\n> read() on a directory under NetBSD returns EPERM, and even succeeds\n> for local filesystems on FreeBSD.\n>\n> Signed-off-by: Dennis Stosberg <dennis@stosberg.net>\n\nThanks.\n\nI've always wondered about the code that follows where you\npatched.  It relies on either open() on a directory to fail, or\nread() from a file descriptor to return something other than\nwhat starts with 40-byte hexadecimal (or \"ref: blah\") to skip\ndirectories.\n\nYou might probably meant the patch primarily to fix the leftover\nempty directories issue in \"next\", but it is also the right\nthing to do for \"master\" (and even for \"maint\"), I think.\n\nI'll apply it to \"master\" and then merge it into \"next\".\n"}]}