提交 22c6e1d0 编写于 作者: D Daniel Barkalow 提交者: Junio C Hamano

[PATCH] Fix fetch completeness assumptions

Don't assume that any commit we have is complete; assume that any ref
we have is complete.
Signed-off-by: NDaniel Barkalow <barkalow@iabervon.org>
Signed-off-by: NJunio C Hamano <junkio@cox.net>
上级 61420a2c
...@@ -62,11 +62,21 @@ static int process_tree(struct tree *tree) ...@@ -62,11 +62,21 @@ static int process_tree(struct tree *tree)
return 0; return 0;
} }
struct commit_list *complete = NULL;
static int process_commit(struct commit *commit) static int process_commit(struct commit *commit)
{ {
if (parse_commit(commit)) if (parse_commit(commit))
return -1; return -1;
while (complete && complete->item->date >= commit->date) {
pop_most_recent_commit(&complete, 1);
}
if (commit->object.flags & 1)
return 0;
memcpy(current_commit_sha1, commit->object.sha1, 20); memcpy(current_commit_sha1, commit->object.sha1, 20);
if (get_tree) { if (get_tree) {
...@@ -78,8 +88,6 @@ static int process_commit(struct commit *commit) ...@@ -78,8 +88,6 @@ static int process_commit(struct commit *commit)
if (get_history) { if (get_history) {
struct commit_list *parents = commit->parents; struct commit_list *parents = commit->parents;
for (; parents; parents = parents->next) { for (; parents; parents = parents->next) {
if (has_sha1_file(parents->item->object.sha1))
continue;
if (process(parents->item->object.sha1, if (process(parents->item->object.sha1,
commit_type)) commit_type))
return -1; return -1;
...@@ -126,6 +134,7 @@ static int process_object(struct object *obj) ...@@ -126,6 +134,7 @@ static int process_object(struct object *obj)
static int process(unsigned char *sha1, const char *type) static int process(unsigned char *sha1, const char *type)
{ {
struct object *obj = lookup_object_type(sha1, type); struct object *obj = lookup_object_type(sha1, type);
if (has_sha1_file(sha1)) { if (has_sha1_file(sha1)) {
parse_object(sha1); parse_object(sha1);
/* We already have it, so we should scan it now. */ /* We already have it, so we should scan it now. */
...@@ -179,6 +188,19 @@ static int interpret_target(char *target, unsigned char *sha1) ...@@ -179,6 +188,19 @@ static int interpret_target(char *target, unsigned char *sha1)
return -1; return -1;
} }
static int mark_complete(const char *path, const unsigned char *sha1)
{
struct object *obj = parse_object(sha1);
while (obj->type == tag_type) {
obj = ((struct tag *) obj)->tagged;
parse_object(obj->sha1);
}
if (obj->type == commit_type) {
obj->flags |= 1;
insert_by_date((struct commit *) obj, &complete);
}
return 0;
}
int pull(char *target) int pull(char *target)
{ {
...@@ -191,6 +213,8 @@ int pull(char *target) ...@@ -191,6 +213,8 @@ int pull(char *target)
return -1; return -1;
} }
for_each_ref(mark_complete);
if (interpret_target(target, sha1)) if (interpret_target(target, sha1))
return error("Could not interpret %s as something to pull", return error("Could not interpret %s as something to pull",
target); target);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册