diff options
author | Junio C Hamano <gitster@pobox.com> | 2009-04-06 00:42:52 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2009-04-06 00:42:52 -0700 |
commit | 03a39a91842cf745e5fc27dbd6485aad44d839a4 (patch) | |
tree | d4536e303954fc52c189fc3140c46810e9832766 /sha1_file.c | |
parent | ccc852c37751c7bc8f81bfb71e6722291270bca5 (diff) | |
parent | 1b89eaa4bef44ef84f2af611d5db8727e3be266c (diff) | |
download | git-03a39a91842cf745e5fc27dbd6485aad44d839a4.tar.gz |
Merge branch 'jc/shared-literally'
* jc/shared-literally:
t1301: loosen test for forced modes
set_shared_perm(): sometimes we know what the final mode bits should look like
move_temp_to_file(): do not forget to chmod() in "Coda hack" codepath
Move chmod(foo, 0444) into move_temp_to_file()
"core.sharedrepository = 0mode" should set, not loosen
Diffstat (limited to 'sha1_file.c')
-rw-r--r-- | sha1_file.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sha1_file.c b/sha1_file.c index 37e833b77d..8fe135dc61 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -2216,11 +2216,15 @@ static void write_sha1_file_prepare(const void *buf, unsigned long len, } /* - * Move the just written object into its final resting place + * Move the just written object into its final resting place. + * NEEDSWORK: this should be renamed to finalize_temp_file() as + * "moving" is only a part of what it does, when no patch between + * master to pu changes the call sites of this function. */ int move_temp_to_file(const char *tmpfile, const char *filename) { int ret = 0; + if (link(tmpfile, filename)) ret = errno; @@ -2232,12 +2236,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); @@ -2248,6 +2252,9 @@ int move_temp_to_file(const char *tmpfile, const char *filename) /* FIXME!!! Collision check here ? */ } +out: + if (set_shared_perm(filename, (S_IFREG|0444))) + return error("unable to set permission to '%s'", filename); return 0; } @@ -2272,7 +2279,6 @@ static void close_sha1_file(int fd) { if (fsync_object_files) fsync_or_die(fd, "sha1 file"); - fchmod(fd, 0444); if (close(fd) != 0) die("error when closing sha1 file (%s)", strerror(errno)); } |