silence broken link warnings with revs->ignore_missing_links
We set revs->ignore_missing_links to instruct the revision-walking machinery that we know the history graph may be incomplete. For example, we use it when walking unreachable but recent objects; we want to add what we can, but it's OK if the history is incomplete. However, we still print error messages for the missing objects, which can be confusing. This is not an error, but just a normal situation when transitioning from a repository last pruned by an older git (which can leave broken segments of history) to a more recent one (where we try to preserve whole reachable segments). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 1, 2015 at 05:56 UTC
daf7d86783b1bd2065881a3f0957f69c79a52fd7
3 files changed
+17
-2
list-objects.c
+1
-1
@@ -81,7 +81,7 @@ static void process_tree(struct rev_info *revs,
81
die("bad tree object");
82
if (obj->flags & (UNINTERESTING | SEEN))
83
return;
84
- if (parse_tree(tree) < 0) {
84
+ if (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {
85
if (revs->ignore_missing_links)
86
return;
87
die("bad tree object %s", sha1_to_hex(obj->sha1));
revision.c
+1
-1
@@ -834,7 +834,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
834
for (parent = commit->parents; parent; parent = parent->next) {
835
struct commit *p = parent->item;
836
837
- if (parse_commit(p) < 0)
837
+ if (parse_commit_gently(p, revs->ignore_missing_links) < 0)
838
return -1;
839
if (revs->show_source && !p->util)
840
p->util = commit->util;
t/t6501-freshen-objects.sh
+15
@@ -129,4 +129,19 @@ for repack in '' true; do
129
'
130
done
131
132
+test_expect_success 'do not complain about existing broken links' '
133
+ cat >broken-commit <<-\EOF &&
134
+ tree 0000000000000000000000000000000000000001
135
+ parent 0000000000000000000000000000000000000002
136
+ author whatever <whatever@example.com> 1234 -0000
137
+ committer whatever <whatever@example.com> 1234 -0000
138
+
139
+ some message
140
+ EOF
141
+ commit=$(git hash-object -t commit -w broken-commit) &&
142
+ git gc 2>stderr &&
143
+ verbose git cat-file -e $commit &&
144
+ test_must_be_empty stderr
145
+'
146
+
147
test_done