{"thread":{"id":"24867","subject":"[PATCH] bundle: detect if bundle file cannot be created","startedAt":"2010-08-26T09:23:33Z","lastAt":"2010-08-27T20:31:47Z","messageCount":3,"participants":["Csaba Henk","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"149059","messageId":"20100826092333.GB32617@acharya.in.gluster.com","threadId":"24867","inReplyTo":null,"subject":"[PATCH] bundle: detect if bundle file cannot be created","fromName":"Csaba Henk","fromEmail":"csaba@gluster.com","sentAt":"2010-08-26T09:23:33Z","receivedAt":"2010-08-26T09:23:33Z","isPatch":true,"sender":{"key":"csaba@gluster.com","avatar":"https://avatars.githubusercontent.com/u/43937?v=4"},"body":"bundle command silently died with no sign of failure if it\ncould not create the bundle file. (Eg.: its path resovles to a directory,\nor the parent dir is sticky while file already exists and is owned\nby someone else.)\n---\n bundle.c          |    6 ++++--\n t/t5704-bundle.sh |    7 +++++++\n 2 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex ff97adc..3eb4ca2 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -372,8 +372,10 @@ int create_bundle(struct bundle_header *header, const char *path,\n \tclose(rls.in);\n \tif (finish_command(&rls))\n \t\treturn error (\"pack-objects died\");\n-\tif (!bundle_to_stdout)\n-\t\tcommit_lock_file(&lock);\n+\tif (!bundle_to_stdout) {\n+\t\tif (commit_lock_file(&lock))\n+\t\t\tdie_errno(\"cannot create bundle file\");\n+\t}\n \treturn 0;\n }\n \ndiff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh\nindex ddc3dc5..728ccd8 100755\n--- a/t/t5704-bundle.sh\n+++ b/t/t5704-bundle.sh\n@@ -30,6 +30,13 @@ test_expect_success 'tags can be excluded by rev-list options' '\n \n '\n \n+test_expect_success 'die if bundle file cannot be created' '\n+\n+\tmkdir adir &&\n+\ttest_must_fail git bundle create adir --all\n+\n+'\n+\n test_expect_failure 'bundle --stdin' '\n \n \techo master | git bundle create stdin-bundle.bdl --stdin &&\n-- \n1.7.2.2\n"},{"id":"149072","messageId":"7vpqx5l1yc.fsf@alter.siamese.dyndns.org","threadId":"24867","inReplyTo":"20100826092333.GB32617@acharya.in.gluster.com","subject":"Re: [PATCH] bundle: detect if bundle file cannot be created","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-26T17:26:51Z","receivedAt":"2010-08-26T17:26:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Csaba Henk <csaba@gluster.com> writes:\n\n> bundle command silently died with no sign of failure if it\n> could not create the bundle file. (Eg.: its path resovles to a directory,\n> or the parent dir is sticky while file already exists and is owned\n> by someone else.)\n> ---\n\nSign-off?\n\n> diff --git a/bundle.c b/bundle.c\n> index ff97adc..3eb4ca2 100644\n> --- a/bundle.c\n> +++ b/bundle.c\n> @@ -372,8 +372,10 @@ int create_bundle(struct bundle_header *header, const char *path,\n>  \tclose(rls.in);\n>  \tif (finish_command(&rls))\n>  \t\treturn error (\"pack-objects died\");\n> -\tif (!bundle_to_stdout)\n> -\t\tcommit_lock_file(&lock);\n> +\tif (!bundle_to_stdout) {\n> +\t\tif (commit_lock_file(&lock))\n> +\t\t\tdie_errno(\"cannot create bundle file\");\n> +\t}\n\nYou would want to parrot the path given by the caller, perhaps like this?\n\n\tdie_errno(\"cannot create '%s'\", path)\n\nThis function tries to report error to the caller in some places but\nrudely dies in some other places, so dying here is not a serious offence.\n\n> diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh\n> index ddc3dc5..728ccd8 100755\n> --- a/t/t5704-bundle.sh\n> +++ b/t/t5704-bundle.sh\n> @@ -30,6 +30,13 @@ test_expect_success 'tags can be excluded by rev-list options' '\n>  \n>  '\n>  \n> +test_expect_success 'die if bundle file cannot be created' '\n> +\n> +\tmkdir adir &&\n> +\ttest_must_fail git bundle create adir --all\n> +\n> +'\n\nI like it ;-)\n\nThanks.\n"},{"id":"149142","messageId":"i597bj$vtg$1@dough.gmane.org","threadId":"24867","inReplyTo":"20100826092333.GB32617@acharya.in.gluster.com","subject":"[PATCH v2] bundle: detect if bundle file cannot be created","fromName":"Csaba Henk","fromEmail":"csaba@gluster.com","sentAt":"2010-08-27T20:31:47Z","receivedAt":"2010-08-27T20:31:47Z","isPatch":true,"sender":{"key":"csaba@gluster.com","avatar":"https://avatars.githubusercontent.com/u/43937?v=4"},"body":"bundle command silently died with no sign of failure if it\ncould not create the bundle file. (Eg.: its path resovles to a directory,\nor the parent dir is sticky while file already exists and is owned\nby someone else.)\n\nSigned-off-by: Csaba Henk <csaba@gluster.com>\n---\n bundle.c          |    6 ++++--\n t/t5704-bundle.sh |    7 +++++++\n 2 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/bundle.c b/bundle.c\nindex ff97adc..65ea26b 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -372,8 +372,10 @@ int create_bundle(struct bundle_header *header, const char *path,\n \tclose(rls.in);\n \tif (finish_command(&rls))\n \t\treturn error (\"pack-objects died\");\n-\tif (!bundle_to_stdout)\n-\t\tcommit_lock_file(&lock);\n+\tif (!bundle_to_stdout) {\n+\t\tif (commit_lock_file(&lock))\n+\t\t\tdie_errno(\"cannot create '%s'\", path);\n+\t}\n \treturn 0;\n }\n \ndiff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh\nindex ddc3dc5..728ccd8 100755\n--- a/t/t5704-bundle.sh\n+++ b/t/t5704-bundle.sh\n@@ -30,6 +30,13 @@ test_expect_success 'tags can be excluded by rev-list options' '\n \n '\n \n+test_expect_success 'die if bundle file cannot be created' '\n+\n+\tmkdir adir &&\n+\ttest_must_fail git bundle create adir --all\n+\n+'\n+\n test_expect_failure 'bundle --stdin' '\n \n \techo master | git bundle create stdin-bundle.bdl --stdin &&\n-- \n1.7.2.2\n"}]}