{"thread":{"id":"15961","subject":"[PATCH/RFR&A] Do not rename read-only files during a push","startedAt":"2008-10-19T07:07:03Z","lastAt":"2008-10-19T17:41:46Z","messageCount":3,"participants":["Junio C Hamano","Shawn O. Pearce","Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"93414","messageId":"7v63np83mw.fsf@gitster.siamese.dyndns.org","threadId":"15961","inReplyTo":null,"subject":"[PATCH/RFR&A] Do not rename read-only files during a push","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-10-19T07:07:03Z","receivedAt":"2008-10-19T07:07:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This is on the \"merged to 'master' soon\" list, but has a small amend by me\n(namely, chmod of final pack is done only when we are writing the final\npack, i.e. reading from stdin) to fix breakages observed in tests.  It\nwould be nice to get a final Ack before moving it to 'master'.\n\n-- >8 --\n\nFrom: Petr Baudis <pasky@suse.cz>\n\nWin32 does not allow renaming read-only files (at least on a Samba\nshare), making push into a local directory to fail. Thus, defer\nthe chmod() call in index-pack.c:final() only after\nmove_temp_to_file() was called.\n\nSigned-off-by: Petr Baudis <pasky@suse.cz>\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n index-pack.c |    5 +++--\n 1 files changed, 3 insertions(+), 2 deletions(-)\n\ndiff --git a/index-pack.c b/index-pack.c\nindex d3a4d31..aec11cb 100644\n--- a/index-pack.c\n+++ b/index-pack.c\n@@ -790,7 +790,6 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\terr = close(output_fd);\n \t\tif (err)\n \t\t\tdie(\"error while closing pack file: %s\", strerror(errno));\n-\t\tchmod(curr_pack_name, 0444);\n \t}\n \n \tif (keep_msg) {\n@@ -824,8 +823,9 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\tif (move_temp_to_file(curr_pack_name, final_pack_name))\n \t\t\tdie(\"cannot store pack file\");\n \t}\n+\tif (from_stdin)\n+\t\tchmod(final_pack_name, 0444);\n \n-\tchmod(curr_index_name, 0444);\n \tif (final_index_name != curr_index_name) {\n \t\tif (!final_index_name) {\n \t\t\tsnprintf(name, sizeof(name), \"%s/pack/pack-%s.idx\",\n@@ -835,6 +835,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n \t\tif (move_temp_to_file(curr_index_name, final_index_name))\n \t\t\tdie(\"cannot store index file\");\n \t}\n+\tchmod(final_index_name, 0444);\n \n \tif (!from_stdin) {\n \t\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n-- \n1.6.0.2.767.g8f0e\n"},{"id":"93442","messageId":"20081019170237.GB14786@spearce.org","threadId":"15961","inReplyTo":"7v63np83mw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH/RFR&A] Do not rename read-only files during a push","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2008-10-19T17:02:37Z","receivedAt":"2008-10-19T17:02:37Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Junio C Hamano <gitster@pobox.com> wrote:\n> This is on the \"merged to 'master' soon\" list, but has a small amend by me\n> (namely, chmod of final pack is done only when we are writing the final\n> pack, i.e. reading from stdin) to fix breakages observed in tests.  It\n> would be nice to get a final Ack before moving it to 'master'.\n\nLooks fine to me.\n\n \n> From: Petr Baudis <pasky@suse.cz>\n> \n> Win32 does not allow renaming read-only files (at least on a Samba\n> share), making push into a local directory to fail. Thus, defer\n> the chmod() call in index-pack.c:final() only after\n> move_temp_to_file() was called.\n> \n> Signed-off-by: Petr Baudis <pasky@suse.cz>\n> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>\n> ---\n>  index-pack.c |    5 +++--\n>  1 files changed, 3 insertions(+), 2 deletions(-)\n> \n> diff --git a/index-pack.c b/index-pack.c\n> index d3a4d31..aec11cb 100644\n> --- a/index-pack.c\n> +++ b/index-pack.c\n> @@ -790,7 +790,6 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n>  \t\terr = close(output_fd);\n>  \t\tif (err)\n>  \t\t\tdie(\"error while closing pack file: %s\", strerror(errno));\n> -\t\tchmod(curr_pack_name, 0444);\n>  \t}\n>  \n>  \tif (keep_msg) {\n> @@ -824,8 +823,9 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n>  \t\tif (move_temp_to_file(curr_pack_name, final_pack_name))\n>  \t\t\tdie(\"cannot store pack file\");\n>  \t}\n> +\tif (from_stdin)\n> +\t\tchmod(final_pack_name, 0444);\n>  \n> -\tchmod(curr_index_name, 0444);\n>  \tif (final_index_name != curr_index_name) {\n>  \t\tif (!final_index_name) {\n>  \t\t\tsnprintf(name, sizeof(name), \"%s/pack/pack-%s.idx\",\n> @@ -835,6 +835,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,\n>  \t\tif (move_temp_to_file(curr_index_name, final_index_name))\n>  \t\t\tdie(\"cannot store index file\");\n>  \t}\n> +\tchmod(final_index_name, 0444);\n>  \n>  \tif (!from_stdin) {\n>  \t\tprintf(\"%s\\n\", sha1_to_hex(sha1));\n> -- \n> 1.6.0.2.767.g8f0e\n> \n\n-- \nShawn.\n"},{"id":"93473","messageId":"200810191941.46986.johannes.sixt@telecom.at","threadId":"15961","inReplyTo":"7v63np83mw.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH/RFR&A] Do not rename read-only files during a push","fromName":"Johannes Sixt","fromEmail":"johannes.sixt@telecom.at","sentAt":"2008-10-19T17:41:46Z","receivedAt":"2008-10-19T17:41:46Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"On Sonntag, 19. Oktober 2008, Junio C Hamano wrote:\n> From: Petr Baudis <pasky@suse.cz>\n>\n> Win32 does not allow renaming read-only files (at least on a Samba\n> share), making push into a local directory to fail. Thus, defer\n> the chmod() call in index-pack.c:final() only after\n> move_temp_to_file() was called.\n\nConcerning the Win32 aspect of this patch:\n\nAcked-by: Johannes Sixt <johannes.sixt@telecom.at>\n\n-- Hannes\n"}]}