From: Christian Couder <chriscool@tuxfamily.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Ingo Molnar <mingo@elte.hu>
Subject: [PATCH] rev-list: estimate number of bisection step left
Date: Tue, 17 Feb 2009 06:09:44 +0100 [thread overview]
Message-ID: <20090217060944.488184b0.chriscool@tuxfamily.org> (raw)
This patch teaches "git rev-list --bisect-vars" to output an estimate
of the number of bisection step left along with the other variables it
already outputs.
The estimate is calculated using log2(all_revisions_left/2 - 1).
This is the most straightforward formula and seems to work fine in
practice.
We substract 1 to "all_revisions_left/2" because we allready know one
bad revision.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
---
builtin-rev-list.c | 27 +++++++++++++++++++++++++--
git-bisect.sh | 2 +-
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 436afa4..ee4abe7 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -574,6 +574,27 @@ static struct commit_list *find_bisection(struct commit_list *list,
return best;
}
+/*
+ * Estimate the number of bisect steps left
+ * Taking log2(all_revisions_left/2 - 1) seems to work fine.
+ * "- 1" is because we already know one bad revision.
+ */
+static int estimate_bisect_steps(int all)
+{
+ int log2 = 0;
+ int left = (all >> 1) - 1;
+
+ if (left <= 0)
+ return 0;
+
+ do {
+ left = left >> 1;
+ log2++;
+ } while (left);
+
+ return log2;
+}
+
int cmd_rev_list(int argc, const char **argv, const char *prefix)
{
struct commit_list *list;
@@ -688,12 +709,14 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
"bisect_nr=%d\n"
"bisect_good=%d\n"
"bisect_bad=%d\n"
- "bisect_all=%d\n",
+ "bisect_all=%d\n"
+ "bisect_steps=%d\n",
hex,
cnt - 1,
all - reaches - 1,
reaches - 1,
- all);
+ all,
+ estimate_bisect_steps(all));
return 0;
}
}
diff --git a/git-bisect.sh b/git-bisect.sh
index 85db4ba..6b23439 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -500,7 +500,7 @@ bisect_next() {
# commit is also a "skip" commit (see above).
exit_if_skipped_commits "$bisect_rev"
- bisect_checkout "$bisect_rev" "$bisect_nr revisions left to test after this"
+ bisect_checkout "$bisect_rev" "$bisect_nr revisions left to test after this (roughtly $bisect_steps steps)"
}
bisect_visualize() {
--
1.6.2.rc0.90.g0753.dirty
next reply other threads:[~2009-02-17 5:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-17 5:09 Christian Couder [this message]
2009-02-17 7:28 ` [PATCH] rev-list: estimate number of bisection step left Junio C Hamano
2009-02-19 5:16 ` Christian Couder
2009-02-19 5:26 ` Christian Couder
2009-02-19 5:32 ` Christian Couder
2009-02-19 6:02 ` John Tapsell
2009-02-19 6:49 ` Christian Couder
2009-02-17 14:44 ` Johannes Schindelin
2009-02-17 15:11 ` John Tapsell
2009-02-17 15:31 ` Johannes Schindelin
2009-02-17 15:36 ` John Tapsell
2009-02-17 15:39 ` Johannes Schindelin
2009-02-17 15:39 ` Thomas Rast
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=20090217060944.488184b0.chriscool@tuxfamily.org \
--to=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).