{"thread":{"id":"26769","subject":"[PATCH] list-objects.c: don't add an unparsed NULL as a pending tree","startedAt":"2011-03-18T07:24:36Z","lastAt":"2011-03-18T07:24:36Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"163610","messageId":"7vbp18zya3.fsf@alter.siamese.dyndns.org","threadId":"26769","inReplyTo":null,"subject":"[PATCH] list-objects.c: don't add an unparsed NULL as a pending tree","fromName":"Junio C Hamano","fromEmail":"junio@pobox.com","sentAt":"2011-03-18T07:24:36Z","receivedAt":"2011-03-18T07:24:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"git rev-list --first-parent --boundary $commit^..$commit\" segfaults on a\nmerge commit since 8d2dfc4 (process_{tree,blob}: show objects without\nbuffering, 2009-04-10), as it tried to dereference a commit that was\ndiscarded as UNINTERESTING without being parsed (hence lacking \"tree\").\n\nSigned-off-by: Junio C Hamano <junio@pobox.com>\n---\n\n * The test has its own test_commit as I did this patch directly on top of\n   8d2dfc4; back then we didn't have the helper in test-lib.sh.  Need to\n   remove it when merging up to branches that have 0088496 (test-lib.sh:\n   introduce test_commit() and test_merge() helpers, 2009-01-27).\n\n list-objects.c             |    7 ++++++-\n t/t6110-rev-list-sparse.sh |   27 +++++++++++++++++++++++++++\n 2 files changed, 33 insertions(+), 1 deletions(-)\n create mode 100755 t/t6110-rev-list-sparse.sh\n\ndiff --git a/list-objects.c b/list-objects.c\nindex 5a4af62..518c665 100644\n--- a/list-objects.c\n+++ b/list-objects.c\n@@ -147,7 +147,12 @@ void traverse_commit_list(struct rev_info *revs,\n \tstruct commit *commit;\n \n \twhile ((commit = get_revision(revs)) != NULL) {\n-\t\tadd_pending_tree(revs, commit->tree);\n+\t\t/*\n+\t\t * an uninteresting boundary commit may not have its tree\n+\t\t * parsed yet, but we are not going to show them anyway\n+\t\t */\n+\t\tif (commit->tree)\n+\t\t\tadd_pending_tree(revs, commit->tree);\n \t\tshow_commit(commit);\n \t}\n \tfor (i = 0; i < revs->pending.nr; i++) {\ndiff --git a/t/t6110-rev-list-sparse.sh b/t/t6110-rev-list-sparse.sh\nnew file mode 100755\nindex 0000000..2a267e8\n--- /dev/null\n+++ b/t/t6110-rev-list-sparse.sh\n@@ -0,0 +1,27 @@\n+#!/bin/sh\n+\n+test_description='operations that cull histories in unusual ways'\n+. ./test-lib.sh\n+\n+test_commit () {\n+\techo \"$1\" >\"$1.file\" &&\n+\tgit add \"$1.file\" &&\n+\ttest_tick &&\n+\tgit commit -m \"$1\"\n+}\n+\n+test_expect_success setup '\n+\ttest_commit A &&\n+\ttest_commit B &&\n+\ttest_commit C &&\n+\tgit checkout -b side HEAD^ &&\n+\ttest_commit D &&\n+\ttest_commit E &&\n+\tgit merge master\n+'\n+\n+test_expect_success 'rev-list --first-parent --boundary' '\n+\tgit rev-list --first-parent --boundary HEAD^..\n+'\n+\n+test_done\n-- \n1.7.4.1.408.gb6b16\n"}]}