From: Pranit Bauva <pranit.bauva@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, chriscool@tuxfamily.org,
larsxschneider@gmail.com, Pranit Bauva <pranit.bauva@gmail.com>
Subject: [PATCH 1/2] bisect--helper: `bisect_log` shell function in C
Date: Sat, 14 May 2016 01:32:16 +0530 [thread overview]
Message-ID: <1463169737-12701-1-git-send-email-pranit.bauva@gmail.com> (raw)
Reimplement the `bisect_log` shell function in C and add a
`--bisect-log` subcommand to `git bisect--helper` to call it from
git-bisect.sh .
Using `--bisect-log` subcommand is a temporary measure to port shell
function to C so as to use the existing test suite. As more functions
are ported, this subcommand will be retired and will be called by some
other method.
Mentored-by: Lars Schneider <larsxschneider@gmail.com>
Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com>
---
This can be applied on the pb/bisect branch
builtin/bisect--helper.c | 22 +++++++++++++++++++++-
git-bisect.sh | 7 +------
2 files changed, 22 insertions(+), 7 deletions(-)
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 2b21c02..87764fe 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -7,6 +7,7 @@
static const char * const git_bisect_helper_usage[] = {
N_("git bisect--helper --next-all [--no-checkout]"),
N_("git bisect--helper --write-terms <bad_term> <good_term>"),
+ N_("git bisect--helper --bisect-log"),
NULL
};
@@ -79,11 +80,26 @@ int write_terms(const char *bad, const char *good)
strbuf_release(&content);
return (res < 0) ? -1 : 0;
}
+
+int bisect_log(void)
+{
+ struct strbuf buf = STRBUF_INIT;
+
+ if (strbuf_read_file(&buf, ".git/BISECT_LOG", 256) < 0)
+ return error(_("We are not bisecting."));
+
+ printf("%s", buf.buf);
+ strbuf_release(&buf);
+
+ return 0;
+}
+
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
{
enum {
NEXT_ALL = 1,
- WRITE_TERMS
+ WRITE_TERMS,
+ BISECT_LOG
} cmdmode = 0;
int no_checkout = 0;
struct option options[] = {
@@ -91,6 +107,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
N_("perform 'git bisect next'"), NEXT_ALL),
OPT_CMDMODE(0, "write-terms", &cmdmode,
N_("write the terms to .git/BISECT_TERMS"), WRITE_TERMS),
+ OPT_CMDMODE(0, "bisect-log", &cmdmode,
+ N_("output contents of .git/BISECT_LOG"), BISECT_LOG),
OPT_BOOL(0, "no-checkout", &no_checkout,
N_("update BISECT_HEAD instead of checking out the current commit")),
OPT_END()
@@ -109,6 +127,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
if (argc != 2)
die(_("--write-terms requires two arguments"));
return write_terms(argv[0], argv[1]);
+ case BISECT_LOG:
+ return bisect_log();
default:
die("BUG: unknown subcommand '%d'", cmdmode);
}
diff --git a/git-bisect.sh b/git-bisect.sh
index 2dd7ec5..612a9c5 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -542,11 +542,6 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2
done
}
-bisect_log () {
- test -s "$GIT_DIR/BISECT_LOG" || die "$(gettext "We are not bisecting.")"
- cat "$GIT_DIR/BISECT_LOG"
-}
-
get_terms () {
if test -s "$GIT_DIR/BISECT_TERMS"
then
@@ -651,7 +646,7 @@ case "$#" in
replay)
bisect_replay "$@" ;;
log)
- bisect_log ;;
+ git bisect--helper --bisect-log ;;
run)
bisect_run "$@" ;;
terms)
--
2.8.2
next reply other threads:[~2016-05-13 20:04 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-13 20:02 Pranit Bauva [this message]
2016-05-13 20:02 ` [PATCH 2/2] bisect--helper: `bisect_voc` shell function in C Pranit Bauva
2016-05-13 20:07 ` Pranit Bauva
2016-05-16 6:40 ` Johannes Schindelin
2016-05-20 7:23 ` Pranit Bauva
2016-05-22 19:49 ` Pranit Bauva
2016-05-23 11:09 ` Johannes Schindelin
2016-05-16 7:49 ` Matthieu Moy
2016-05-16 7:36 ` [PATCH 1/2] bisect--helper: `bisect_log` " Eric Sunshine
2016-05-20 7:28 ` Pranit Bauva
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=1463169737-12701-1-git-send-email-pranit.bauva@gmail.com \
--to=pranit.bauva@gmail.com \
--cc=chriscool@tuxfamily.org \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=larsxschneider@gmail.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.
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).