* [PATCH] Solaris 5.8 returns ENOTDIR for inappropriate renames.
@ 2007-01-16 1:30 Jason Riedy
2007-01-16 2:56 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Jason Riedy @ 2007-01-16 1:30 UTC (permalink / raw)
To: git
The reflog code clears empty directories when rename returns
either EISDIR or ENOTDIR. Seems to be the only place.
Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
---
Haven't been keeping up with the list, so I apologize if I've
missed discussions related to these changes.
refs.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/refs.c b/refs.c
index 689ac50..851b573 100644
--- a/refs.c
+++ b/refs.c
@@ -837,7 +837,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
retry:
if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
- if (errno==EISDIR) {
+ if (errno==EISDIR || errno==ENOTDIR) {
if (remove_empty_directories(git_path("logs/%s", newref))) {
error("Directory not empty: logs/%s", newref);
goto rollback;
--
1.5.0.rc1.gf4b6c
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Solaris 5.8 returns ENOTDIR for inappropriate renames.
2007-01-16 1:30 Jason Riedy
@ 2007-01-16 2:56 ` Junio C Hamano
0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2007-01-16 2:56 UTC (permalink / raw)
To: Jason Riedy; +Cc: git
Jason Riedy <ejr@EECS.Berkeley.EDU> writes:
> The reflog code clears empty directories when rename returns
> either EISDIR or ENOTDIR. Seems to be the only place.
>
> Signed-off-by: Jason Riedy <ejr@cs.berkeley.edu>
> ---
> Haven't been keeping up with the list, so I apologize if I've
> missed discussions related to these changes.
>
> refs.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/refs.c b/refs.c
> index 689ac50..851b573 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -837,7 +837,7 @@ int rename_ref(const char *oldref, const char *newref, const char *logmsg)
>
> retry:
> if (log && rename(git_path("tmp-renamed-log"), git_path("logs/%s", newref))) {
> - if (errno==EISDIR) {
> + if (errno==EISDIR || errno==ENOTDIR) {
> if (remove_empty_directories(git_path("logs/%s", newref))) {
> error("Directory not empty: logs/%s", newref);
> goto rollback;
Sorry, I do not understand.
Before this codepath, we have done safe_create_directories() and
should have already errored out if the parent directory of
"logs/$newref" couldn't have been created for whatever reason.
So when this rename fails, we have a file ".git/tmp-renamed-log"
and a directory ".git/logs/foo", and we are trying to rename the
former to ".git/logs/foo/bar".
Now ".git/logs/foo/bar" might already exist as a directory, and
this error path is attempting to catch EISDIR that comes out
from it (and in that case, if there is nothing but empty
directories in the hierarchy under .git/logs/foo/bar, we
remove them and retry).
Does Solaris give ENOTDIR in such a case?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Solaris 5.8 returns ENOTDIR for inappropriate renames.
@ 2007-01-16 3:16 Jason Riedy
0 siblings, 0 replies; 3+ messages in thread
From: Jason Riedy @ 2007-01-16 3:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
And Junio C Hamano writes:
> > - if (errno==EISDIR) {
> > + if (errno==EISDIR || errno==ENOTDIR) {
> Now ".git/logs/foo/bar" might already exist as a directory, and
> this error path is attempting to catch EISDIR that comes out
> from it (and in that case, if there is nothing but empty
> directories in the hierarchy under .git/logs/foo/bar, we
> remove them and retry).
>
> Does Solaris give ENOTDIR in such a case?
Exactly. rename(file, directory) produces an error. Some
systems associate the error with the directory and give EISDIR.
Solaris (at least 5.8) associates the error with the file and
gives ENOTDIR.
Looks like SUS declares EISDIR as the correct errno. I didn't
realize that... I don't think it's worth a full compat wrapper
just for this, but I could be wrong.
It is worth including your very lucid explanation in the
routine's comments, though.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-01-16 3:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-16 3:16 [PATCH] Solaris 5.8 returns ENOTDIR for inappropriate renames Jason Riedy
-- strict thread matches above, loose matches on Subject: below --
2007-01-16 1:30 Jason Riedy
2007-01-16 2:56 ` 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).