{"thread":{"id":"27919","subject":"[PATCH v4 0/2] ls-tree: exit with non-zero status on error","startedAt":"2011-07-25T22:03:09Z","lastAt":"2011-07-25T22:05:13Z","messageCount":4,"participants":["Jon Seymour"],"isPatch":true,"patchVersion":4,"patchTotal":2},"messages":[{"id":"172019","messageId":"1311631391-12842-1-git-send-email-jon.seymour@gmail.com","threadId":"27919","inReplyTo":null,"subject":"[PATCH v4 0/2] ls-tree: exit with non-zero status on error","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-25T22:03:09Z","receivedAt":"2011-07-25T22:03:09Z","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\n| v2: Amended test per Jens Lehmann's suggestion.\n| v3: Generalize name of test script (in response to Junio's comment).\n|     Removed unnecessary local variable, per Jens' comment.\n| v4: Lexical simplification (Andreas, Junio), 0 or 1 exit code (Nguyen).\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-misc.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":"172020","messageId":"1311631391-12842-2-git-send-email-jon.seymour@gmail.com","threadId":"27919","inReplyTo":"1311631391-12842-1-git-send-email-jon.seymour@gmail.com","subject":"[v4 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-25T22:03:10Z","receivedAt":"2011-07-25T22:03:10Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"Expected to fail at this commit, fixed by subsequent commit.\n\nAdditional tests of adhoc or uncategorised nature should be added to this\nfile.\n\nImproved-by: Jens Lehmann <Jens.Lehmann@web.de>\nImproved-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n t/t3103-ls-tree-misc.sh |   24 ++++++++++++++++++++++++\n 1 files changed, 24 insertions(+), 0 deletions(-)\n create mode 100755 t/t3103-ls-tree-misc.sh\n\ndiff --git a/t/t3103-ls-tree-misc.sh b/t/t3103-ls-tree-misc.sh\nnew file mode 100755\nindex 0000000..c9c20f9\n--- /dev/null\n+++ b/t/t3103-ls-tree-misc.sh\n@@ -0,0 +1,24 @@\n+#!/bin/sh\n+\n+test_description='\n+Miscellaneous tests for git ls-tree.\n+\n+\t      1. git ls-tree fails in presence of tree damage.\n+\n+'\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_failure '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.g8394c\n"},{"id":"172021","messageId":"1311631391-12842-3-git-send-email-jon.seymour@gmail.com","threadId":"27919","inReplyTo":"1311631391-12842-1-git-send-email-jon.seymour@gmail.com","subject":"[v4 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-25T22:03:11Z","receivedAt":"2011-07-25T22:03:11Z","isPatch":false,"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 sets the exit code to 1, if the read_tree_recursive returns\nnon-zero and 0 otherwise.\n\nImproved-by: Jens Lehmann <Jens.Lehmann@web.de>\nImproved-by: Nguyen Thai Ngoc Duy <pclouds@gmail.com>\nImproved-by: Andreas Schwab <schwab@linux-m68k.org>\nImproved-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jon Seymour <jon.seymour@gmail.com>\n---\n builtin/ls-tree.c       |    3 +--\n t/t3103-ls-tree-misc.sh |    2 +-\n 2 files changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/ls-tree.c b/builtin/ls-tree.c\nindex f08c5b0..b1dcebd 100644\n--- a/builtin/ls-tree.c\n+++ b/builtin/ls-tree.c\n@@ -173,7 +173,6 @@ 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 \n-\treturn 0;\n+\treturn !!read_tree_recursive(tree, \"\", 0, 0, &pathspec, show_tree, NULL);\n }\ndiff --git a/t/t3103-ls-tree-misc.sh b/t/t3103-ls-tree-misc.sh\nindex c9c20f9..09dcf04 100755\n--- a/t/t3103-ls-tree-misc.sh\n+++ b/t/t3103-ls-tree-misc.sh\n@@ -16,7 +16,7 @@ test_expect_success 'setup' '\n \tgit commit -m test\n '\n \n-test_expect_failure 'ls-tree fails with non-zero exit code on broken tree' '\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-- \n1.7.6.347.g8394c\n"},{"id":"172022","messageId":"CAH3AnrrsWLTn7iCCrp29L9UJN1qbU5SX++6BidenJUQDyJEWNg@mail.gmail.com","threadId":"27919","inReplyTo":"1311631391-12842-1-git-send-email-jon.seymour@gmail.com","subject":"Re: [PATCH v4 0/2] ls-tree: exit with non-zero status on error","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-25T22:05:13Z","receivedAt":"2011-07-25T22:05:13Z","isPatch":true,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Tue, Jul 26, 2011 at 8:03 AM, Jon Seymour <jon.seymour@gmail.com> wrote:\n>\n> This patch uses the return code from read_tree_recursive instead.\n\nSorry, should be:\n\nThis change sets the exit code to 1, if the read_tree_recursive returns\nnon-zero and 0 otherwise.\n"}]}