X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=sha1_file.c;h=642f00d3d47c3d782c3dfe522d21819c1a67de30;hb=e24317b4d093e4b148996172d0b749f09a0e6f2e;hp=e45679975e7fcbfae0497f25ab56b6bbd0ff1155;hpb=2b2dabc29f53c5835868029585000ee487cf6cbb;p=git.git diff --git a/sha1_file.c b/sha1_file.c index e4567997..642f00d3 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -1232,18 +1232,22 @@ static int link_temp_to_file(const char *tmpfile, char *filename) int move_temp_to_file(const char *tmpfile, char *filename) { int ret = link_temp_to_file(tmpfile, filename); - if (ret) { - /* - * 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)) + + /* + * 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. + * + * The same holds for FAT formatted media. + * + * When this succeeds, we just return 0. We have nothing + * left to unlink. + */ + if (ret && ret != EEXIST) { + if (!rename(tmpfile, filename)) return 0; + ret = errno; } unlink(tmpfile); if (ret) {