Skip to content

Commit 0b6b342

Browse files
Martin Ågrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2e85a0c commit 0b6b342

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

http-fetch.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ int cmd_main(int argc, const char **argv)
5656

5757
http_init(NULL, url, 0);
5858
walker = get_http_walker(url);
59-
walker->get_tree = 1;
60-
walker->get_history = 1;
61-
walker->get_all = 1;
6259
walker->get_verbosely = get_verbosely;
6360
walker->get_recover = get_recover;
6461

remote-curl.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,9 +797,6 @@ static int fetch_dumb(int nr_heads, struct ref **to_fetch)
797797
targets[i] = xstrdup(oid_to_hex(&to_fetch[i]->old_oid));
798798

799799
walker = get_http_walker(url.buf);
800-
walker->get_all = 1;
801-
walker->get_tree = 1;
802-
walker->get_history = 1;
803800
walker->get_verbosely = options.verbosity >= 3;
804801
walker->get_recover = 0;
805802
ret = walker_fetch(walker, nr_heads, targets, NULL, NULL);

walker.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ static struct commit_list *complete = NULL;
7272

7373
static int process_commit(struct walker *walker, struct commit *commit)
7474
{
75+
struct commit_list *parents;
76+
7577
if (parse_commit(commit))
7678
return -1;
7779

@@ -86,19 +88,14 @@ static int process_commit(struct walker *walker, struct commit *commit)
8688

8789
walker_say(walker, "walk %s\n", oid_to_hex(&commit->object.oid));
8890

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))
9196
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-
}
10197
}
98+
10299
return 0;
103100
}
104101

walker.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ struct walker {
99
void (*prefetch)(struct walker *, unsigned char *sha1);
1010
int (*fetch)(struct walker *, unsigned char *sha1);
1111
void (*cleanup)(struct walker *);
12-
int get_tree;
13-
int get_history;
14-
int get_all;
1512
int get_verbosely;
1613
int get_recover;
1714

0 commit comments

Comments
 (0)