@matheusbsbs / matheus-bagliano / commits / 33b650308c
Fork 0

Do not rename read-only files during a push

Win32 does not allow renaming read-only files (at least on a Samba share), making push into a local directory to fail. Thus, defer the chmod() call in index-pack.c:final() only after move_temp_to_file() was called. Signed-off-by: Petr Baudis <pasky@suse.cz> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Petr Baudis committed Oct 3, 2008 at 12:20 UTC 33b650308c9be52180c6556b17cb9fc1fba3adf4
1 file changed +3 -2
index-pack.c
+3 -2
@@ -790,7 +790,6 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
790 err = close(output_fd);
791 if (err)
792 die("error while closing pack file: %s", strerror(errno));
793 - chmod(curr_pack_name, 0444);
793 }
794
795 if (keep_msg) {
@@ -824,8 +823,9 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
823 if (move_temp_to_file(curr_pack_name, final_pack_name))
824 die("cannot store pack file");
825 }
826 + if (from_stdin)
827 + chmod(final_pack_name, 0444);
828
828 - chmod(curr_index_name, 0444);
829 if (final_index_name != curr_index_name) {
830 if (!final_index_name) {
831 snprintf(name, sizeof(name), "%s/pack/pack-%s.idx",
@@ -835,6 +835,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
835 if (move_temp_to_file(curr_index_name, final_index_name))
836 die("cannot store index file");
837 }
838 + chmod(final_index_name, 0444);
839
840 if (!from_stdin) {
841 printf("%s\n", sha1_to_hex(sha1));