Merge branch 'jk/squelch-missing-link-warning-for-unreachable'

Recent "git prune" traverses young unreachable objects to safekeep
old objects in the reachability chain from them, which sometimes
caused error messages that are unnecessarily alarming.

* jk/squelch-missing-link-warning-for-unreachable:
  suppress errors on missing UNINTERESTING links
  silence broken link warnings with revs->ignore_missing_links
  add quieter versions of parse_{tree,commit}
This commit is contained in:
Junio C Hamano 2015-06-11 09:29:58 -07:00
Родитель 0e04b248b5 ce4e7b2ac3
Коммит 43262d8d65
7 изменённых файлов: 34 добавлений и 9 удалений

Просмотреть файл

@ -357,7 +357,7 @@ int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long s
return 0; return 0;
} }
int parse_commit(struct commit *item) int parse_commit_gently(struct commit *item, int quiet_on_missing)
{ {
enum object_type type; enum object_type type;
void *buffer; void *buffer;
@ -370,7 +370,8 @@ int parse_commit(struct commit *item)
return 0; return 0;
buffer = read_sha1_file(item->object.sha1, &type, &size); buffer = read_sha1_file(item->object.sha1, &type, &size);
if (!buffer) if (!buffer)
return error("Could not read %s", return quiet_on_missing ? -1 :
error("Could not read %s",
sha1_to_hex(item->object.sha1)); sha1_to_hex(item->object.sha1));
if (type != OBJ_COMMIT) { if (type != OBJ_COMMIT) {
free(buffer); free(buffer);

Просмотреть файл

@ -59,7 +59,11 @@ struct commit *lookup_commit_reference_by_name(const char *name);
struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name); struct commit *lookup_commit_or_die(const unsigned char *sha1, const char *ref_name);
int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size); int parse_commit_buffer(struct commit *item, const void *buffer, unsigned long size);
int parse_commit(struct commit *item); int parse_commit_gently(struct commit *item, int quiet_on_missing);
static inline int parse_commit(struct commit *item)
{
return parse_commit_gently(item, 0);
}
void parse_commit_or_die(struct commit *item); void parse_commit_or_die(struct commit *item);
/* /*

Просмотреть файл

@ -81,7 +81,7 @@ static void process_tree(struct rev_info *revs,
die("bad tree object"); die("bad tree object");
if (obj->flags & (UNINTERESTING | SEEN)) if (obj->flags & (UNINTERESTING | SEEN))
return; return;
if (parse_tree(tree) < 0) { if (parse_tree_gently(tree, revs->ignore_missing_links) < 0) {
if (revs->ignore_missing_links) if (revs->ignore_missing_links)
return; return;
die("bad tree object %s", sha1_to_hex(obj->sha1)); die("bad tree object %s", sha1_to_hex(obj->sha1));

Просмотреть файл

@ -817,7 +817,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
parent = parent->next; parent = parent->next;
if (p) if (p)
p->object.flags |= UNINTERESTING; p->object.flags |= UNINTERESTING;
if (parse_commit(p) < 0) if (parse_commit_gently(p, 1) < 0)
continue; continue;
if (p->parents) if (p->parents)
mark_parents_uninteresting(p); mark_parents_uninteresting(p);
@ -844,7 +844,7 @@ static int add_parents_to_list(struct rev_info *revs, struct commit *commit,
for (parent = commit->parents; parent; parent = parent->next) { for (parent = commit->parents; parent; parent = parent->next) {
struct commit *p = parent->item; struct commit *p = parent->item;
if (parse_commit(p) < 0) if (parse_commit_gently(p, revs->ignore_missing_links) < 0)
return -1; return -1;
if (revs->show_source && !p->util) if (revs->show_source && !p->util)
p->util = commit->util; p->util = commit->util;

Просмотреть файл

@ -129,4 +129,19 @@ for repack in '' true; do
' '
done 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 test_done

5
tree.c
Просмотреть файл

@ -204,7 +204,7 @@ int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size)
return 0; return 0;
} }
int parse_tree(struct tree *item) int parse_tree_gently(struct tree *item, int quiet_on_missing)
{ {
enum object_type type; enum object_type type;
void *buffer; void *buffer;
@ -214,7 +214,8 @@ int parse_tree(struct tree *item)
return 0; return 0;
buffer = read_sha1_file(item->object.sha1, &type, &size); buffer = read_sha1_file(item->object.sha1, &type, &size);
if (!buffer) if (!buffer)
return error("Could not read %s", return quiet_on_missing ? -1 :
error("Could not read %s",
sha1_to_hex(item->object.sha1)); sha1_to_hex(item->object.sha1));
if (type != OBJ_TREE) { if (type != OBJ_TREE) {
free(buffer); free(buffer);

6
tree.h
Просмотреть файл

@ -16,7 +16,11 @@ struct tree *lookup_tree(const unsigned char *sha1);
int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size); int parse_tree_buffer(struct tree *item, void *buffer, unsigned long size);
int parse_tree(struct tree *tree); int parse_tree_gently(struct tree *tree, int quiet_on_missing);
static inline int parse_tree(struct tree *tree)
{
return parse_tree_gently(tree, 0);
}
void free_tree_buffer(struct tree *tree); void free_tree_buffer(struct tree *tree);
/* Parses and returns the tree in the given ent, chasing tags and commits. */ /* Parses and returns the tree in the given ent, chasing tags and commits. */