git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Martin Ågren" <martin.agren@gmail.com>
To: git@vger.kernel.org
Cc: Ben Walton <bwalton@artsci.utoronto.ca>,
	Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/2] walker: drop fields of `struct walker` which are always 1
Date: Sun, 22 Apr 2018 20:12:50 +0200	[thread overview]
Message-ID: <44e0ee4a6617244e5d45806e100565f8f46a86c5.1524420451.git.martin.agren@gmail.com> (raw)
In-Reply-To: <367243f0c8215f702fd38152952f47121ab337b1.1524420451.git.martin.agren@gmail.com>

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>
---
 walker.h      |  3 ---
 http-fetch.c  |  3 ---
 remote-curl.c |  3 ---
 walker.c      | 19 ++++++++-----------
 4 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/walker.h b/walker.h
index a869013e85..6d8ae00e5b 100644
--- 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;
 
diff --git a/http-fetch.c b/http-fetch.c
index a1564f5a41..7b855d3349 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -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;
 
diff --git a/remote-curl.c b/remote-curl.c
index a7c4c9b5ff..dd86a6c4fa 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -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);
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;
 }
 
-- 
2.17.0


      reply	other threads:[~2018-04-22 18:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-22 18:12 [PATCH 1/2] http-fetch: make `-a` standard behaviour Martin Ågren
2018-04-22 18:12 ` Martin Ågren [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44e0ee4a6617244e5d45806e100565f8f46a86c5.1524420451.git.martin.agren@gmail.com \
    --to=martin.agren@gmail.com \
    --cc=bwalton@artsci.utoronto.ca \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).