{"thread":{"id":"43634","subject":"[PATCH] Catch errors when writing an index that contains invalid objects.","startedAt":"2006-11-13T13:50:00Z","lastAt":"2006-11-13T13:50:04Z","messageCount":2,"participants":["Johannes Sixt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"296142","messageId":"11634257782215-git-send-email-j.sixt@eudaptics.com","threadId":"43634","inReplyTo":"11634257784001-git-send-email-j.sixt@eudaptics.com","subject":"[PATCH] Catch errors when writing an index that contains invalid objects.","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2006-11-13T13:50:00Z","receivedAt":"2006-11-13T13:50:00Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nIf git-write-index is called without --missing-ok, it reports invalid\nobjects that it finds in the index. But without this patch it dies\nright away or may run into an infinite loop.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n cache-tree.c     |    2 ++\n t/t0000-basic.sh |   22 ++++++++++++++++++++++\n 2 files changed, 24 insertions(+), 0 deletions(-)\n\ndiff --git a/cache-tree.c b/cache-tree.c\nindex a803262..9b73c86 100644\n--- a/cache-tree.c\n+++ b/cache-tree.c\n@@ -282,6 +282,8 @@ static int update_one(struct cache_tree \n \t\t\t\t    baselen + sublen + 1,\n \t\t\t\t    missing_ok,\n \t\t\t\t    dryrun);\n+\t\tif (subcnt < 0)\n+\t\t\treturn subcnt;\n \t\ti += subcnt - 1;\n \t\tsub->used = 1;\n \t}\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 2c9bbb5..6aff0b8 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -209,6 +209,28 @@ test_expect_success \\\n     'validate object ID for a known tree.' \\\n     'test \"$ptree\" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'\n \n+cat >badobjects <<EOF\n+100644 blob 1000000000000000000000000000000000000000\tdir/file1\n+100644 blob 2000000000000000000000000000000000000000\tdir/file2\n+100644 blob 3000000000000000000000000000000000000000\tdir/file3\n+100644 blob 4000000000000000000000000000000000000000\tdir/file4\n+100644 blob 5000000000000000000000000000000000000000\tdir/file5\n+EOF\n+\n+rm .git/index\n+test_expect_success \\\n+    'put invalid objects into the index.' \\\n+    'git-update-index --index-info < badobjects'\n+\n+test_expect_failure \\\n+    'writing this tree without --missing-ok.' \\\n+    'git-write-tree'\n+\n+test_expect_success \\\n+    'writing this tree with --missing-ok.' \\\n+    'git-write-tree --missing-ok'\n+\n+\n ################################################################\n rm .git/index\n test_expect_success \\\n-- \n1.4.1.rc1.g47e5\n"},{"id":"297564","messageId":"11634257784001-git-send-email-j.sixt@eudaptics.com","threadId":"43634","inReplyTo":null,"subject":"[PATCH] test-lib.sh: A command dying due to a signal is an unexpected failure.","fromName":"Johannes Sixt","fromEmail":"j.sixt@eudaptics.com","sentAt":"2006-11-13T13:50:04Z","receivedAt":"2006-11-13T13:50:04Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"From: Johannes Sixt <johannes.sixt@telecom.at>\n\nWhen test_expect_failure detects that a command failed, it still has to\ntreat a program that crashed from a signal as unexpected failure.\n\nSigned-off-by: Johannes Sixt <johannes.sixt@telecom.at>\n---\n t/test-lib.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 07cb706..3895f16 100755\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -129,7 +129,7 @@ test_expect_failure () {\n \terror \"bug in the test script: not 2 parameters to test-expect-failure\"\n \tsay >&3 \"expecting failure: $2\"\n \ttest_run_ \"$2\"\n-\tif [ \"$?\" = 0 -a \"$eval_ret\" != 0 ]\n+\tif [ \"$?\" = 0 -a \"$eval_ret\" != 0 -a \"$eval_ret\" -lt 129 ]\n \tthen\n \t\ttest_ok_ \"$1\"\n \telse\n-- \n1.4.1.rc1.g47e5\n"}]}