Skip to content

Commit 3be1f18

Browse files
committed
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 <[email protected]>
1 parent fb8b193 commit 3be1f18

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sha1_file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2263,12 +2263,12 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
22632263
*
22642264
* The same holds for FAT formatted media.
22652265
*
2266-
* When this succeeds, we just return 0. We have nothing
2266+
* When this succeeds, we just return. We have nothing
22672267
* left to unlink.
22682268
*/
22692269
if (ret && ret != EEXIST) {
22702270
if (!rename(tmpfile, filename))
2271-
return 0;
2271+
goto out;
22722272
ret = errno;
22732273
}
22742274
unlink(tmpfile);
@@ -2279,6 +2279,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
22792279
/* FIXME!!! Collision check here ? */
22802280
}
22812281

2282+
out:
22822283
if (chmod(filename, 0444) || adjust_shared_perm(filename))
22832284
return error("unable to set permission to '%s'", filename);
22842285
return 0;

0 commit comments

Comments
 (0)