X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=walker.c;h=4984bf8b3d6658dc2571f66bd5142e67c0fe7d37;hb=a78305ffbca58e49a7cdad901df0ae779bbed8fb;hp=dffb9c8e37c220e71e108060dc5a81bc21f8370c;hpb=b5cc90f548375fa8d5ae78a2879eabae78f19ae4;p=platform%2Fupstream%2Fgit.git diff --git a/walker.c b/walker.c index dffb9c8..4984bf8 100644 --- a/walker.c +++ b/walker.c @@ -1,11 +1,14 @@ #include "cache.h" #include "walker.h" +#include "repository.h" +#include "object-store.h" #include "commit.h" #include "tree.h" #include "tree-walk.h" #include "tag.h" #include "blob.h" #include "refs.h" +#include "progress.h" static struct object_id current_commit_oid; @@ -47,12 +50,14 @@ static int process_tree(struct walker *walker, struct tree *tree) if (S_ISGITLINK(entry.mode)) continue; if (S_ISDIR(entry.mode)) { - struct tree *tree = lookup_tree(entry.oid); + struct tree *tree = lookup_tree(the_repository, + &entry.oid); if (tree) obj = &tree->object; } else { - struct blob *blob = lookup_blob(entry.oid); + struct blob *blob = lookup_blob(the_repository, + &entry.oid); if (blob) obj = &blob->object; } @@ -72,6 +77,8 @@ static struct commit_list *complete = NULL; static int process_commit(struct walker *walker, struct commit *commit) { + struct commit_list *parents; + if (parse_commit(commit)) return -1; @@ -86,19 +93,14 @@ static int process_commit(struct walker *walker, struct commit *commit) walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid)); - if (walker->get_tree) { - if (process(walker, &commit->tree->object)) + if (process(walker, &get_commit_tree(commit)->object)) + return -1; + + for (parents = commit->parents; parents; parents = parents->next) { + if (process(walker, &parents->item->object)) return -1; - if (!walker->get_all) - walker->get_tree = 0; - } - if (walker->get_history) { - struct commit_list *parents = commit->parents; - for (; parents; parents = parents->next) { - if (process(walker, &parents->item->object)) - return -1; - } } + return 0; } @@ -161,6 +163,11 @@ static int process(struct walker *walker, struct object *obj) static int loop(struct walker *walker) { struct object_list *elem; + struct progress *progress = NULL; + uint64_t nr = 0; + + if (walker->get_progress) + progress = start_delayed_progress(_("Fetching objects"), 0); while (process_queue) { struct object *obj = process_queue->item; @@ -175,15 +182,20 @@ static int loop(struct walker *walker) */ if (! (obj->flags & TO_SCAN)) { if (walker->fetch(walker, obj->oid.hash)) { + stop_progress(&progress); report_missing(obj); return -1; } } if (!obj->type) - parse_object(&obj->oid); - if (process_object(walker, obj)) + parse_object(the_repository, &obj->oid); + if (process_object(walker, obj)) { + stop_progress(&progress); return -1; + } + display_progress(progress, ++nr); } + stop_progress(&progress); return 0; } @@ -206,7 +218,8 @@ static int interpret_target(struct walker *walker, char *target, struct object_i static int mark_complete(const char *path, const struct object_id *oid, int flag, void *cb_data) { - struct commit *commit = lookup_commit_reference_gently(oid, 1); + struct commit *commit = lookup_commit_reference_gently(the_repository, + oid, 1); if (commit) { commit->object.flags |= COMPLETE; @@ -259,12 +272,14 @@ int walker_fetch(struct walker *walker, int targets, char **target, struct strbuf refname = STRBUF_INIT; struct strbuf err = STRBUF_INIT; struct ref_transaction *transaction = NULL; - struct object_id *oids = xmalloc(targets * sizeof(struct object_id)); + struct object_id *oids; char *msg = NULL; int i, ret = -1; save_commit_buffer = 0; + ALLOC_ARRAY(oids, targets); + if (write_ref) { transaction = ref_transaction_begin(&err); if (!transaction) { @@ -283,7 +298,7 @@ int walker_fetch(struct walker *walker, int targets, char **target, error("Could not interpret response from server '%s' as something to pull", target[i]); goto done; } - if (process(walker, lookup_unknown_object(oids[i].hash))) + if (process(walker, lookup_unknown_object(&oids[i]))) goto done; }