@matheusbsbs / matheus-bagliano / commits / 6e7d0efa90
Fork 0

list-objects.c: don't add an unparsed NULL as a pending tree

"git rev-list --first-parent --boundary $commit^..$commit" segfaults on a merge commit since 8d2dfc4 (process_{tree,blob}: show objects without buffering, 2009-04-10), as it tried to dereference a commit that was discarded as UNINTERESTING without being parsed (hence lacking "tree"). Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Mar 14, 2011 at 12:29 UTC 6e7d0efa9058aa61147d9d18b33bd046055584e4
2 files changed +33 -1
list-objects.c
+6 -1
@@ -147,7 +147,12 @@ void traverse_commit_list(struct rev_info *revs,
147 struct commit *commit;
148
149 while ((commit = get_revision(revs)) != NULL) {
150 - add_pending_tree(revs, commit->tree);
150 + /*
151 + * an uninteresting boundary commit may not have its tree
152 + * parsed yet, but we are not going to show them anyway
153 + */
154 + if (commit->tree)
155 + add_pending_tree(revs, commit->tree);
156 show_commit(commit);
157 }
158 for (i = 0; i < revs->pending.nr; i++) {
t/t6110-rev-list-sparse.sh new
+27
@@ -0,0 +1,27 @@
1 +#!/bin/sh
2 +
3 +test_description='operations that cull histories in unusual ways'
4 +. ./test-lib.sh
5 +
6 +test_commit () {
7 + echo "$1" >"$1.file" &&
8 + git add "$1.file" &&
9 + test_tick &&
10 + git commit -m "$1"
11 +}
12 +
13 +test_expect_success setup '
14 + test_commit A &&
15 + test_commit B &&
16 + test_commit C &&
17 + git checkout -b side HEAD^ &&
18 + test_commit D &&
19 + test_commit E &&
20 + git merge master
21 +'
22 +
23 +test_expect_success 'rev-list --first-parent --boundary' '
24 + git rev-list --first-parent --boundary HEAD^..
25 +'
26 +
27 +test_done