silence broken link warnings with revs->ignore_missing_links
authorJeff King <peff@peff.net>
Mon, 1 Jun 2015 09:56:37 +0000 (05:56 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Jun 2015 16:29:50 +0000 (09:29 -0700)
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>
list-objects.c
revision.c
t/t6501-freshen-objects.sh
index 2910becd6c65b66670215aefdf08e1933895aa39..90c21abc5cf2ee2d3f77a35277855fd964f91db4 100644 (file)
@@ -81,7 +81,7 @@ static void process_tree(struct rev_info *revs,
                die("bad tree object");
        if (obj->flags & (UNINTERESTING | SEEN))
                return;
-       if (parse_tree(tree) < 0) {
+       if (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {
                if (revs->ignore_missing_links)
                        return;
                die("bad tree object %s", sha1_to_hex(obj->sha1));
index 75dda928ea6be1dacd2fbeba5c0ce207ea46dd25..983e4c49ff77c7e89de44cddffb1d2fca4a52961 100644 (file)
@@ -834,7 +834,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
        for (parent = commit->parents; parent; parent = parent->next) {
                struct commit *p = parent->item;
 
-               if (parse_commit(p) < 0)
+               if (parse_commit_gently(p, revs->ignore_missing_links) < 0)
                        return -1;
                if (revs->show_source && !p->util)
                        p->util = commit->util;
index 157f3f91db1e54f3069e45a5087cdb6a8838c7db..2adf825076b9c8f774973dcc83686980dca7725b 100755 (executable)
@@ -129,4 +129,19 @@ for repack in '' true; do
        '
 done
 
+test_expect_success 'do not complain about existing broken links' '
+       cat >broken-commit <<-\EOF &&
+       tree 0000000000000000000000000000000000000001
+       parent 0000000000000000000000000000000000000002
+       author whatever <whatever@example.com> 1234 -0000
+       committer whatever <whatever@example.com> 1234 -0000
+
+       some message
+       EOF
+       commit=$(git hash-object -t commit -w broken-commit) &&
+       git gc 2>stderr &&
+       verbose git cat-file -e $commit &&
+       test_must_be_empty stderr
+'
+
 test_done