Skip to content

Commit

Permalink
move_temp_to_file(): do not forget to chmod() in "Coda hack" codepath
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Mar 28, 2009
1 parent fb8b193 commit 3be1f18
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2263,12 +2263,12 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
*
* The same holds for FAT formatted media.
*
* When this succeeds, we just return 0. We have nothing
* When this succeeds, we just return. We have nothing
* left to unlink.
*/
if (ret && ret != EEXIST) {
if (!rename(tmpfile, filename))
return 0;
goto out;
ret = errno;
}
unlink(tmpfile);
Expand All @@ -2279,6 +2279,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
/* FIXME!!! Collision check here ? */
}

out:
if (chmod(filename, 0444) || adjust_shared_perm(filename))
return error("unable to set permission to '%s'", filename);
return 0;
Expand Down

0 comments on commit 3be1f18

Please sign in to comment.