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>
This commit is contained in:
Junio C Hamano 2009-03-27 23:14:39 -07:00
parent fb8b193670
commit 3be1f18e1b

View File

@ -2263,12 +2263,12 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
* *
* The same holds for FAT formatted media. * 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. * left to unlink.
*/ */
if (ret && ret != EEXIST) { if (ret && ret != EEXIST) {
if (!rename(tmpfile, filename)) if (!rename(tmpfile, filename))
return 0; goto out;
ret = errno; ret = errno;
} }
unlink(tmpfile); unlink(tmpfile);
@ -2279,6 +2279,7 @@ int move_temp_to_file(const char *tmpfile, const char *filename)
/* FIXME!!! Collision check here ? */ /* FIXME!!! Collision check here ? */
} }
out:
if (chmod(filename, 0444) || adjust_shared_perm(filename)) if (chmod(filename, 0444) || adjust_shared_perm(filename))
return error("unable to set permission to '%s'", filename); return error("unable to set permission to '%s'", filename);
return 0; return 0;