walker: drop fields of `struct walker` which are always 1
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>
Martin Ågren committed
Apr 22, 2018 at 20:12 UTC
0b6b34295413410e4ca52df4671d2a217e56a57b
4 files changed
+8
-20
http-fetch.c
-3
@@ -56,9 +56,6 @@ int cmd_main(int argc, const char **argv)
56
57
http_init(NULL, url, 0);
58
walker = get_http_walker(url);
59
- walker->get_tree = 1;
60
- walker->get_history = 1;
61
- walker->get_all = 1;
59
walker->get_verbosely = get_verbosely;
60
walker->get_recover = get_recover;
61
remote-curl.c
-3
@@ -797,9 +797,6 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
797
targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));
798
799
walker = get_http_walker(url.buf);
800
- walker->get_all = 1;
801
- walker->get_tree = 1;
802
- walker->get_history = 1;
800
walker->get_verbosely = options.verbosity >= 3;
801
walker->get_recover = 0;
802
ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);
walker.c
+8
-11
@@ -72,6 +72,8 @@ static struct commit_list *complete = NULL;
72
73
static int process_commit(struct walker *walker, struct commit *commit)
74
{
75
+ struct commit_list *parents;
76
+
77
if (parse_commit(commit))
78
return -1;
79
@@ -86,19 +88,14 @@ static int process_commit(struct walker *walker, struct commit *commit)
88
89
walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
90
89
- if (walker->get_tree) {
90
- if (process(walker, &commit->tree->object))
91
+ if (process(walker, &commit->tree->object))
92
+ return -1;
93
+
94
+ for (parents = commit->parents; parents; parents = parents->next) {
95
+ if (process(walker, &parents->item->object))
96
return -1;
92
- if (!walker->get_all)
93
- walker->get_tree = 0;
94
- }
95
- if (walker->get_history) {
96
- struct commit_list *parents = commit->parents;
97
- for (; parents; parents = parents->next) {
98
- if (process(walker, &parents->item->object))
99
- return -1;
100
- }
97
}
98
+
99
return 0;
100
}
101
walker.h
-3
@@ -9,9 +9,6 @@ struct walker {
9
void (*prefetch)(struct walker *, unsigned char *sha1);
10
int (*fetch)(struct walker *, unsigned char *sha1);
11
void (*cleanup)(struct walker *);
12
- int get_tree;
13
- int get_history;
14
- int get_all;
12
int get_verbosely;
13
int get_recover;
14