git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	John Tapsell <johnflux@gmail.com>,
	Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: [PATCH 5/7] rev-list: move code to show bisect vars into its own function
Date: Thu, 12 Mar 2009 08:51:31 +0100	[thread overview]
Message-ID: <20090312085131.9c923d14.chriscool@tuxfamily.org> (raw)

This is a straightforward clean up to make "cmd_rev_list" function
smaller.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
 builtin-rev-list.c |  101 ++++++++++++++++++++++++++++------------------------
 1 files changed, 54 insertions(+), 47 deletions(-)

diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index b50d304..6e0466e 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -237,6 +237,57 @@ static void show_tried(struct commit_list *tried)
 	printf("'\n");
 }
 
+static int show_bisect_vars(int reaches, int all, int show_all, int skip)
+{
+	int cnt;
+	char hex[41];
+	struct commit_list *tried;
+
+	revs.commits = filter_skipped(revs.commits, &tried, show_all);
+
+	if (!revs.commits && !skip)
+		return 1;
+
+	/*
+	 * revs.commits can reach "reaches" commits among
+	 * "all" commits.  If it is good, then there are
+	 * (all-reaches) commits left to be bisected.
+	 * On the other hand, if it is bad, then the set
+	 * to bisect is "reaches".
+	 * A bisect set of size N has (N-1) commits further
+	 * to test, as we already know one bad one.
+	 */
+	cnt = all - reaches;
+	if (cnt < reaches)
+		cnt = reaches;
+	if (revs.commits)
+		strcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));
+	else
+		hex[0] = '\0';
+
+	if (show_all) {
+		traverse_commit_list(&revs, show_commit, show_object);
+		printf("------\n");
+	}
+
+	if (skip)
+		show_tried(tried);
+	printf("bisect_rev=%s\n"
+	       "bisect_nr=%d\n"
+	       "bisect_good=%d\n"
+	       "bisect_bad=%d\n"
+	       "bisect_all=%d\n"
+	       "bisect_steps=%d\n",
+	       hex,
+	       cnt - 1,
+	       all - reaches - 1,
+	       reaches - 1,
+	       all,
+	       estimate_bisect_steps(all));
+
+	return 0;
+}
+
 int cmd_rev_list(int argc, const char **argv, const char *prefix)
 {
 	struct commit_list *list;
@@ -332,57 +383,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
 
 	if (bisect_list) {
 		int reaches = reaches, all = all;
-		struct commit_list *tried;
 
 		revs.commits = find_bisection(revs.commits, &reaches, &all,
 					      bisect_find_all);
 
-		revs.commits = filter_skipped(revs.commits, &tried,
-					      bisect_show_all);
-
-		if (bisect_show_vars) {
-			int cnt;
-			char hex[41];
-			if (!revs.commits && !bisect_skip)
-				return 1;
-			/*
-			 * revs.commits can reach "reaches" commits among
-			 * "all" commits.  If it is good, then there are
-			 * (all-reaches) commits left to be bisected.
-			 * On the other hand, if it is bad, then the set
-			 * to bisect is "reaches".
-			 * A bisect set of size N has (N-1) commits further
-			 * to test, as we already know one bad one.
-			 */
-			cnt = all - reaches;
-			if (cnt < reaches)
-				cnt = reaches;
-			if (revs.commits)
-				strcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));
-			else
-				hex[0] = '\0';
-
-			if (bisect_show_all) {
-				traverse_commit_list(&revs, show_commit, show_object);
-				printf("------\n");
-			}
-
-			if (bisect_skip)
-				show_tried(tried);
-			printf("bisect_rev=%s\n"
-			       "bisect_nr=%d\n"
-			       "bisect_good=%d\n"
-			       "bisect_bad=%d\n"
-			       "bisect_all=%d\n"
-			       "bisect_steps=%d\n",
-			       hex,
-			       cnt - 1,
-			       all - reaches - 1,
-			       reaches - 1,
-			       all,
-			       estimate_bisect_steps(all));
-			return 0;
-		}
+		if (bisect_show_vars)
+			return show_bisect_vars(reaches, all,
+						bisect_show_all, bisect_skip);
 	}
 
 	traverse_commit_list(&revs,
-- 
1.6.2.83.g012a16.dirty

                 reply	other threads:[~2009-03-12  7:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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

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

  git send-email \
    --in-reply-to=20090312085131.9c923d14.chriscool@tuxfamily.org \
    --to=chriscool@tuxfamily.org \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=johnflux@gmail.com \
    --cc=mingo@elte.hu \
    /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.
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 NNTP newsgroup(s).