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
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 <redacted>
---
t/t6030-bisect-porcelain.sh | 14 ++++++++++++++
1 file changed, 14 insertions(+)
@@ -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_scripttest_script.sh<<-\EOF&&+exit128>/dev/null+EOF+test_must_failgitbisectrun./test_script.sh>my_bisect_log.txt+'++test_expect_success'bisect run fails with exit code smaller than 0''+write_scripttest_script.sh<<-\EOF&&+exit-1>/dev/null+EOF+test_must_failgitbisectrun./test_script.sh>my_bisect_log.txt+'+ test_done
+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
From: Christian Couder <hidden> Date: 2021-08-17 09:23:27
On Tue, Aug 17, 2021 at 11:03 AM Bagas Sanjaya [off-list ref] wrote:
On 17/08/21 15.14, Miriam Rubio wrote:
quoted
+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.
quoted
+
+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
From: Miriam R. <hidden> Date: 2021-08-17 20:22:01
Hi,
El mar, 17 ago 2021 a las 11:23, Christian Couder
([off-list ref]) escribió:
On Tue, Aug 17, 2021 at 11:03 AM Bagas Sanjaya [off-list ref] wrote:
quoted
On 17/08/21 15.14, Miriam Rubio wrote:
quoted
+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.
quoted
quoted
+
+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.
Add a test to control breakages in bisect visualize command.
Signed-off-by: Miriam Rubio <redacted>
---
t/t6030-bisect-porcelain.sh | 7 +++++++
1 file changed, 7 insertions(+)
@@ -976,4 +976,11 @@ test_expect_success 'bisect run fails with exit code smaller than 0' 'test_must_failgitbisectrun./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&&+gitadd---hello\ 2&&+gitcommit--quiet-m"Add test line"---hello\ 2&&+gitbisectvisualize-p---hello\ 2>my_bisect_log.txt+'+ test_done
Add a test to control breakages in bisect visualize command.
Signed-off-by: Miriam Rubio <redacted>
---
t/t6030-bisect-porcelain.sh | 7 +++++++
1 file changed, 7 insertions(+)
@@ -976,4 +976,11 @@ test_expect_success 'bisect run fails with exit code smaller than 0' 'test_must_failgitbisectrun./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&&+gitadd---hello\ 2&&+gitcommit--quiet-m"Add test line"---hello\ 2&&+gitbisectvisualize-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
From: Miriam R. <hidden> Date: 2021-08-17 20:21:31
Hi Bagas,
El mar, 17 ago 2021 a las 11:03, Bagas Sanjaya
([off-list ref]) escribió:
On 17/08/21 15.14, Miriam Rubio wrote:
quoted
Add a test to control breakages in bisect visualize command.
Signed-off-by: Miriam Rubio <redacted>
---
t/t6030-bisect-porcelain.sh | 7 +++++++
1 file changed, 7 insertions(+)
@@ -976,4 +976,11 @@ test_expect_success 'bisect run fails with exit code smaller than 0' 'test_must_failgitbisectrun./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&&+gitadd---hello\ 2&&+gitcommit--quiet-m"Add test line"---hello\ 2&&+gitbisectvisualize-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?
From: Pranit Bauva <redacted>
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 [off-list ref]
Mentored by: Johannes Schindelin [off-list ref]
Signed-off-by: Tanushree Tumane <redacted>
Signed-off-by: Miriam Rubio <redacted>
---
run-command.c | 2 +-
run-command.h | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
From: Pranit Bauva <redacted>
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 [off-list ref]
Mentored-by: Johannes Schindelin [off-list ref]
Signed-off-by: Tanushree Tumane <redacted>
Signed-off-by: Miriam Rubio <redacted>
---
builtin/bisect--helper.c | 48 +++++++++++++++++++++++++++++++++++++++-
git-bisect.sh | 25 +--------------------
2 files changed, 48 insertions(+), 25 deletions(-)
@@ -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()
@@ -152,7 +129,7 @@ case "$#" in# Not sure we want "next" at the UI level anymore.gitbisect--helper--bisect-next"$@"||exit;;visualize|view)-bisect_visualize"$@";;+gitbisect--helper--bisect-visualize"$@"||exit;;reset)gitbisect--helper--bisect-reset"$@";;replay)
@@ -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); }
@@ -152,7 +129,7 @@ case "$#" in# Not sure we want "next" at the UI level anymore.gitbisect--helper--bisect-next"$@"||exit;;visualize|view)-bisect_visualize"$@";;+gitbisect--helper--bisect-visualize"$@"||exit;;reset)gitbisect--helper--bisect-reset"$@";;replay)--
@@ -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); }
@@ -152,7 +129,7 @@ case "$#" in# Not sure we want "next" at the UI level anymore.gitbisect--helper--bisect-next"$@"||exit;;visualize|view)-bisect_visualize"$@";;+gitbisect--helper--bisect-visualize"$@"||exit;;reset)gitbisect--helper--bisect-reset"$@";;replay)--
From: Tanushree Tumane <redacted>
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 [off-list ref]
Signed-off-by: Tanushree Tumane <redacted>
Signed-off-by: Miriam Rubio <redacted>
---
builtin/bisect--helper.c | 75 ++++++++++++++++++++++++++++++++++++++++
git-bisect.sh | 62 +--------------------------------
2 files changed, 76 insertions(+), 61 deletions(-)
@@ -1075,6 +1076,71 @@ static int bisect_visualize(struct bisect_terms *terms, const char **argv, int areturnres;}+staticintbisect_run(structbisect_terms*terms,constchar**argv,intargc)+{+intres=BISECT_OK;+structstrbufcommand=STRBUF_INIT;+structstrvecargs=STRVEC_INIT;+structstrvecrun_args=STRVEC_INIT;+intexit=0;++if(bisect_next_check(terms,NULL))+returnBISECT_FAILED;++if(argc)+sq_quote_argv(&command,argv);+else+returnBISECT_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);+returnres;+}++if(res==125)+strvec_push(&args,"skip");+elseif(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"));+elseif(res==BISECT_INTERNAL_SUCCESS_MERGE_BASE){+printf(_("bisect run success"));+res=BISECT_OK;+}elseif(res==BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND){+printf(_("bisect found first bad commit"));+res=BISECT_OK;+}elseif(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);+returnres;+}+}+}+intcmd_bisect__helper(intargc,constchar**argv,constchar*prefix){enum{
@@ -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;+caseBISECT_RUN:+if(!argc)+returnerror(_("bisect run failed: no command provided."));+get_terms(&terms);+res=bisect_run(&terms,argv,argc);+break;default:BUG("unknown subcommand %d",cmdmode);}
@@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"TERM_BAD=badTERM_GOOD=good-bisect_run(){-gitbisect--helper--bisect-next-check$TERM_GOOD$TERM_BADfail||exit--test-n"$*"||die"$(gettext"bisect run failed: no command provided.")"--whiletrue-do-command="$@"-eval_gettextln"running \$command"-"$@"-res=$?--# Check for really bad run error.-if[$res-lt0-o$res-ge128]-then-eval_gettextln"bisect run failed:-exitcode\$resfrom'\$command'is<0or>=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-eq125]-then-state='skip'-elif[$res-gt0]-then-state="$TERM_BAD"-else-state="$TERM_GOOD"-fi--gitbisect--helper--bisect-state$state>"$GIT_DIR/BISECT_RUN"-res=$?--cat"$GIT_DIR/BISECT_RUN"--ifsane_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-ne0]-then-eval_gettextln"bisect run failed:-'bisect-state \$state'exitedwitherrorcode\$res" >&2-exit$res-fi--ifsane_grep"is the first $TERM_BAD commit""$GIT_DIR/BISECT_RUN">/dev/null-then-gettextln"bisect run success"-exit0;-fi--done-}- get_terms(){iftest-s"$GIT_DIR/BISECT_TERMS"then
@@ -137,7 +77,7 @@ case "$#" inlog)gitbisect--helper--bisect-log||exit;;run)-bisect_run"$@";;+gitbisect--helper--bisect-run"$@"||exit;;terms)gitbisect--helper--bisect-terms"$@"||exit;;*)
From: Johannes Schindelin <hidden> Date: 2021-08-17 11:42:11
Hi Miriam,
On Tue, 17 Aug 2021, Miriam Rubio wrote:
quoted hunk
From: Tanushree Tumane <redacted>
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 [off-list ref]
Signed-off-by: Tanushree Tumane <redacted>
Signed-off-by: Miriam Rubio <redacted>
---
builtin/bisect--helper.c | 75 ++++++++++++++++++++++++++++++++++++++++
git-bisect.sh | 62 +--------------------------------
2 files changed, 76 insertions(+), 61 deletions(-)
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
@@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"TERM_BAD=badTERM_GOOD=good-bisect_run(){-gitbisect--helper--bisect-next-check$TERM_GOOD$TERM_BADfail||exit--test-n"$*"||die"$(gettext"bisect run failed: no command provided.")"--whiletrue-do-command="$@"-eval_gettextln"running \$command"-"$@"-res=$?--# Check for really bad run error.-if[$res-lt0-o$res-ge128]-then-eval_gettextln"bisect run failed:-exitcode\$resfrom'\$command'is<0or>=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-eq125]-then-state='skip'-elif[$res-gt0]-then-state="$TERM_BAD"-else-state="$TERM_GOOD"-fi--gitbisect--helper--bisect-state$state>"$GIT_DIR/BISECT_RUN"-res=$?--cat"$GIT_DIR/BISECT_RUN"--ifsane_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-ne0]-then-eval_gettextln"bisect run failed:-'bisect-state \$state'exitedwitherrorcode\$res" >&2-exit$res-fi--ifsane_grep"is the first $TERM_BAD commit""$GIT_DIR/BISECT_RUN">/dev/null-then-gettextln"bisect run success"-exit0;-fi--done-}- get_terms(){iftest-s"$GIT_DIR/BISECT_TERMS"then
@@ -137,7 +77,7 @@ case "$#" inlog)gitbisect--helper--bisect-log||exit;;run)-bisect_run"$@";;+gitbisect--helper--bisect-run"$@"||exit;;terms)gitbisect--helper--bisect-terms"$@"||exit;;*)--
From: Miriam R. <hidden> Date: 2021-08-17 20:22:58
Hi Johannes,
El mar, 17 ago 2021 a las 13:42, Johannes Schindelin
([off-list ref]) escribió:
Hi Miriam,
On Tue, 17 Aug 2021, Miriam Rubio wrote:
quoted
From: Tanushree Tumane <redacted>
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 [off-list ref]
Signed-off-by: Tanushree Tumane <redacted>
Signed-off-by: Miriam Rubio <redacted>
---
builtin/bisect--helper.c | 75 ++++++++++++++++++++++++++++++++++++++++
git-bisect.sh | 62 +--------------------------------
2 files changed, 76 insertions(+), 61 deletions(-)
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.
+
+ 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.
@@ -39,66 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"TERM_BAD=badTERM_GOOD=good-bisect_run(){-gitbisect--helper--bisect-next-check$TERM_GOOD$TERM_BADfail||exit--test-n"$*"||die"$(gettext"bisect run failed: no command provided.")"--whiletrue-do-command="$@"-eval_gettextln"running \$command"-"$@"-res=$?--# Check for really bad run error.-if[$res-lt0-o$res-ge128]-then-eval_gettextln"bisect run failed:-exitcode\$resfrom'\$command'is<0or>=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-eq125]-then-state='skip'-elif[$res-gt0]-then-state="$TERM_BAD"-else-state="$TERM_GOOD"-fi--gitbisect--helper--bisect-state$state>"$GIT_DIR/BISECT_RUN"-res=$?--cat"$GIT_DIR/BISECT_RUN"--ifsane_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-ne0]-then-eval_gettextln"bisect run failed:-'bisect-state \$state'exitedwitherrorcode\$res" >&2-exit$res-fi--ifsane_grep"is the first $TERM_BAD commit""$GIT_DIR/BISECT_RUN">/dev/null-then-gettextln"bisect run success"-exit0;-fi--done-}- get_terms(){iftest-s"$GIT_DIR/BISECT_TERMS"then
@@ -137,7 +77,7 @@ case "$#" inlog)gitbisect--helper--bisect-log||exit;;run)-bisect_run"$@";;+gitbisect--helper--bisect-run"$@"||exit;;terms)gitbisect--helper--bisect-terms"$@"||exit;;*)--
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.
quoted
Also: I think at this stage, an equivalent to `cat
"$GIT_DIR/BISECT_RUN"` is missing.
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
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.
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.
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 [off-list ref]
Signed-off-by: Miriam Rubio <redacted>
---
builtin/bisect--helper.c | 7 -------
1 file changed, 7 deletions(-)
@@ -1200,12 +1199,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)returnerror(_("--bisect-reset requires either no argument or a commit"));res=bisect_reset(argc?argv[0]:NULL);break;-caseBISECT_NEXT_CHECK:-if(argc!=2&&argc!=3)-returnerror(_("--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;caseBISECT_TERMS:if(argc>1)returnerror(_("--bisect-terms requires 0 or 1 argument"));
From: Johannes Schindelin <hidden> Date: 2021-08-17 11:57:56
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 [off-list ref]
Signed-off-by: Miriam Rubio <redacted>
---
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
@@ -1200,12 +1199,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)returnerror(_("--bisect-reset requires either no argument or a commit"));res=bisect_reset(argc?argv[0]:NULL);break;-caseBISECT_NEXT_CHECK:-if(argc!=2&&argc!=3)-returnerror(_("--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;caseBISECT_TERMS:if(argc>1)returnerror(_("--bisect-terms requires 0 or 1 argument"));--