]> git.ipfire.org Git - thirdparty/git.git/commitdiff
walker: drop fields of `struct walker` which are always 1
authorMartin Ågren <martin.agren@gmail.com>
Sun, 22 Apr 2018 18:12:50 +0000 (20:12 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 24 Apr 2018 01:55:04 +0000 (10:55 +0900)
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 <martin.agren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http-fetch.c
remote-curl.c
walker.c
walker.h

index a1564f5a41c2752d6ab3610f7703a2a68d9a9cd5..7b855d3349fae4af2bcc6bb81e06afbb2fb0bdd0 100644 (file)
@@ -56,9 +56,6 @@ int cmd_main(int argc, const char **argv)
 
        http_init(NULL, url, 0);
        walker = get_http_walker(url);
-       walker->get_tree = 1;
-       walker->get_history = 1;
-       walker->get_all = 1;
        walker->get_verbosely = get_verbosely;
        walker->get_recover = get_recover;
 
index a7c4c9b5ff4822e36bfc43a59d113c624537297e..dd86a6c4fa2e1b480fed5bfbc1fafffbc69261e7 100644 (file)
@@ -797,9 +797,6 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
                targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));
 
        walker = get_http_walker(url.buf);
-       walker->get_all = 1;
-       walker->get_tree = 1;
-       walker->get_history = 1;
        walker->get_verbosely = options.verbosity >= 3;
        walker->get_recover = 0;
        ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
index dffb9c8e37c220e71e108060dc5a81bc21f8370c..8eb7db7a52782c9862718979e5270724fd982d1f 100644 (file)
--- 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;
 }
 
index a869013e85110a0b64d8fe344c8bd67f5e8f7f09..6d8ae00e5b995f6565fab8b617e4629788c3c0c7 100644 (file)
--- a/walker.h
+++ b/walker.h
@@ -9,9 +9,6 @@ struct walker {
        void (*prefetch)(struct walker *, unsigned char *sha1);
        int (*fetch)(struct walker *, unsigned char *sha1);
        void (*cleanup)(struct walker *);
-       int get_tree;
-       int get_history;
-       int get_all;
        int get_verbosely;
        int get_recover;