summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d3ba675)
raw | patch | inline | side by side (parent: d3ba675)
author | Shawn Pearce <spearce@spearce.org> | |
Wed, 12 Jul 2006 05:00:16 +0000 (01:00 -0400) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Thu, 13 Jul 2006 06:16:29 +0000 (23:16 -0700) |
Linus Torvalds <torvalds@osdl.org> wrote:
It's entirely possible that we should just make that whole
if (ret == ENOENT)
go away. Yes, it's the right error code if a subdirectory is missing, and
yes, POSIX requires it, and yes, WXP is probably just a horrible piece of
sh*t, but on the other hand, I don't think git really has any serious
reason to even care.
It's entirely possible that we should just make that whole
if (ret == ENOENT)
go away. Yes, it's the right error code if a subdirectory is missing, and
yes, POSIX requires it, and yes, WXP is probably just a horrible piece of
sh*t, but on the other hand, I don't think git really has any serious
reason to even care.
sha1_file.c | patch | blob | history |
diff --git a/sha1_file.c b/sha1_file.c
index 8734d501fec50dc16b298e1473749c64ec25fe81..e666aec502f1aaadac62c72c152beeab15a8bd8e 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
static int link_temp_to_file(const char *tmpfile, char *filename)
{
int ret;
+ char *dir;
if (!link(tmpfile, filename))
return 0;
/*
- * Try to mkdir the last path component if that failed
- * with an ENOENT.
+ * Try to mkdir the last path component if that failed.
*
* Re-try the "link()" regardless of whether the mkdir
* succeeds, since a race might mean that somebody
* else succeeded.
*/
ret = errno;
- if (ret == ENOENT) {
- char *dir = strrchr(filename, '/');
- if (dir) {
- *dir = 0;
- mkdir(filename, 0777);
- if (adjust_shared_perm(filename))
- return -2;
- *dir = '/';
- if (!link(tmpfile, filename))
- return 0;
- ret = errno;
- }
+ dir = strrchr(filename, '/');
+ if (dir) {
+ *dir = 0;
+ mkdir(filename, 0777);
+ if (adjust_shared_perm(filename))
+ return -2;
+ *dir = '/';
+ if (!link(tmpfile, filename))
+ return 0;
+ ret = errno;
}
return ret;
}