{"thread":{"id":"27895","subject":"[PATCH 0/2] Ensure git ls-tree exits with a non-zero exit code if read_tree_recursive fails.","startedAt":"2011-07-23T12:27:29Z","lastAt":"2011-07-23T18:01:44Z","messageCount":4,"participants":["Jon Seymour","Jens Lehmann"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"171887","messageId":"1311424051-29644-1-git-send-email-jon.seymour@gmail.com","threadId":"27895","inReplyTo":null,"subject":"[PATCH 0/2] Ensure git ls-tree exits with a non-zero exit code if read_tree_recursive fails.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-23T12:27:29Z","receivedAt":"2011-07-23T12:27:29Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"While working with a damaged repository, I noticed that git ls-tree was reporting an error \neven though it set a zero exit code. \n\nThis patch uses the return code from read_tree_recursive instead.\n\nJon Seymour (2):\n  Add a test to check that git ls-tree sets non-zero exit code on\n    error.\n  Ensure git ls-tree exits with a non-zero exit code if\n    read_tree_recursive fails.\n\n builtin/ls-tree.c               |    6 +++---\n t/t3103-ls-tree-missing-tree.sh |   19 +++++++++++++++++++\n 2 files changed, 22 insertions(+), 3 deletions(-)\n create mode 100755 t/t3103-ls-tree-missing-tree.sh\n\n-- \n1.7.6.347.g6a5a9c\n"},{"id":"171889","messageId":"1311424051-29644-2-git-send-email-jon.seymour@gmail.com","threadId":"27895","inReplyTo":"1311424051-29644-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH 1/2] Add a test to check that git ls-tree sets non-zero exit code on error.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-23T12:27:30Z","receivedAt":"2011-07-23T12:27:30Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Fails at this commit, fixed by subsequent commit.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t3103-ls-tree-missing-tree.sh |   19 +++++++++++++++++++\n 1 files changed, 19 insertions(+), 0 deletions(-)\n create mode 100755 t/t3103-ls-tree-missing-tree.sh\n\ndiff --git a/t/t3103-ls-tree-missing-tree.sh b/t/t3103-ls-tree-missing-tree.sh\nnew file mode 100755\nindex 0000000..365ac07\n--- /dev/null\n+++ b/t/t3103-ls-tree-missing-tree.sh\n@@ -0,0 +1,19 @@\n+#!/bin/sh\n+\n+test_description='ls-tree exits with non-zero status if it also reports an error'\n+\n+. ./test-lib.sh\n+\n+test_expect_success 'setup' '\n+\tmkdir a &&\n+\ttouch a/one &&\n+\tgit add a/one &&\n+\tgit commit -m test\n+'\n+\n+test_expect_success 'ls-tree fails with non-zero exit code on broken tree' '\n+\trm -f .git/objects/5f/cffbd6e4c5c5b8d81f5e9314b20e338e3ffff5 &&\n+\ttest_must_fail git ls-tree -r HEAD\n+'\n+\n+test_done\n-- \n1.7.6.347.g6a5a9c\n"},{"id":"171890","messageId":"1311424051-29644-3-git-send-email-jon.seymour@gmail.com","threadId":"27895","inReplyTo":"1311424051-29644-1-git-send-email-jon.seymour@gmail.com","subject":"[PATCH 2/2] Ensure git ls-tree exits with a non-zero exit code if read_tree_recursive fails.","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-23T12:27:31Z","receivedAt":"2011-07-23T12:27:31Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"In the case of a corrupt repository, git ls-tree may report an error but\npresently it exits with a code of 0.\n\nThis change uses the return code of read_tree_recursive instead.\n\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n builtin/ls-tree.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex f08c5b0..6d6c992 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -120,7 +120,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n {\n \tunsigned char sha1[20];\n \tstruct tree *tree;\n-\tint i, full_tree = 0;\n+\tint i, full_tree = 0, err;\n \tconst struct option ls_tree_options[] = {\n \t\tOPT_BIT('d', NULL, &ls_options, \"only show trees\",\n \t\t\tLS_TREE_ONLY),\n@@ -173,7 +173,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)\n \ttree = parse_tree_indirect(sha1);\n \tif (!tree)\n \t\tdie(\"not a tree object\");\n-\tread_tree_recursive(tree, \"\", 0, 0, &pathspec, show_tree, NULL);\n+\terr = read_tree_recursive(tree, \"\", 0, 0, &pathspec, show_tree, NULL);\n \n-\treturn 0;\n+\treturn err;\n }\n-- \n1.7.6.347.g6a5a9c\n"},{"id":"171894","messageId":"4E2B0C88.1030906@web.de","threadId":"27895","inReplyTo":"1311424051-29644-2-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH 1/2] Add a test to check that git ls-tree sets non-zero exit code on error.","fromName":"Jens Lehmann","fromEmail":"jens.lehmann@web.de","sentAt":"2011-07-23T18:01:44Z","receivedAt":"2011-07-23T18:01:44Z","isPatch":true,"sender":{"key":"jens.lehmann@web.de","avatar":"https://avatars.githubusercontent.com/u/135220?v=4"},"body":"Am 23.07.2011 14:27, schrieb Jon Seymour:\n> Fails at this commit, fixed by subsequent commit.\n\nMaybe use \"test_expect_failure\" here and change that to \"test_expect_success\"\nin the next commit?\n\n> Signed-off-by: Jon Seymour <jon.seymour@gmail.com>\n> ---\n>  t/t3103-ls-tree-missing-tree.sh |   19 +++++++++++++++++++\n>  1 files changed, 19 insertions(+), 0 deletions(-)\n>  create mode 100755 t/t3103-ls-tree-missing-tree.sh\n> \n> diff --git a/t/t3103-ls-tree-missing-tree.sh b/t/t3103-ls-tree-missing-tree.sh\n> new file mode 100755\n> index 0000000..365ac07\n> --- /dev/null\n> +++ b/t/t3103-ls-tree-missing-tree.sh\n> @@ -0,0 +1,19 @@\n> +#!/bin/sh\n> +\n> +test_description='ls-tree exits with non-zero status if it also reports an error'\n> +\n> +. ./test-lib.sh\n> +\n> +test_expect_success 'setup' '\n> +\tmkdir a &&\n> +\ttouch a/one &&\n> +\tgit add a/one &&\n> +\tgit commit -m test\n> +'\n> +\n> +test_expect_success 'ls-tree fails with non-zero exit code on broken tree' '\n> +\trm -f .git/objects/5f/cffbd6e4c5c5b8d81f5e9314b20e338e3ffff5 &&\n> +\ttest_must_fail git ls-tree -r HEAD\n> +'\n> +\n> +test_done\n"}]}