]> asedeno.scripts.mit.edu Git - git.git/blobdiff - sha1_file.c
replace direct calls to unlink(2) with unlink_or_warn
[git.git] / sha1_file.c
index 8fe135dc61908103cf2d7de700794843f83db057..dd474116a8856b429c9416de5c3a149e11a9f70b 100644 (file)
@@ -2225,7 +2225,9 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
 {
        int ret = 0;
 
-       if (link(tmpfile, filename))
+       if (object_creation_mode == OBJECT_CREATION_USES_RENAMES)
+               goto try_rename;
+       else if (link(tmpfile, filename))
                ret = errno;
 
        /*
@@ -2240,11 +2242,12 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
         * left to unlink.
         */
        if (ret && ret != EEXIST) {
+       try_rename:
                if (!rename(tmpfile, filename))
                        goto out;
                ret = errno;
        }
-       unlink(tmpfile);
+       unlink_or_warn(tmpfile);
        if (ret) {
                if (ret != EEXIST) {
                        return error("unable to write sha1 filename %s: %s\n", filename, strerror(ret));