summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-03 22:16:18 (GMT)
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-05-03 22:16:18 (GMT)
commita31c6d022e2435a514fcc8ca57f9995c4376a986 (patch)
tree51a882a2dc62e0d3cdc79e0badc61559fb723481 /sha1_file.c
parentaac17941320f7f73e5d411b152bfd041572e8a66 (diff)
downloadgit-a31c6d022e2435a514fcc8ca57f9995c4376a986.zip
git-a31c6d022e2435a514fcc8ca57f9995c4376a986.tar.gz
git-a31c6d022e2435a514fcc8ca57f9995c4376a986.tar.bz2
sha1_file: make the new sha1 object writing be coda-friendly.
Coda doesn't like cross-directory hardlinks. So try to fall back on a plain rename instead.
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 8f57798..e6ce455 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -353,8 +353,21 @@ int write_sha1_file(char *buf, unsigned long len, const char *type, unsigned cha
close(fd);
ret = link(tmpfile, filename);
- if (ret < 0)
+ if (ret < 0) {
ret = errno;
+
+ /*
+ * Coda hack - coda doesn't like cross-directory links,
+ * so we fall back to a rename, which will mean that it
+ * won't be able to check collisions, but that's not a
+ * big deal.
+ *
+ * When this succeeds, we just return 0. We have nothing
+ * left to unlink.
+ */
+ if (ret == EXDEV && !rename(tmpfile, filename))
+ return 0;
+ }
unlink(tmpfile);
if (ret) {
if (ret != EEXIST) {