Skip to content

Commit afce435

Browse files
committed
Merge branch 'maint-1.5.5' into maint-1.5.6
* maint-1.5.5: revision traversal and pack: notice and die on missing commit Conflicts: revision.c
2 parents 8a124b8 + 9279870 commit afce435

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

revision.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,14 +1599,16 @@ static struct commit *get_revision_1(struct rev_info *revs)
15991599
(commit->date < revs->max_age))
16001600
continue;
16011601
if (add_parents_to_list(revs, commit, &revs->commits, NULL) < 0)
1602-
return NULL;
1602+
die("Failed to traverse parents of commit %s",
1603+
sha1_to_hex(commit->object.sha1));
16031604
}
16041605

16051606
switch (simplify_commit(revs, commit)) {
16061607
case commit_ignore:
16071608
continue;
16081609
case commit_error:
1609-
return NULL;
1610+
die("Failed to simplify parents of commit %s",
1611+
sha1_to_hex(commit->object.sha1));
16101612
default:
16111613
return commit;
16121614
}

t/t5307-pack-missing-commit.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
test_description='pack should notice missing commit objects'
4+
5+
. ./test-lib.sh
6+
7+
test_expect_success setup '
8+
for i in 1 2 3 4 5
9+
do
10+
echo "$i" >"file$i" &&
11+
git add "file$i" &&
12+
test_tick &&
13+
git commit -m "$i" &&
14+
git tag "tag$i"
15+
done &&
16+
obj=$(git rev-parse --verify tag3) &&
17+
fanout=$(expr "$obj" : "\(..\)") &&
18+
remainder=$(expr "$obj" : "..\(.*\)") &&
19+
rm -f ".git/objects/$fanout/$remainder"
20+
'
21+
22+
test_expect_success 'check corruption' '
23+
test_must_fail git fsck
24+
'
25+
26+
test_expect_success 'rev-list notices corruption (1)' '
27+
test_must_fail git rev-list HEAD
28+
'
29+
30+
test_expect_success 'rev-list notices corruption (2)' '
31+
test_must_fail git rev-list --objects HEAD
32+
'
33+
34+
test_expect_success 'pack-objects notices corruption' '
35+
echo HEAD |
36+
test_must_fail git pack-objects --revs pack
37+
'
38+
39+
test_done

0 commit comments

Comments
 (0)