11 static int make_sure_we_have_it(unsigned char *sha1)
13 if (has_sha1_file(sha1))
18 static int process_tree(unsigned char *sha1)
20 struct tree *tree = lookup_tree(sha1);
21 struct tree_entry_list *entries;
26 for (entries = tree->entries; entries; entries = entries->next) {
27 if (make_sure_we_have_it(entries->item.tree->object.sha1))
29 if (entries->directory) {
30 if (process_tree(entries->item.tree->object.sha1))
37 static int process_commit(unsigned char *sha1)
39 struct commit *obj = lookup_commit(sha1);
41 if (make_sure_we_have_it(sha1))
44 if (parse_commit(obj))
48 if (make_sure_we_have_it(obj->tree->object.sha1))
50 if (process_tree(obj->tree->object.sha1))
56 struct commit_list *parents = obj->parents;
57 for (; parents; parents = parents->next) {
58 if (has_sha1_file(parents->item->object.sha1))
60 if (make_sure_we_have_it(parents->item->object.sha1)) {
61 /* The server might not have it, and
66 if (process_commit(parents->item->object.sha1))
73 int pull(char *target)
76 unsigned char sha1[20];
77 retval = get_sha1_hex(target, sha1);
80 retval = make_sure_we_have_it(sha1);
83 return process_commit(sha1);