From 0b6b34295413410e4ca52df4671d2a217e56a57b Mon Sep 17 00:00:00 2001 From: Martin Ågren Date: Sun, 22 Apr 2018 20:12:50 +0200 Subject: walker: drop fields of `struct walker` which are always 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the previous commit, both users of `struct walker` set `get_tree`, `get_history` and `get_all` to 1. Drop those fields and simplify the walker implementation accordingly. Let's hope that any out-of-tree users will not mind this change. They should notice that the compilation fails as they try to set these fields. (If they do not set them, note that `get_http_walker()` leaves them undefined, so the behavior will have been undefined all the time.) Signed-off-by: Martin Ågren Signed-off-by: Junio C Hamano --- walker.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'walker.c') diff --git a/walker.c b/walker.c index dffb9c8e37..8eb7db7a52 100644 --- a/walker.c +++ b/walker.c @@ -72,6 +72,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 +88,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, &commit->tree->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; } -- cgit v1.3