All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] bisect--helper: `bisect_log` shell function in C
@ 2016-05-13 20:02 Pranit Bauva
  2016-05-13 20:02 ` [PATCH 2/2] bisect--helper: `bisect_voc` " Pranit Bauva
  2016-05-16  7:36 ` [PATCH 1/2] bisect--helper: `bisect_log` " Eric Sunshine
  0 siblings, 2 replies; 10+ messages in thread
From: Pranit Bauva @ 2016-05-13 20:02 UTC (permalink / raw)
  To: git; +Cc: christian.couder, chriscool, larsxschneider, Pranit Bauva

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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-05-23 11:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-13 20:02 [PATCH 1/2] bisect--helper: `bisect_log` shell function in C Pranit Bauva
2016-05-13 20:02 ` [PATCH 2/2] bisect--helper: `bisect_voc` " 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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.