git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH v4 0/6]Finish converting git bisect to C part 4
@ 2021-08-17  8:14 Miriam Rubio
  2021-08-17  8:14 ` [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases Miriam Rubio
                   ` (5 more replies)
  0 siblings, 6 replies; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git; +Cc: Miriam Rubio

These patches correspond to a fourth part of patch series 
of Outreachy project "Finish converting `git bisect` from shell to C" 
started by Pranit Bauva and Tanushree Tumane
(https://public-inbox.org/git/pull.117.git.gitgitgadget@gmail.com) and
continued by me.

This fourth part is formed by reimplementations of some `git bisect` 
subcommands, addition of tests and removal of some temporary subcommands.

These patch series emails were generated from:
https://gitlab.com/mirucam/git/commits/git-bisect-work-part4-v4.1.

I would like to thank Junio Hamano, Andrzej Hunt and Christian Couder 
for reviewing this patch series.


General changes
---------------
* Rebase on master branch: 5d213e46bb (Git 2.33-rc2, 2021-08-11) 
to include latest updates in bisect-helper.c file.
* Add three tests requested by reviewers in v3 patch series in 
t6030-bisect-porcelain.sh file.

Specific changes
----------------


[5/6] bisect--helper: reimplement `bisect_run` shell function in C
* Content of the BISECT_RUN file is shown to the user.
* Use strvec_push() instead of xstrdup().
* Fix a bug on previous patch series regarding to 
BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND (-10) return code.

---


Miriam Rubio (3):
  t6030-bisect-porcelain: add tests to control bisect run exit cases
  t6030-bisect-porcelain: add test for bisect visualize
  bisect--helper: retire `--bisect-next-check` subcommand

Pranit Bauva (2):
  run-command: make `exists_in_PATH()` non-static
  bisect--helper: reimplement `bisect_visualize()`shell function in C

Tanushree Tumane (1):
  bisect--helper: reimplement `bisect_run` shell function in C

 builtin/bisect--helper.c    | 130 +++++++++++++++++++++++++++++++++---
 git-bisect.sh               |  87 +-----------------------
 run-command.c               |   2 +-
 run-command.h               |  12 ++++
 t/t6030-bisect-porcelain.sh |  21 ++++++
 5 files changed, 158 insertions(+), 94 deletions(-)

-- 
2.29.2


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

* [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases
  2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
@ 2021-08-17  8:14 ` Miriam Rubio
  2021-08-17  9:00   ` Bagas Sanjaya
  2021-08-17  8:14 ` [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize Miriam Rubio
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git; +Cc: Miriam Rubio

There is a gap on bisect run test coverage related with error exits.
Add two tests to control these error cases.

Signed-off-by: Miriam Rubio <mirucam@gmail.com>
---
 t/t6030-bisect-porcelain.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index a1baf4e451..f41453cc97 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -962,4 +962,18 @@ test_expect_success 'bisect handles annotated tags' '
 	grep "$bad is the first bad commit" output
 '
 
+test_expect_success 'bisect run fails with exit code equals or greater than 128' '
+	write_script test_script.sh <<-\EOF &&
+	exit 128 >/dev/null
+	EOF
+	test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
+'
+
+test_expect_success 'bisect run fails with exit code smaller than 0' '
+	write_script test_script.sh <<-\EOF &&
+	exit -1 >/dev/null
+	EOF
+	test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
+'
+
 test_done
-- 
2.29.2


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

* [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize
  2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
  2021-08-17  8:14 ` [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases Miriam Rubio
@ 2021-08-17  8:14 ` Miriam Rubio
  2021-08-17  9:03   ` Bagas Sanjaya
  2021-08-17  8:14 ` [PATCH v4 3/6] run-command: make `exists_in_PATH()` non-static Miriam Rubio
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git; +Cc: Miriam Rubio

Add a test to control breakages in bisect visualize command.

Signed-off-by: Miriam Rubio <mirucam@gmail.com>
---
 t/t6030-bisect-porcelain.sh | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index f41453cc97..99b7517400 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -976,4 +976,11 @@ test_expect_success 'bisect run fails with exit code smaller than 0' '
 	test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
 '
 
+test_expect_success 'bisect visualize with a filename with dash and space' '
+	echo "My test line" >> -hello\ 2 &&
+	git add -- -hello\ 2 &&
+	git commit --quiet -m "Add test line" -- -hello\ 2 &&
+	git bisect visualize -p -- -hello\ 2 > my_bisect_log.txt
+'
+
 test_done
-- 
2.29.2


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

* [PATCH v4 3/6] run-command: make `exists_in_PATH()` non-static
  2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
  2021-08-17  8:14 ` [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases Miriam Rubio
  2021-08-17  8:14 ` [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize Miriam Rubio
@ 2021-08-17  8:14 ` Miriam Rubio
  2021-08-17  8:14 ` [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C Miriam Rubio
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git; +Cc: Pranit Bauva, Tanushree Tumane, Miriam Rubio

From: Pranit Bauva <pranit.bauva@gmail.com>

Removes the `static` keyword from `exists_in_PATH()` function
and declares the function in `run-command.h` file.
The function will be used in bisect_visualize() in a later
commit.

Mentored by: Christian Couder <chriscool@tuxfamily.org>
Mentored by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
---
 run-command.c |  2 +-
 run-command.h | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/run-command.c b/run-command.c
index f72e72cce7..390f46819f 100644
--- a/run-command.c
+++ b/run-command.c
@@ -210,7 +210,7 @@ static char *locate_in_PATH(const char *file)
 	return NULL;
 }
 
-static int exists_in_PATH(const char *file)
+int exists_in_PATH(const char *file)
 {
 	char *r = locate_in_PATH(file);
 	int found = r != NULL;
diff --git a/run-command.h b/run-command.h
index af1296769f..54d74b706f 100644
--- a/run-command.h
+++ b/run-command.h
@@ -182,6 +182,18 @@ void child_process_clear(struct child_process *);
 
 int is_executable(const char *name);
 
+/**
+ * Search if a $PATH for a command exists.  This emulates the path search that
+ * execvp would perform, without actually executing the command so it
+ * can be used before fork() to prepare to run a command using
+ * execve() or after execvp() to diagnose why it failed.
+ *
+ * The caller should ensure that file contains no directory separators.
+ *
+ * Returns 1 if it is found in $PATH or 0 if the command could not be found.
+ */
+int exists_in_PATH(const char *file);
+
 /**
  * Start a sub-process. Takes a pointer to a `struct child_process`
  * that specifies the details and returns pipe FDs (if requested).
-- 
2.29.2


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

* [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C
  2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
                   ` (2 preceding siblings ...)
  2021-08-17  8:14 ` [PATCH v4 3/6] run-command: make `exists_in_PATH()` non-static Miriam Rubio
@ 2021-08-17  8:14 ` Miriam Rubio
  2021-08-17 11:30   ` Johannes Schindelin
  2021-08-17  8:14 ` [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell " Miriam Rubio
  2021-08-17  8:14 ` [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand Miriam Rubio
  5 siblings, 1 reply; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git
  Cc: Pranit Bauva, Christian Couder, Johannes Schindelin,
	Tanushree Tumane, Miriam Rubio

From: Pranit Bauva <pranit.bauva@gmail.com>

Reimplement the `bisect_visualize()` shell function
in C and also add `--bisect-visualize` subcommand to
`git bisect--helper` to call it from git-bisect.sh.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
---
 builtin/bisect--helper.c | 48 +++++++++++++++++++++++++++++++++++++++-
 git-bisect.sh            | 25 +--------------------
 2 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index f184eaeac6..4258429c1c 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -30,6 +30,7 @@ static const char * const git_bisect_helper_usage[] = {
 	N_("git bisect--helper --bisect-state (good|old) [<rev>...]"),
 	N_("git bisect--helper --bisect-replay <filename>"),
 	N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
+	N_("git bisect--helper --bisect-visualize"),
 	NULL
 };
 
@@ -1036,6 +1037,44 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
 	return res;
 }
 
+static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc)
+{
+	struct strvec args = STRVEC_INIT;
+	int flags = RUN_COMMAND_NO_STDIN, res = 0;
+	struct strbuf sb = STRBUF_INIT;
+
+	if (bisect_next_check(terms, NULL) != 0)
+		return BISECT_FAILED;
+
+	if (!argc) {
+		if ((getenv("DISPLAY") || getenv("SESSIONNAME") || getenv("MSYSTEM") ||
+		     getenv("SECURITYSESSIONID")) && exists_in_PATH("gitk"))
+			strvec_push(&args, "gitk");
+		else {
+			strvec_pushl(&args, "log", NULL);
+			flags |= RUN_GIT_CMD;
+		}
+	} else {
+		if (argv[0][0] == '-') {
+			strvec_pushl(&args, "log", NULL);
+			flags |= RUN_GIT_CMD;
+		} else if (strcmp(argv[0], "tig") && !starts_with(argv[0], "git"))
+			flags |= RUN_GIT_CMD;
+
+		strvec_pushv(&args, argv);
+	}
+
+	strvec_pushl(&args, "--bisect", "--", NULL);
+
+	strbuf_read_file(&sb, git_path_bisect_names(), 0);
+	sq_dequote_to_strvec(sb.buf, &args);
+	strbuf_release(&sb);
+
+	res = run_command_v_opt(args.v, flags);
+	strvec_clear(&args);
+	return res;
+}
+
 int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 {
 	enum {
@@ -1048,7 +1087,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 		BISECT_STATE,
 		BISECT_LOG,
 		BISECT_REPLAY,
-		BISECT_SKIP
+		BISECT_SKIP,
+		BISECT_VISUALIZE,
 	} cmdmode = 0;
 	int res = 0, nolog = 0;
 	struct option options[] = {
@@ -1070,6 +1110,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 			 N_("replay the bisection process from the given file"), BISECT_REPLAY),
 		OPT_CMDMODE(0, "bisect-skip", &cmdmode,
 			 N_("skip some commits for checkout"), BISECT_SKIP),
+		OPT_CMDMODE(0, "bisect-visualize", &cmdmode,
+			 N_("visualize the bisection"), BISECT_VISUALIZE),
 		OPT_BOOL(0, "no-log", &nolog,
 			 N_("no log for BISECT_WRITE")),
 		OPT_END()
@@ -1131,6 +1173,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 		get_terms(&terms);
 		res = bisect_skip(&terms, argv, argc);
 		break;
+	case BISECT_VISUALIZE:
+		get_terms(&terms);
+		res = bisect_visualize(&terms, argv, argc);
+		break;
 	default:
 		BUG("unknown subcommand %d", cmdmode);
 	}
diff --git a/git-bisect.sh b/git-bisect.sh
index 6a7afaea8d..95f7f3fb8c 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -39,29 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 TERM_BAD=bad
 TERM_GOOD=good
 
-bisect_visualize() {
-	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
-
-	if test $# = 0
-	then
-		if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
-			type gitk >/dev/null 2>&1
-		then
-			set gitk
-		else
-			set git log
-		fi
-	else
-		case "$1" in
-		git*|tig) ;;
-		-*)	set git log "$@" ;;
-		*)	set git "$@" ;;
-		esac
-	fi
-
-	eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES")
-}
-
 bisect_run () {
 	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
 
@@ -152,7 +129,7 @@ case "$#" in
 		# Not sure we want "next" at the UI level anymore.
 		git bisect--helper --bisect-next "$@" || exit ;;
 	visualize|view)
-		bisect_visualize "$@" ;;
+		git bisect--helper --bisect-visualize "$@" || exit;;
 	reset)
 		git bisect--helper --bisect-reset "$@" ;;
 	replay)
-- 
2.29.2


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

* [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell function in C
  2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
                   ` (3 preceding siblings ...)
  2021-08-17  8:14 ` [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C Miriam Rubio
@ 2021-08-17  8:14 ` Miriam Rubio
  2021-08-17 11:42   ` Johannes Schindelin
  2021-08-17  8:14 ` [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand Miriam Rubio
  5 siblings, 1 reply; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git; +Cc: Tanushree Tumane, Christian Couder, Miriam Rubio

From: Tanushree Tumane <tanushreetumane@gmail.com>

Reimplement the `bisect_run()` shell function
in C and also add `--bisect-run` subcommand to
`git bisect--helper` to call it from git-bisect.sh.

Mentored-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
---
 builtin/bisect--helper.c | 75 ++++++++++++++++++++++++++++++++++++++++
 git-bisect.sh            | 62 +--------------------------------
 2 files changed, 76 insertions(+), 61 deletions(-)

diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 4258429c1c..852e0a30fb 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -31,6 +31,7 @@ static const char * const git_bisect_helper_usage[] = {
 	N_("git bisect--helper --bisect-replay <filename>"),
 	N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
 	N_("git bisect--helper --bisect-visualize"),
+	N_("git bisect--helper --bisect-run <cmd>..."),
 	NULL
 };
 
@@ -1075,6 +1076,71 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
 	return res;
 }
 
+static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
+{
+	int res = BISECT_OK;
+	struct strbuf command = STRBUF_INIT;
+	struct strvec args = STRVEC_INIT;
+	struct strvec run_args = STRVEC_INIT;
+	int exit = 0;
+
+	if (bisect_next_check(terms, NULL))
+		return BISECT_FAILED;
+
+	if (argc)
+		sq_quote_argv(&command, argv);
+	else
+		return BISECT_FAILED;
+
+	strvec_push(&run_args, command.buf);
+
+	while (1) {
+		strvec_clear(&args);
+		exit = 1;
+
+		printf(_("running %s"), command.buf);
+		res = run_command_v_opt(run_args.v, RUN_USING_SHELL);
+
+		if (res < 0 || 128 <= res) {
+			error(_("bisect run failed: exit code %d from"
+				" '%s' is < 0 or >= 128"), res, command.buf);
+			strbuf_release(&command);
+			return res;
+		}
+
+		if (res == 125)
+			strvec_push(&args, "skip");
+		else if (res > 0)
+			strvec_push(&args, terms->term_bad);
+		else
+			strvec_push(&args, terms->term_good);
+
+		res = bisect_state(terms, args.v, args.nr);
+
+		if (res == BISECT_ONLY_SKIPPED_LEFT)
+			error(_("bisect run cannot continue any more"));
+		else if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) {
+			printf(_("bisect run success"));
+			res = BISECT_OK;
+		} else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
+			printf(_("bisect found first bad commit"));
+			res = BISECT_OK;
+		} else if (res) {
+			error(_("bisect run failed:'git bisect--helper --bisect-state"
+			" %s' exited with error code %d"), args.v[0], res);
+		} else {
+			exit = 0;
+		}
+
+		if (exit) {
+			strbuf_release(&command);
+			strvec_clear(&args);
+			strvec_clear(&run_args);
+			return res;
+		}
+	}
+}
+
 int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 {
 	enum {
@@ -1089,6 +1155,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 		BISECT_REPLAY,
 		BISECT_SKIP,
 		BISECT_VISUALIZE,
+		BISECT_RUN,
 	} cmdmode = 0;
 	int res = 0, nolog = 0;
 	struct option options[] = {
@@ -1112,6 +1179,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 			 N_("skip some commits for checkout"), BISECT_SKIP),
 		OPT_CMDMODE(0, "bisect-visualize", &cmdmode,
 			 N_("visualize the bisection"), BISECT_VISUALIZE),
+		OPT_CMDMODE(0, "bisect-run", &cmdmode,
+			 N_("use <cmd>... to automatically bisect."), BISECT_RUN),
 		OPT_BOOL(0, "no-log", &nolog,
 			 N_("no log for BISECT_WRITE")),
 		OPT_END()
@@ -1177,6 +1246,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 		get_terms(&terms);
 		res = bisect_visualize(&terms, argv, argc);
 		break;
+	case BISECT_RUN:
+		if (!argc)
+			return error(_("bisect run failed: no command provided."));
+		get_terms(&terms);
+		res = bisect_run(&terms, argv, argc);
+		break;
 	default:
 		BUG("unknown subcommand %d", cmdmode);
 	}
diff --git a/git-bisect.sh b/git-bisect.sh
index 95f7f3fb8c..e83d011e17 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
 TERM_BAD=bad
 TERM_GOOD=good
 
-bisect_run () {
-	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
-
-	test -n "$*" || die "$(gettext "bisect run failed: no command provided.")"
-
-	while true
-	do
-		command="$@"
-		eval_gettextln "running \$command"
-		"$@"
-		res=$?
-
-		# Check for really bad run error.
-		if [ $res -lt 0 -o $res -ge 128 ]
-		then
-			eval_gettextln "bisect run failed:
-exit code \$res from '\$command' is < 0 or >= 128" >&2
-			exit $res
-		fi
-
-		# Find current state depending on run success or failure.
-		# A special exit code of 125 means cannot test.
-		if [ $res -eq 125 ]
-		then
-			state='skip'
-		elif [ $res -gt 0 ]
-		then
-			state="$TERM_BAD"
-		else
-			state="$TERM_GOOD"
-		fi
-
-		git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN"
-		res=$?
-
-		cat "$GIT_DIR/BISECT_RUN"
-
-		if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \
-			>/dev/null
-		then
-			gettextln "bisect run cannot continue any more" >&2
-			exit $res
-		fi
-
-		if [ $res -ne 0 ]
-		then
-			eval_gettextln "bisect run failed:
-'bisect-state \$state' exited with error code \$res" >&2
-			exit $res
-		fi
-
-		if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null
-		then
-			gettextln "bisect run success"
-			exit 0;
-		fi
-
-	done
-}
-
 get_terms () {
 	if test -s "$GIT_DIR/BISECT_TERMS"
 	then
@@ -137,7 +77,7 @@ case "$#" in
 	log)
 		git bisect--helper --bisect-log || exit ;;
 	run)
-		bisect_run "$@" ;;
+		git bisect--helper --bisect-run "$@" || exit;;
 	terms)
 		git bisect--helper --bisect-terms "$@" || exit;;
 	*)
-- 
2.29.2


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

* [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand
  2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
                   ` (4 preceding siblings ...)
  2021-08-17  8:14 ` [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell " Miriam Rubio
@ 2021-08-17  8:14 ` Miriam Rubio
  2021-08-17 11:57   ` Johannes Schindelin
  5 siblings, 1 reply; 20+ messages in thread
From: Miriam Rubio @ 2021-08-17  8:14 UTC (permalink / raw)
  To: git; +Cc: Miriam Rubio

After reimplementation of `git bisect run` in C,
`--bisect-next-check` subcommand is not needed anymore.

Let's remove it from options list and code.

Mentored by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Miriam Rubio <mirucam@gmail.com>
---
 builtin/bisect--helper.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 852e0a30fb..d749747639 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -21,7 +21,6 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
 
 static const char * const git_bisect_helper_usage[] = {
 	N_("git bisect--helper --bisect-reset [<commit>]"),
-	N_("git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]"),
 	N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"),
 	N_("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
 					    " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
@@ -1200,12 +1199,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
 			return error(_("--bisect-reset requires either no argument or a commit"));
 		res = bisect_reset(argc ? argv[0] : NULL);
 		break;
-	case BISECT_NEXT_CHECK:
-		if (argc != 2 && argc != 3)
-			return error(_("--bisect-next-check requires 2 or 3 arguments"));
-		set_terms(&terms, argv[1], argv[0]);
-		res = bisect_next_check(&terms, argc == 3 ? argv[2] : NULL);
-		break;
 	case BISECT_TERMS:
 		if (argc > 1)
 			return error(_("--bisect-terms requires 0 or 1 argument"));
-- 
2.29.2


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

* Re: [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases
  2021-08-17  8:14 ` [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases Miriam Rubio
@ 2021-08-17  9:00   ` Bagas Sanjaya
  2021-08-17  9:23     ` Christian Couder
  0 siblings, 1 reply; 20+ messages in thread
From: Bagas Sanjaya @ 2021-08-17  9:00 UTC (permalink / raw)
  To: Miriam Rubio, git

On 17/08/21 15.14, Miriam Rubio wrote:

> +test_expect_success 'bisect run fails with exit code equals or greater than 128' '
> +	write_script test_script.sh <<-\EOF &&
> +	exit 128 >/dev/null
> +	EOF
> +	test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> +'

This only checks for exit code equals to 128. You should also check for 
exit code greater than 128, for example 255.

> +
> +test_expect_success 'bisect run fails with exit code smaller than 0' '
> +	write_script test_script.sh <<-\EOF &&
> +	exit -1 >/dev/null
> +	EOF
> +	test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> +'

This test looks OK, using -1 as representative of negative exit code. 
However, wording of test name can also be 'bisect run fails with 
negative exit code'.

Thanks for reviewing.

-- 
An old man doll... just what I always wanted! - Clara

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

* Re: [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize
  2021-08-17  8:14 ` [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize Miriam Rubio
@ 2021-08-17  9:03   ` Bagas Sanjaya
  2021-08-17 20:17     ` Miriam R.
  0 siblings, 1 reply; 20+ messages in thread
From: Bagas Sanjaya @ 2021-08-17  9:03 UTC (permalink / raw)
  To: Miriam Rubio, git

On 17/08/21 15.14, Miriam Rubio wrote:
> Add a test to control breakages in bisect visualize command.
> 
> Signed-off-by: Miriam Rubio <mirucam@gmail.com>
> ---
>   t/t6030-bisect-porcelain.sh | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> index f41453cc97..99b7517400 100755
> --- a/t/t6030-bisect-porcelain.sh
> +++ b/t/t6030-bisect-porcelain.sh
> @@ -976,4 +976,11 @@ test_expect_success 'bisect run fails with exit code smaller than 0' '
>   	test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
>   '
>   
> +test_expect_success 'bisect visualize with a filename with dash and space' '
> +	echo "My test line" >> -hello\ 2 &&
> +	git add -- -hello\ 2 &&
> +	git commit --quiet -m "Add test line" -- -hello\ 2 &&
> +	git bisect visualize -p -- -hello\ 2 > my_bisect_log.txt
> +'
> +
>   test_done
> 

Seems like you're testing with filename with dash and space. Does git 
bisect visualize have any problems handling such filenames?

-- 
An old man doll... just what I always wanted! - Clara

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

* Re: [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases
  2021-08-17  9:00   ` Bagas Sanjaya
@ 2021-08-17  9:23     ` Christian Couder
  2021-08-17 20:19       ` Miriam R.
  0 siblings, 1 reply; 20+ messages in thread
From: Christian Couder @ 2021-08-17  9:23 UTC (permalink / raw)
  To: Bagas Sanjaya; +Cc: Miriam Rubio, git

On Tue, Aug 17, 2021 at 11:03 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
>
> On 17/08/21 15.14, Miriam Rubio wrote:
>
> > +test_expect_success 'bisect run fails with exit code equals or greater than 128' '
> > +     write_script test_script.sh <<-\EOF &&
> > +     exit 128 >/dev/null
> > +     EOF
> > +     test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> > +'
>
> This only checks for exit code equals to 128. You should also check for
> exit code greater than 128, for example 255.
>
> > +
> > +test_expect_success 'bisect run fails with exit code smaller than 0' '
> > +     write_script test_script.sh <<-\EOF &&
> > +     exit -1 >/dev/null
> > +     EOF
> > +     test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> > +'
>
> This test looks OK, using -1 as representative of negative exit code.
> However, wording of test name can also be 'bisect run fails with
> negative exit code'.

Actually I am not sure that it makes sense to test an exit code
smaller than 0, as POSIX exit codes are between 0 and 255 (included).

For example:

$ bash -c 'exit -1'; echo $?
255

$ dash -c 'exit -1'; echo $?
dash: 1: exit: Illegal number: -1
2

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

* Re: [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C
  2021-08-17  8:14 ` [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C Miriam Rubio
@ 2021-08-17 11:30   ` Johannes Schindelin
  2021-08-17 20:19     ` Miriam R.
  0 siblings, 1 reply; 20+ messages in thread
From: Johannes Schindelin @ 2021-08-17 11:30 UTC (permalink / raw)
  To: Miriam Rubio; +Cc: git, Pranit Bauva, Christian Couder, Tanushree Tumane

Hi Miriam,

this looks good!

Just one suggestion (but I won't insist on it):

On Tue, 17 Aug 2021, Miriam Rubio wrote:

> @@ -1036,6 +1037,44 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
>  	return res;
>  }
>
> +static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc)
> +{
> +	struct strvec args = STRVEC_INIT;
> +	int flags = RUN_COMMAND_NO_STDIN, res = 0;
> +	struct strbuf sb = STRBUF_INIT;
> +
> +	if (bisect_next_check(terms, NULL) != 0)
> +		return BISECT_FAILED;
> +
> +	if (!argc) {
> +		if ((getenv("DISPLAY") || getenv("SESSIONNAME") || getenv("MSYSTEM") ||
> +		     getenv("SECURITYSESSIONID")) && exists_in_PATH("gitk"))
> +			strvec_push(&args, "gitk");
> +		else {
> +			strvec_pushl(&args, "log", NULL);

This could be written more concisely as `strvec_push(&args, "log")`.

> +			flags |= RUN_GIT_CMD;
> +		}
> +	} else {
> +		if (argv[0][0] == '-') {
> +			strvec_pushl(&args, "log", NULL);

Same here.

Otherwise, it looks good to me!

Thank you,
Dscho

> +			flags |= RUN_GIT_CMD;
> +		} else if (strcmp(argv[0], "tig") && !starts_with(argv[0], "git"))
> +			flags |= RUN_GIT_CMD;
> +
> +		strvec_pushv(&args, argv);
> +	}
> +
> +	strvec_pushl(&args, "--bisect", "--", NULL);
> +
> +	strbuf_read_file(&sb, git_path_bisect_names(), 0);
> +	sq_dequote_to_strvec(sb.buf, &args);
> +	strbuf_release(&sb);
> +
> +	res = run_command_v_opt(args.v, flags);
> +	strvec_clear(&args);
> +	return res;
> +}
> +
>  int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  {
>  	enum {
> @@ -1048,7 +1087,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  		BISECT_STATE,
>  		BISECT_LOG,
>  		BISECT_REPLAY,
> -		BISECT_SKIP
> +		BISECT_SKIP,
> +		BISECT_VISUALIZE,
>  	} cmdmode = 0;
>  	int res = 0, nolog = 0;
>  	struct option options[] = {
> @@ -1070,6 +1110,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  			 N_("replay the bisection process from the given file"), BISECT_REPLAY),
>  		OPT_CMDMODE(0, "bisect-skip", &cmdmode,
>  			 N_("skip some commits for checkout"), BISECT_SKIP),
> +		OPT_CMDMODE(0, "bisect-visualize", &cmdmode,
> +			 N_("visualize the bisection"), BISECT_VISUALIZE),
>  		OPT_BOOL(0, "no-log", &nolog,
>  			 N_("no log for BISECT_WRITE")),
>  		OPT_END()
> @@ -1131,6 +1173,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  		get_terms(&terms);
>  		res = bisect_skip(&terms, argv, argc);
>  		break;
> +	case BISECT_VISUALIZE:
> +		get_terms(&terms);
> +		res = bisect_visualize(&terms, argv, argc);
> +		break;
>  	default:
>  		BUG("unknown subcommand %d", cmdmode);
>  	}
> diff --git a/git-bisect.sh b/git-bisect.sh
> index 6a7afaea8d..95f7f3fb8c 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -39,29 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
>  TERM_BAD=bad
>  TERM_GOOD=good
>
> -bisect_visualize() {
> -	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
> -
> -	if test $# = 0
> -	then
> -		if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
> -			type gitk >/dev/null 2>&1
> -		then
> -			set gitk
> -		else
> -			set git log
> -		fi
> -	else
> -		case "$1" in
> -		git*|tig) ;;
> -		-*)	set git log "$@" ;;
> -		*)	set git "$@" ;;
> -		esac
> -	fi
> -
> -	eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES")
> -}
> -
>  bisect_run () {
>  	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
>
> @@ -152,7 +129,7 @@ case "$#" in
>  		# Not sure we want "next" at the UI level anymore.
>  		git bisect--helper --bisect-next "$@" || exit ;;
>  	visualize|view)
> -		bisect_visualize "$@" ;;
> +		git bisect--helper --bisect-visualize "$@" || exit;;
>  	reset)
>  		git bisect--helper --bisect-reset "$@" ;;
>  	replay)
> --
> 2.29.2
>
>

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

* Re: [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell function in C
  2021-08-17  8:14 ` [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell " Miriam Rubio
@ 2021-08-17 11:42   ` Johannes Schindelin
  2021-08-17 20:22     ` Miriam R.
  0 siblings, 1 reply; 20+ messages in thread
From: Johannes Schindelin @ 2021-08-17 11:42 UTC (permalink / raw)
  To: Miriam Rubio; +Cc: git, Tanushree Tumane, Christian Couder

Hi Miriam,

On Tue, 17 Aug 2021, Miriam Rubio wrote:

> From: Tanushree Tumane <tanushreetumane@gmail.com>
>
> Reimplement the `bisect_run()` shell function
> in C and also add `--bisect-run` subcommand to
> `git bisect--helper` to call it from git-bisect.sh.
>
> Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
> Signed-off-by: Miriam Rubio <mirucam@gmail.com>
> ---
>  builtin/bisect--helper.c | 75 ++++++++++++++++++++++++++++++++++++++++
>  git-bisect.sh            | 62 +--------------------------------
>  2 files changed, 76 insertions(+), 61 deletions(-)
>
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index 4258429c1c..852e0a30fb 100644
> --- a/builtin/bisect--helper.c
> +++ b/builtin/bisect--helper.c
> @@ -31,6 +31,7 @@ static const char * const git_bisect_helper_usage[] = {
>  	N_("git bisect--helper --bisect-replay <filename>"),
>  	N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
>  	N_("git bisect--helper --bisect-visualize"),
> +	N_("git bisect--helper --bisect-run <cmd>..."),
>  	NULL
>  };
>
> @@ -1075,6 +1076,71 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
>  	return res;
>  }
>
> +static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
> +{
> +	int res = BISECT_OK;
> +	struct strbuf command = STRBUF_INIT;
> +	struct strvec args = STRVEC_INIT;
> +	struct strvec run_args = STRVEC_INIT;
> +	int exit = 0;
> +
> +	if (bisect_next_check(terms, NULL))
> +		return BISECT_FAILED;
> +
> +	if (argc)
> +		sq_quote_argv(&command, argv);
> +	else
> +		return BISECT_FAILED;

Do we want to say something helpful here, e.g. _("bisect run failed: no
command provided.")?

> +
> +	strvec_push(&run_args, command.buf);
> +
> +	while (1) {
> +		strvec_clear(&args);
> +		exit = 1;
> +
> +		printf(_("running %s"), command.buf);
> +		res = run_command_v_opt(run_args.v, RUN_USING_SHELL);
> +
> +		if (res < 0 || 128 <= res) {
> +			error(_("bisect run failed: exit code %d from"
> +				" '%s' is < 0 or >= 128"), res, command.buf);
> +			strbuf_release(&command);
> +			return res;
> +		}
> +
> +		if (res == 125)
> +			strvec_push(&args, "skip");
> +		else if (res > 0)
> +			strvec_push(&args, terms->term_bad);
> +		else
> +			strvec_push(&args, terms->term_good);
> +
> +		res = bisect_state(terms, args.v, args.nr);

Since `args.nr` will always be 1, it would probably be better to use
something like this:

		const char *new_state;

		[...]
		if (res == 125)
			new_state = "skip";
		else
			new_state = res > 0 ?
				terms->term_bad : terms->term_good;

		res = bisect_state(terms, &new_state, 1);

Also: I think at this stage, an equivalent to `cat "$GIT_DIR/BISECT_RUN"`
is missing.

> +
> +		if (res == BISECT_ONLY_SKIPPED_LEFT)
> +			error(_("bisect run cannot continue any more"));
> +		else if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) {
> +			printf(_("bisect run success"));
> +			res = BISECT_OK;
> +		} else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
> +			printf(_("bisect found first bad commit"));
> +			res = BISECT_OK;
> +		} else if (res) {
> +			error(_("bisect run failed:'git bisect--helper --bisect-state"
> +			" %s' exited with error code %d"), args.v[0], res);
> +		} else {
> +			exit = 0;

Since the only purpose of `exit` seems to be that the loop should continue
if `exit` is set to 0, and it is only set here, how about doing away with
the variable altogether and writing `continue;` instead of `exit = 0;`?
Then the conditional block below does not need to be conditional.

Other than that: well done!

Ciao,
Dscho

> +		}
> +
> +		if (exit) {
> +			strbuf_release(&command);
> +			strvec_clear(&args);
> +			strvec_clear(&run_args);
> +			return res;
> +		}
> +	}
> +}
> +
>  int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  {
>  	enum {
> @@ -1089,6 +1155,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  		BISECT_REPLAY,
>  		BISECT_SKIP,
>  		BISECT_VISUALIZE,
> +		BISECT_RUN,
>  	} cmdmode = 0;
>  	int res = 0, nolog = 0;
>  	struct option options[] = {
> @@ -1112,6 +1179,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  			 N_("skip some commits for checkout"), BISECT_SKIP),
>  		OPT_CMDMODE(0, "bisect-visualize", &cmdmode,
>  			 N_("visualize the bisection"), BISECT_VISUALIZE),
> +		OPT_CMDMODE(0, "bisect-run", &cmdmode,
> +			 N_("use <cmd>... to automatically bisect."), BISECT_RUN),
>  		OPT_BOOL(0, "no-log", &nolog,
>  			 N_("no log for BISECT_WRITE")),
>  		OPT_END()
> @@ -1177,6 +1246,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  		get_terms(&terms);
>  		res = bisect_visualize(&terms, argv, argc);
>  		break;
> +	case BISECT_RUN:
> +		if (!argc)
> +			return error(_("bisect run failed: no command provided."));
> +		get_terms(&terms);
> +		res = bisect_run(&terms, argv, argc);
> +		break;
>  	default:
>  		BUG("unknown subcommand %d", cmdmode);
>  	}
> diff --git a/git-bisect.sh b/git-bisect.sh
> index 95f7f3fb8c..e83d011e17 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
>  TERM_BAD=bad
>  TERM_GOOD=good
>
> -bisect_run () {
> -	git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
> -
> -	test -n "$*" || die "$(gettext "bisect run failed: no command provided.")"
> -
> -	while true
> -	do
> -		command="$@"
> -		eval_gettextln "running \$command"
> -		"$@"
> -		res=$?
> -
> -		# Check for really bad run error.
> -		if [ $res -lt 0 -o $res -ge 128 ]
> -		then
> -			eval_gettextln "bisect run failed:
> -exit code \$res from '\$command' is < 0 or >= 128" >&2
> -			exit $res
> -		fi
> -
> -		# Find current state depending on run success or failure.
> -		# A special exit code of 125 means cannot test.
> -		if [ $res -eq 125 ]
> -		then
> -			state='skip'
> -		elif [ $res -gt 0 ]
> -		then
> -			state="$TERM_BAD"
> -		else
> -			state="$TERM_GOOD"
> -		fi
> -
> -		git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN"
> -		res=$?
> -
> -		cat "$GIT_DIR/BISECT_RUN"
> -
> -		if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \
> -			>/dev/null
> -		then
> -			gettextln "bisect run cannot continue any more" >&2
> -			exit $res
> -		fi
> -
> -		if [ $res -ne 0 ]
> -		then
> -			eval_gettextln "bisect run failed:
> -'bisect-state \$state' exited with error code \$res" >&2
> -			exit $res
> -		fi
> -
> -		if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null
> -		then
> -			gettextln "bisect run success"
> -			exit 0;
> -		fi
> -
> -	done
> -}
> -
>  get_terms () {
>  	if test -s "$GIT_DIR/BISECT_TERMS"
>  	then
> @@ -137,7 +77,7 @@ case "$#" in
>  	log)
>  		git bisect--helper --bisect-log || exit ;;
>  	run)
> -		bisect_run "$@" ;;
> +		git bisect--helper --bisect-run "$@" || exit;;
>  	terms)
>  		git bisect--helper --bisect-terms "$@" || exit;;
>  	*)
> --
> 2.29.2
>
>

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

* Re: [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand
  2021-08-17  8:14 ` [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand Miriam Rubio
@ 2021-08-17 11:57   ` Johannes Schindelin
  0 siblings, 0 replies; 20+ messages in thread
From: Johannes Schindelin @ 2021-08-17 11:57 UTC (permalink / raw)
  To: Miriam Rubio; +Cc: git

Hi Miriam,

On Tue, 17 Aug 2021, Miriam Rubio wrote:

> After reimplementation of `git bisect run` in C,
> `--bisect-next-check` subcommand is not needed anymore.
>
> Let's remove it from options list and code.
>
> Mentored by: Christian Couder <chriscool@tuxfamily.org>
> Signed-off-by: Miriam Rubio <mirucam@gmail.com>
> ---
>  builtin/bisect--helper.c | 7 -------
>  1 file changed, 7 deletions(-)

Exciting! This is inching closer and closer to a fully-built-in `git
bisect`.

Thank you so much!
Dscho

>
> diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> index 852e0a30fb..d749747639 100644
> --- a/builtin/bisect--helper.c
> +++ b/builtin/bisect--helper.c
> @@ -21,7 +21,6 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
>
>  static const char * const git_bisect_helper_usage[] = {
>  	N_("git bisect--helper --bisect-reset [<commit>]"),
> -	N_("git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]"),
>  	N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"),
>  	N_("git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]"
>  					    " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
> @@ -1200,12 +1199,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
>  			return error(_("--bisect-reset requires either no argument or a commit"));
>  		res = bisect_reset(argc ? argv[0] : NULL);
>  		break;
> -	case BISECT_NEXT_CHECK:
> -		if (argc != 2 && argc != 3)
> -			return error(_("--bisect-next-check requires 2 or 3 arguments"));
> -		set_terms(&terms, argv[1], argv[0]);
> -		res = bisect_next_check(&terms, argc == 3 ? argv[2] : NULL);
> -		break;
>  	case BISECT_TERMS:
>  		if (argc > 1)
>  			return error(_("--bisect-terms requires 0 or 1 argument"));
> --
> 2.29.2
>
>

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

* Re: [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize
  2021-08-17  9:03   ` Bagas Sanjaya
@ 2021-08-17 20:17     ` Miriam R.
  0 siblings, 0 replies; 20+ messages in thread
From: Miriam R. @ 2021-08-17 20:17 UTC (permalink / raw)
  To: Bagas Sanjaya; +Cc: git

Hi Bagas,

El mar, 17 ago 2021 a las 11:03, Bagas Sanjaya
(<bagasdotme@gmail.com>) escribió:
>
> On 17/08/21 15.14, Miriam Rubio wrote:
> > Add a test to control breakages in bisect visualize command.
> >
> > Signed-off-by: Miriam Rubio <mirucam@gmail.com>
> > ---
> >   t/t6030-bisect-porcelain.sh | 7 +++++++
> >   1 file changed, 7 insertions(+)
> >
> > diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
> > index f41453cc97..99b7517400 100755
> > --- a/t/t6030-bisect-porcelain.sh
> > +++ b/t/t6030-bisect-porcelain.sh
> > @@ -976,4 +976,11 @@ test_expect_success 'bisect run fails with exit code smaller than 0' '
> >       test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> >   '
> >
> > +test_expect_success 'bisect visualize with a filename with dash and space' '
> > +     echo "My test line" >> -hello\ 2 &&
> > +     git add -- -hello\ 2 &&
> > +     git commit --quiet -m "Add test line" -- -hello\ 2 &&
> > +     git bisect visualize -p -- -hello\ 2 > my_bisect_log.txt
> > +'
> > +
> >   test_done
> >
>
> Seems like you're testing with filename with dash and space. Does git
> bisect visualize have any problems handling such filenames?
>
It was a suggestion of a reviewer in the previous version to detect
possible breakages:
https://lore.kernel.org/git/xmqq35vwh8qk.fsf@gitster.g/

Thanks for reviewing,
Miriam

> --
> An old man doll... just what I always wanted! - Clara

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

* Re: [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases
  2021-08-17  9:23     ` Christian Couder
@ 2021-08-17 20:19       ` Miriam R.
  0 siblings, 0 replies; 20+ messages in thread
From: Miriam R. @ 2021-08-17 20:19 UTC (permalink / raw)
  To: Christian Couder; +Cc: Bagas Sanjaya, git

Hi,

El mar, 17 ago 2021 a las 11:23, Christian Couder
(<christian.couder@gmail.com>) escribió:
>
> On Tue, Aug 17, 2021 at 11:03 AM Bagas Sanjaya <bagasdotme@gmail.com> wrote:
> >
> > On 17/08/21 15.14, Miriam Rubio wrote:
> >
> > > +test_expect_success 'bisect run fails with exit code equals or greater than 128' '
> > > +     write_script test_script.sh <<-\EOF &&
> > > +     exit 128 >/dev/null
> > > +     EOF
> > > +     test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> > > +'
> >
> > This only checks for exit code equals to 128. You should also check for
> > exit code greater than 128, for example 255.
> >
Noted.
Thank you for reviewing, Bagas.
> > > +
> > > +test_expect_success 'bisect run fails with exit code smaller than 0' '
> > > +     write_script test_script.sh <<-\EOF &&
> > > +     exit -1 >/dev/null
> > > +     EOF
> > > +     test_must_fail git bisect run ./test_script.sh > my_bisect_log.txt
> > > +'
> >
> > This test looks OK, using -1 as representative of negative exit code.
> > However, wording of test name can also be 'bisect run fails with
> > negative exit code'.
>
> Actually I am not sure that it makes sense to test an exit code
> smaller than 0, as POSIX exit codes are between 0 and 255 (included).
>
> For example:
>
> $ bash -c 'exit -1'; echo $?
> 255
>
> $ dash -c 'exit -1'; echo $?
> dash: 1: exit: Illegal number: -1
> 2
Ok, I will remove this test. No problem.
Thanks, Christian.

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

* Re: [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C
  2021-08-17 11:30   ` Johannes Schindelin
@ 2021-08-17 20:19     ` Miriam R.
  0 siblings, 0 replies; 20+ messages in thread
From: Miriam R. @ 2021-08-17 20:19 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Pranit Bauva, Christian Couder, Tanushree Tumane

Hi Johannes,

El mar, 17 ago 2021 a las 13:30, Johannes Schindelin
(<Johannes.Schindelin@gmx.de>) escribió:
>
> Hi Miriam,
>
> this looks good!
>
> Just one suggestion (but I won't insist on it):
>
> On Tue, 17 Aug 2021, Miriam Rubio wrote:
>
> > @@ -1036,6 +1037,44 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
> >       return res;
> >  }
> >
> > +static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc)
> > +{
> > +     struct strvec args = STRVEC_INIT;
> > +     int flags = RUN_COMMAND_NO_STDIN, res = 0;
> > +     struct strbuf sb = STRBUF_INIT;
> > +
> > +     if (bisect_next_check(terms, NULL) != 0)
> > +             return BISECT_FAILED;
> > +
> > +     if (!argc) {
> > +             if ((getenv("DISPLAY") || getenv("SESSIONNAME") || getenv("MSYSTEM") ||
> > +                  getenv("SECURITYSESSIONID")) && exists_in_PATH("gitk"))
> > +                     strvec_push(&args, "gitk");
> > +             else {
> > +                     strvec_pushl(&args, "log", NULL);
>
> This could be written more concisely as `strvec_push(&args, "log")`.
>
> > +                     flags |= RUN_GIT_CMD;
> > +             }
> > +     } else {
> > +             if (argv[0][0] == '-') {
> > +                     strvec_pushl(&args, "log", NULL);
>
> Same here.
Sure, I will change it in both cases.
Thank you for reviewing,
Miriam.

>
> Otherwise, it looks good to me!
>
> Thank you,
> Dscho
>
> > +                     flags |= RUN_GIT_CMD;
> > +             } else if (strcmp(argv[0], "tig") && !starts_with(argv[0], "git"))
> > +                     flags |= RUN_GIT_CMD;
> > +
> > +             strvec_pushv(&args, argv);
> > +     }
> > +
> > +     strvec_pushl(&args, "--bisect", "--", NULL);
> > +
> > +     strbuf_read_file(&sb, git_path_bisect_names(), 0);
> > +     sq_dequote_to_strvec(sb.buf, &args);
> > +     strbuf_release(&sb);
> > +
> > +     res = run_command_v_opt(args.v, flags);
> > +     strvec_clear(&args);
> > +     return res;
> > +}
> > +
> >  int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >  {
> >       enum {
> > @@ -1048,7 +1087,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >               BISECT_STATE,
> >               BISECT_LOG,
> >               BISECT_REPLAY,
> > -             BISECT_SKIP
> > +             BISECT_SKIP,
> > +             BISECT_VISUALIZE,
> >       } cmdmode = 0;
> >       int res = 0, nolog = 0;
> >       struct option options[] = {
> > @@ -1070,6 +1110,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >                        N_("replay the bisection process from the given file"), BISECT_REPLAY),
> >               OPT_CMDMODE(0, "bisect-skip", &cmdmode,
> >                        N_("skip some commits for checkout"), BISECT_SKIP),
> > +             OPT_CMDMODE(0, "bisect-visualize", &cmdmode,
> > +                      N_("visualize the bisection"), BISECT_VISUALIZE),
> >               OPT_BOOL(0, "no-log", &nolog,
> >                        N_("no log for BISECT_WRITE")),
> >               OPT_END()
> > @@ -1131,6 +1173,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >               get_terms(&terms);
> >               res = bisect_skip(&terms, argv, argc);
> >               break;
> > +     case BISECT_VISUALIZE:
> > +             get_terms(&terms);
> > +             res = bisect_visualize(&terms, argv, argc);
> > +             break;
> >       default:
> >               BUG("unknown subcommand %d", cmdmode);
> >       }
> > diff --git a/git-bisect.sh b/git-bisect.sh
> > index 6a7afaea8d..95f7f3fb8c 100755
> > --- a/git-bisect.sh
> > +++ b/git-bisect.sh
> > @@ -39,29 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
> >  TERM_BAD=bad
> >  TERM_GOOD=good
> >
> > -bisect_visualize() {
> > -     git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
> > -
> > -     if test $# = 0
> > -     then
> > -             if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
> > -                     type gitk >/dev/null 2>&1
> > -             then
> > -                     set gitk
> > -             else
> > -                     set git log
> > -             fi
> > -     else
> > -             case "$1" in
> > -             git*|tig) ;;
> > -             -*)     set git log "$@" ;;
> > -             *)      set git "$@" ;;
> > -             esac
> > -     fi
> > -
> > -     eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES")
> > -}
> > -
> >  bisect_run () {
> >       git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
> >
> > @@ -152,7 +129,7 @@ case "$#" in
> >               # Not sure we want "next" at the UI level anymore.
> >               git bisect--helper --bisect-next "$@" || exit ;;
> >       visualize|view)
> > -             bisect_visualize "$@" ;;
> > +             git bisect--helper --bisect-visualize "$@" || exit;;
> >       reset)
> >               git bisect--helper --bisect-reset "$@" ;;
> >       replay)
> > --
> > 2.29.2
> >
> >

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

* Re: [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell function in C
  2021-08-17 11:42   ` Johannes Schindelin
@ 2021-08-17 20:22     ` Miriam R.
  2021-08-17 21:36       ` Johannes Schindelin
  0 siblings, 1 reply; 20+ messages in thread
From: Miriam R. @ 2021-08-17 20:22 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: git, Tanushree Tumane, Christian Couder

Hi Johannes,

El mar, 17 ago 2021 a las 13:42, Johannes Schindelin
(<Johannes.Schindelin@gmx.de>) escribió:
>
> Hi Miriam,
>
> On Tue, 17 Aug 2021, Miriam Rubio wrote:
>
> > From: Tanushree Tumane <tanushreetumane@gmail.com>
> >
> > Reimplement the `bisect_run()` shell function
> > in C and also add `--bisect-run` subcommand to
> > `git bisect--helper` to call it from git-bisect.sh.
> >
> > Mentored-by: Christian Couder <chriscool@tuxfamily.org>
> > Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com>
> > Signed-off-by: Miriam Rubio <mirucam@gmail.com>
> > ---
> >  builtin/bisect--helper.c | 75 ++++++++++++++++++++++++++++++++++++++++
> >  git-bisect.sh            | 62 +--------------------------------
> >  2 files changed, 76 insertions(+), 61 deletions(-)
> >
> > diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
> > index 4258429c1c..852e0a30fb 100644
> > --- a/builtin/bisect--helper.c
> > +++ b/builtin/bisect--helper.c
> > @@ -31,6 +31,7 @@ static const char * const git_bisect_helper_usage[] = {
> >       N_("git bisect--helper --bisect-replay <filename>"),
> >       N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
> >       N_("git bisect--helper --bisect-visualize"),
> > +     N_("git bisect--helper --bisect-run <cmd>..."),
> >       NULL
> >  };
> >
> > @@ -1075,6 +1076,71 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int a
> >       return res;
> >  }
> >
> > +static int bisect_run(struct bisect_terms *terms, const char **argv, int argc)
> > +{
> > +     int res = BISECT_OK;
> > +     struct strbuf command = STRBUF_INIT;
> > +     struct strvec args = STRVEC_INIT;
> > +     struct strvec run_args = STRVEC_INIT;
> > +     int exit = 0;
> > +
> > +     if (bisect_next_check(terms, NULL))
> > +             return BISECT_FAILED;
> > +
> > +     if (argc)
> > +             sq_quote_argv(&command, argv);
> > +     else
> > +             return BISECT_FAILED;
>
> Do we want to say something helpful here, e.g. _("bisect run failed: no
> command provided.")?
>
Ok, noted
> > +
> > +     strvec_push(&run_args, command.buf);
> > +
> > +     while (1) {
> > +             strvec_clear(&args);
> > +             exit = 1;
> > +
> > +             printf(_("running %s"), command.buf);
> > +             res = run_command_v_opt(run_args.v, RUN_USING_SHELL);
> > +
> > +             if (res < 0 || 128 <= res) {
> > +                     error(_("bisect run failed: exit code %d from"
> > +                             " '%s' is < 0 or >= 128"), res, command.buf);
> > +                     strbuf_release(&command);
> > +                     return res;
> > +             }
> > +
> > +             if (res == 125)
> > +                     strvec_push(&args, "skip");
> > +             else if (res > 0)
> > +                     strvec_push(&args, terms->term_bad);
> > +             else
> > +                     strvec_push(&args, terms->term_good);
> > +
> > +             res = bisect_state(terms, args.v, args.nr);
>
> Since `args.nr` will always be 1, it would probably be better to use
> something like this:
>
>                 const char *new_state;
>
>                 [...]
>                 if (res == 125)
>                         new_state = "skip";
>                 else
>                         new_state = res > 0 ?
>                                 terms->term_bad : terms->term_good;
>
>                 res = bisect_state(terms, &new_state, 1);
>
Yes, indeed. I will change it.
> Also: I think at this stage, an equivalent to `cat "$GIT_DIR/BISECT_RUN"`
> is missing.
In the previous patch series (v3), I implemented the equivalent to the
cat command but I understood
reviewers wanted to print the output to the user, so I reverted my
changes for this version.
https://lore.kernel.org/git/20210411095538.34129-4-mirucam@gmail.com/

>
> > +
> > +             if (res == BISECT_ONLY_SKIPPED_LEFT)
> > +                     error(_("bisect run cannot continue any more"));
> > +             else if (res == BISECT_INTERNAL_SUCCESS_MERGE_BASE) {
> > +                     printf(_("bisect run success"));
> > +                     res = BISECT_OK;
> > +             } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
> > +                     printf(_("bisect found first bad commit"));
> > +                     res = BISECT_OK;
> > +             } else if (res) {
> > +                     error(_("bisect run failed:'git bisect--helper --bisect-state"
> > +                     " %s' exited with error code %d"), args.v[0], res);
> > +             } else {
> > +                     exit = 0;
>
> Since the only purpose of `exit` seems to be that the loop should continue
> if `exit` is set to 0, and it is only set here, how about doing away with
> the variable altogether and writing `continue;` instead of `exit = 0;`?
> Then the conditional block below does not need to be conditional.
>
Noted.
> Other than that: well done!
>
Thank you for reviewing!,
Miriam


> Ciao,
> Dscho
>
> > +             }
> > +
> > +             if (exit) {
> > +                     strbuf_release(&command);
> > +                     strvec_clear(&args);
> > +                     strvec_clear(&run_args);
> > +                     return res;
> > +             }
> > +     }
> > +}
> > +
> >  int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >  {
> >       enum {
> > @@ -1089,6 +1155,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >               BISECT_REPLAY,
> >               BISECT_SKIP,
> >               BISECT_VISUALIZE,
> > +             BISECT_RUN,
> >       } cmdmode = 0;
> >       int res = 0, nolog = 0;
> >       struct option options[] = {
> > @@ -1112,6 +1179,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >                        N_("skip some commits for checkout"), BISECT_SKIP),
> >               OPT_CMDMODE(0, "bisect-visualize", &cmdmode,
> >                        N_("visualize the bisection"), BISECT_VISUALIZE),
> > +             OPT_CMDMODE(0, "bisect-run", &cmdmode,
> > +                      N_("use <cmd>... to automatically bisect."), BISECT_RUN),
> >               OPT_BOOL(0, "no-log", &nolog,
> >                        N_("no log for BISECT_WRITE")),
> >               OPT_END()
> > @@ -1177,6 +1246,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> >               get_terms(&terms);
> >               res = bisect_visualize(&terms, argv, argc);
> >               break;
> > +     case BISECT_RUN:
> > +             if (!argc)
> > +                     return error(_("bisect run failed: no command provided."));
> > +             get_terms(&terms);
> > +             res = bisect_run(&terms, argv, argc);
> > +             break;
> >       default:
> >               BUG("unknown subcommand %d", cmdmode);
> >       }
> > diff --git a/git-bisect.sh b/git-bisect.sh
> > index 95f7f3fb8c..e83d011e17 100755
> > --- a/git-bisect.sh
> > +++ b/git-bisect.sh
> > @@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
> >  TERM_BAD=bad
> >  TERM_GOOD=good
> >
> > -bisect_run () {
> > -     git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
> > -
> > -     test -n "$*" || die "$(gettext "bisect run failed: no command provided.")"
> > -
> > -     while true
> > -     do
> > -             command="$@"
> > -             eval_gettextln "running \$command"
> > -             "$@"
> > -             res=$?
> > -
> > -             # Check for really bad run error.
> > -             if [ $res -lt 0 -o $res -ge 128 ]
> > -             then
> > -                     eval_gettextln "bisect run failed:
> > -exit code \$res from '\$command' is < 0 or >= 128" >&2
> > -                     exit $res
> > -             fi
> > -
> > -             # Find current state depending on run success or failure.
> > -             # A special exit code of 125 means cannot test.
> > -             if [ $res -eq 125 ]
> > -             then
> > -                     state='skip'
> > -             elif [ $res -gt 0 ]
> > -             then
> > -                     state="$TERM_BAD"
> > -             else
> > -                     state="$TERM_GOOD"
> > -             fi
> > -
> > -             git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN"
> > -             res=$?
> > -
> > -             cat "$GIT_DIR/BISECT_RUN"
> > -
> > -             if sane_grep "first $TERM_BAD commit could be any of" "$GIT_DIR/BISECT_RUN" \
> > -                     >/dev/null
> > -             then
> > -                     gettextln "bisect run cannot continue any more" >&2
> > -                     exit $res
> > -             fi
> > -
> > -             if [ $res -ne 0 ]
> > -             then
> > -                     eval_gettextln "bisect run failed:
> > -'bisect-state \$state' exited with error code \$res" >&2
> > -                     exit $res
> > -             fi
> > -
> > -             if sane_grep "is the first $TERM_BAD commit" "$GIT_DIR/BISECT_RUN" >/dev/null
> > -             then
> > -                     gettextln "bisect run success"
> > -                     exit 0;
> > -             fi
> > -
> > -     done
> > -}
> > -
> >  get_terms () {
> >       if test -s "$GIT_DIR/BISECT_TERMS"
> >       then
> > @@ -137,7 +77,7 @@ case "$#" in
> >       log)
> >               git bisect--helper --bisect-log || exit ;;
> >       run)
> > -             bisect_run "$@" ;;
> > +             git bisect--helper --bisect-run "$@" || exit;;
> >       terms)
> >               git bisect--helper --bisect-terms "$@" || exit;;
> >       *)
> > --
> > 2.29.2
> >
> >

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

* Re: [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell function in C
  2021-08-17 20:22     ` Miriam R.
@ 2021-08-17 21:36       ` Johannes Schindelin
  2021-08-18  8:33         ` Christian Couder
  0 siblings, 1 reply; 20+ messages in thread
From: Johannes Schindelin @ 2021-08-17 21:36 UTC (permalink / raw)
  To: Miriam R.; +Cc: git, Tanushree Tumane, Christian Couder

[-- Attachment #1: Type: text/plain, Size: 2094 bytes --]

Hi Miriam,

On Tue, 17 Aug 2021, Miriam R. wrote:

> El mar, 17 ago 2021 a las 13:42, Johannes Schindelin
> (<Johannes.Schindelin@gmx.de>) escribió:
> >
> > On Tue, 17 Aug 2021, Miriam Rubio wrote:
> >
> > > From: Tanushree Tumane <tanushreetumane@gmail.com>
> > >
> > > [...]
> > > +
> > > +             if (res == 125)
> > > +                     strvec_push(&args, "skip");
> > > +             else if (res > 0)
> > > +                     strvec_push(&args, terms->term_bad);
> > > +             else
> > > +                     strvec_push(&args, terms->term_good);
> > > +
> > > +             res = bisect_state(terms, args.v, args.nr);
> >
> > Since `args.nr` will always be 1, it would probably be better to use
> > something like this:
> >
> >                 const char *new_state;
> >
> >                 [...]
> >                 if (res == 125)
> >                         new_state = "skip";
> >                 else
> >                         new_state = res > 0 ?
> >                                 terms->term_bad : terms->term_good;
> >
> >                 res = bisect_state(terms, &new_state, 1);
> >
>
> Yes, indeed. I will change it.
>
> > Also: I think at this stage, an equivalent to `cat
> > "$GIT_DIR/BISECT_RUN"` is missing.
>
> In the previous patch series (v3), I implemented the equivalent to the
> cat command but I understood reviewers wanted to print the output to the
> user, so I reverted my changes for this version.
> https://lore.kernel.org/git/20210411095538.34129-4-mirucam@gmail.com/

I am a bit confused: doesn't `bisect_state()` write to the `BISECT_RUN`
file? If so, I think we do need to show the contents by opening the file
and piping it to `stdout`.

FWIW I read
https://lore.kernel.org/git/CAP8UFD3X24F3qgefHpi00PM-KUk+vcqxwy2Dbngbyj7ciavCVQ@mail.gmail.com/
to mean the same thing, although I have to admit that I am not 100%
certain.

Just to make sure: with this patch, at the end of a `git bisect` run, the
user is shown the commit message of the first bad commit?

Ciao,
Dscho

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

* Re: [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell function in C
  2021-08-17 21:36       ` Johannes Schindelin
@ 2021-08-18  8:33         ` Christian Couder
  2021-08-18  9:43           ` Miriam R.
  0 siblings, 1 reply; 20+ messages in thread
From: Christian Couder @ 2021-08-18  8:33 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Miriam R., git, Tanushree Tumane, Christian Couder

On Tue, Aug 17, 2021 at 11:36 PM Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
>
> Hi Miriam,
>
> On Tue, 17 Aug 2021, Miriam R. wrote:
>
> > El mar, 17 ago 2021 a las 13:42, Johannes Schindelin

> > > Also: I think at this stage, an equivalent to `cat
> > > "$GIT_DIR/BISECT_RUN"` is missing.
> >
> > In the previous patch series (v3), I implemented the equivalent to the
> > cat command but I understood reviewers wanted to print the output to the
> > user, so I reverted my changes for this version.
> > https://lore.kernel.org/git/20210411095538.34129-4-mirucam@gmail.com/
>
> I am a bit confused: doesn't `bisect_state()` write to the `BISECT_RUN`
> file? If so, I think we do need to show the contents by opening the file
> and piping it to `stdout`.
>
> FWIW I read
> https://lore.kernel.org/git/CAP8UFD3X24F3qgefHpi00PM-KUk+vcqxwy2Dbngbyj7ciavCVQ@mail.gmail.com/
> to mean the same thing, although I have to admit that I am not 100%
> certain.

I agree that, after `bisect_state()` has written into the `BISECT_RUN`
file, we should indeed be opening it and piping it to `stdout`. That's
what I meant in the above message.

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

* Re: [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell function in C
  2021-08-18  8:33         ` Christian Couder
@ 2021-08-18  9:43           ` Miriam R.
  0 siblings, 0 replies; 20+ messages in thread
From: Miriam R. @ 2021-08-18  9:43 UTC (permalink / raw)
  To: Christian Couder
  Cc: Johannes Schindelin, git, Tanushree Tumane, Christian Couder

Hi,

El mié, 18 ago 2021 a las 10:33, Christian Couder
(<christian.couder@gmail.com>) escribió:
>
> On Tue, Aug 17, 2021 at 11:36 PM Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
> >
> > Hi Miriam,
> >
> > On Tue, 17 Aug 2021, Miriam R. wrote:
> >
> > > El mar, 17 ago 2021 a las 13:42, Johannes Schindelin
>
> > > > Also: I think at this stage, an equivalent to `cat
> > > > "$GIT_DIR/BISECT_RUN"` is missing.
> > >
> > > In the previous patch series (v3), I implemented the equivalent to the
> > > cat command but I understood reviewers wanted to print the output to the
> > > user, so I reverted my changes for this version.
> > > https://lore.kernel.org/git/20210411095538.34129-4-mirucam@gmail.com/
> >
> > I am a bit confused: doesn't `bisect_state()` write to the `BISECT_RUN`
> > file? If so, I think we do need to show the contents by opening the file
> > and piping it to `stdout`.
> >
> > FWIW I read
> > https://lore.kernel.org/git/CAP8UFD3X24F3qgefHpi00PM-KUk+vcqxwy2Dbngbyj7ciavCVQ@mail.gmail.com/
> > to mean the same thing, although I have to admit that I am not 100%
> > certain.
>
> I agree that, after `bisect_state()` has written into the `BISECT_RUN`
> file, we should indeed be opening it and piping it to `stdout`. That's
> what I meant in the above message.

Sorry for the confusion, I was understanding that reviewers wanted a
different approach, one thing or the other, not both.
I will do both then.
Thank you for the clarification!
Best,
Miriam.

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

end of thread, other threads:[~2021-08-18  9:43 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17  8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
2021-08-17  8:14 ` [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases Miriam Rubio
2021-08-17  9:00   ` Bagas Sanjaya
2021-08-17  9:23     ` Christian Couder
2021-08-17 20:19       ` Miriam R.
2021-08-17  8:14 ` [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize Miriam Rubio
2021-08-17  9:03   ` Bagas Sanjaya
2021-08-17 20:17     ` Miriam R.
2021-08-17  8:14 ` [PATCH v4 3/6] run-command: make `exists_in_PATH()` non-static Miriam Rubio
2021-08-17  8:14 ` [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C Miriam Rubio
2021-08-17 11:30   ` Johannes Schindelin
2021-08-17 20:19     ` Miriam R.
2021-08-17  8:14 ` [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell " Miriam Rubio
2021-08-17 11:42   ` Johannes Schindelin
2021-08-17 20:22     ` Miriam R.
2021-08-17 21:36       ` Johannes Schindelin
2021-08-18  8:33         ` Christian Couder
2021-08-18  9:43           ` Miriam R.
2021-08-17  8:14 ` [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand Miriam Rubio
2021-08-17 11:57   ` Johannes Schindelin

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).