move_temp_to_file(): do not forget to chmod() in "Coda hack" codepath
Now move_temp_to_file() is responsible for doing everything that is necessary to turn a tempfile in $GIT_DIR into its final form, it must make sure "Coda hack" codepath correctly makes the file read-only. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Mar 27, 2009 at 23:14 UTC
3be1f18e1b15c28ac6c750ff1a42576fd981d0f5
1 file changed
+3
-2
sha1_file.c
+3
-2
@@ -2263,12 +2263,12 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
2263
*
2264
* The same holds for FAT formatted media.
2265
*
2266
- * When this succeeds, we just return 0. We have nothing
2266
+ * When this succeeds, we just return. We have nothing
2267
* left to unlink.
2268
*/
2269
if (ret && ret != EEXIST) {
2270
if (!rename(tmpfile, filename))
2271
- return 0;
2271
+ goto out;
2272
ret = errno;
2273
}
2274
unlink(tmpfile);
@@ -2279,6 +2279,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
2279
/* FIXME!!! Collision check here ? */
2280
}
2281
2282
+out:
2283
if (chmod(filename, 0444) || adjust_shared_perm(filename))
2284
return error("unable to set permission to '%s'", filename);
2285
return 0;