@matheusbsbs / matheus-bagliano / commits / 22c6e1d0f7
Fork 0

[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: Daniel Barkalow <barkalow@iabervon.org> Signed-off-by: Junio C Hamano <junkio@cox.net>

Daniel Barkalow committed Sep 14, 2005 at 21:31 UTC 22c6e1d0f76f58a425065d3e8e447b6366ccd98c
1 file changed +26 -2
fetch.c
+26 -2
@@ -62,11 +62,21 @@ static int process_tree(struct tree *tree)
62 return 0;
63 }
64
65 +struct commit_list *complete = NULL;
66 +
67 static int process_commit(struct commit *commit)
68 {
69 if (parse_commit(commit))
70 return -1;
71
72 + while (complete && complete->item->date >= commit->date) {
73 + pop_most_recent_commit(&complete, 1);
74 + }
75 +
76 +
77 + if (commit->object.flags & 1)
78 + return 0;
79 +
80 memcpy(current_commit_sha1, commit->object.sha1, 20);
81
82 if (get_tree) {
@@ -78,8 +88,6 @@ static int process_commit(struct commit *commit)
88 if (get_history) {
89 struct commit_list *parents = commit->parents;
90 for (; parents; parents = parents->next) {
81 - if (has_sha1_file(parents->item->object.sha1))
82 - continue;
91 if (process(parents->item->object.sha1,
92 commit_type))
93 return -1;
@@ -126,6 +134,7 @@ static int process_object(struct object *obj)
134 static int process(unsigned char *sha1, const char *type)
135 {
136 struct object *obj = lookup_object_type(sha1, type);
137 +
138 if (has_sha1_file(sha1)) {
139 parse_object(sha1);
140 /* We already have it, so we should scan it now. */
@@ -179,6 +188,19 @@ static int interpret_target(char *target, unsigned char *sha1)
188 return -1;
189 }
190
191 +static int mark_complete(const char *path, const unsigned char *sha1)
192 +{
193 + struct object *obj = parse_object(sha1);
194 + while (obj->type == tag_type) {
195 + obj = ((struct tag *) obj)->tagged;
196 + parse_object(obj->sha1);
197 + }
198 + if (obj->type == commit_type) {
199 + obj->flags |= 1;
200 + insert_by_date((struct commit *) obj, &complete);
201 + }
202 + return 0;
203 +}
204
205 int pull(char *target)
206 {
@@ -191,6 +213,8 @@ int pull(char *target)
213 return -1;
214 }
215
216 + for_each_ref(mark_complete);
217 +
218 if (interpret_target(target, sha1))
219 return error("Could not interpret %s as something to pull",
220 target);