Finish converting git bisect to C part 2 subset 2
v10 cover Finish converting git bisect to C part 2 subset 2
These patches correspond to a second 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/[email protected]) and continued by me.
This patch series version is composed by the last seven patches of part2 set.
These patch series emails were generated from:
https://gitlab.com/mirucam/git/commits/git-bisect-work-part2-v10-subset2.
I would like to thank Johannes Schindelin for reviewing this patch series and to Christian Couder for his advice and help.
General information
-------------------
* Rebased on d4a392452e (Git 2.29-rc1, 2020-10-08) to build with latest changes in bisect--helper.c file.
Specific changes
----------------
[1/7]bisect--helper: finish porting bisect_start() to C
* Add comment in commit message related with eval command.
* Remove code comment that does not apply anymore.
---
[4/7]bisect--helper: reimplement bisect_state & bisect_head shell
functions in C
* Add comment in commit message related with eval command.
* Change some code to convert shell command more faithfully.
* Add call to bisect_autostart() in bisect_state().
* Amend error message.
---
Pranit Bauva (7):
bisect--helper: finish porting bisect_start() to C
bisect--helper: retire --bisect-clean-state subcommand
bisect--helper: retire --next-all subcommand
bisect--helper: reimplement bisect_state & bisect_head shell
functions in C
bisect--helper: retire --check-expected-revs subcommand
bisect--helper: retire --write-terms subcommand
bisect--helper: retire --bisect-autostart subcommand
builtin/bisect--helper.c | 185 +++++++++++++++++++++++---------------- git-bisect.sh | 81 ++--------------- 2 files changed, 115 insertions(+), 151 deletions(-)
Signature · 1 line
2.25.0
PATCH v10 1/7 bisect--helper: finish porting `bisect_start()` to C
From: Pranit Bauva <[email protected]>
Add the subcommand to git bisect--helper and call it from git-bisect.sh.
With the conversion of bisect_auto_next() from shell to C in a previous commit, bisect_start() can now be fully ported to C.
So let's complete the --bisect-start subcommand of git bisect--helper so that it fully implements bisect_start(), and let's use this subcommand in git-bisect.sh instead of bisect_start().
Note that the eval in the changed line of git-bisect.sh cannot be
dropped: it is necessary because the rev and the tail variables may contain multiple, quoted arguments that need to be passed to bisect--helper (without the quotes, naturally).
--- builtin/bisect--helper.c | 41 ++++++++++++++++++++++++++-------------- git-bisect.sh | 26 ++----------------------- 2 files changed, 29 insertions(+), 38 deletions(-)
builtin/bisect--helper.c +27 -14
@@ -85,6 +85,19 @@ static int one_of(const char *term, ...)return res; } +/* +* return code BISECT_INTERNAL_SUCCESS_MERGE_BASE +* and BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND are codes +* that indicate special success. +*/ + +static int is_bisect_success (enum bisect_error res) +{ +return !res || + res ==BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND || + res ==BISECT_INTERNAL_SUCCESS_MERGE_BASE ; +} +static int write_in_file (const char *path,const char *mode,const char *format,va_list args) {FILE *fp =NULL ;
@@ -609,12 +622,13 @@ static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const charreturn bisect_next (terms, prefix); } -static int bisect_start (struct bisect_terms *terms,const char **argv,int argc) +static enum bisect_error bisect_start (struct bisect_terms *terms,const char **argv,int argc) {int no_checkout =0 ;int first_parent_only =0 ;int i, has_double_dash =0 , must_write_terms =0 , bad_seen =0 ; -int flags, pathspec_pos, res =0 ; +int flags, pathspec_pos; +enum bisect_error res =BISECT_OK ;struct string_list revs =STRING_LIST_INIT_DUP ;struct string_list states =STRING_LIST_INIT_DUP ;struct strbuf start_head =STRBUF_INIT ;
@@ -753,14 +767,7 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc)* Get rid of any old bisect state. */ if (bisect_clean_state ()) -return -1 ; - -/* -* In case of mistaken revs or checkout error, or signals received, -* "bisect_auto_next" below may exit or misbehave. -* We have to trap this to be able to clean up using -* "bisect_clean_state". -*/ +return BISECT_FAILED ;/* * Write new start state
@@ -777,7 +784,7 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc) }if (update_ref (NULL ,"BISECT_HEAD" , &oid,NULL ,0 ,UPDATE_REFS_MSG_ON_ERR )) { - res =-1 ; + res =BISECT_FAILED ; goto finish; } }
@@ -789,25 +796,31 @@ static int bisect_start(struct bisect_terms *terms, const char **argv, int argc)for (i =0 ; i < states.nr; i++)if (bisect_write (states.items[i].string, revs.items[i].string, terms,1 )) { - res =-1 ; + res =BISECT_FAILED ; goto finish; }if (must_write_terms &&write_terms (terms->term_bad, terms->term_good)) { - res =-1 ; + res =BISECT_FAILED ; goto finish; } res =bisect_append_log_quoted (argv);if (res) - res =-1 ; + res =BISECT_FAILED ; finish:string_list_clear (&revs,0 );string_list_clear (&states,0 );strbuf_release (&start_head);strbuf_release (&bisect_names); +if (res) +return res; + + res =bisect_auto_next (terms,NULL ); +if (!is_bisect_success (res)) +bisect_clean_state ();return res; }
git-bisect.sh +2 -24
@@ -49,27 +49,6 @@ bisect_head() fi } -bisect_start() { - git bisect--helper --bisect-start $@ || exit - - # - # Change state. - # In case of mistaken revs or checkout error, or signals received, - # "bisect_auto_next" below may exit or misbehave. - # We have to trap this to be able to clean up using - # "bisect_clean_state". - # - trap 'git bisect--helper --bisect-clean-state' 0 - trap 'exit 255' 1 2 3 15 - - # - # Check if we can proceed to the next bisect state. - # - git bisect--helper --bisect-auto-next || exit - - trap '-' 0 -} - bisect_skip() { all='' for arg in "$@"
@@ -163,8 +142,7 @@ bisect_replay () { get_terms case "$command" in start) - cmd="bisect_start $rev $tail" - eval "$cmd" ;; + eval "git bisect--helper --bisect-start $rev $tail" ;; "$TERM_GOOD"|"$TERM_BAD"|skip) git bisect--helper --bisect-write "$command" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit;; terms)
@@ -264,7 +242,7 @@ case "$#" in help) git bisect -h ;; start) - bisect_start "$@" ;; + git bisect--helper --bisect-start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") bisect_state "$cmd" "$@" ;; skip)
Signature · 1 line
2.25.0
PATCH v10 2/7 bisect--helper: retire `--bisect-clean-state` subcommand
In reply to Miriam RubioFrom: Pranit Bauva <[email protected]>
The --bisect-clean-state subcommand is no longer used from the git-bisect.sh shell script. Instead the function bisect_clean_state() is directly called from the C implementation.
--- builtin/bisect--helper.c | 8 -------- 1 file changed, 8 deletions(-)
builtin/bisect--helper.c +0 -8
@@ -22,7 +22,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 --next-all" ),N_ ("git bisect--helper --write-terms <bad_term> <good_term>" ), -N_ ("git bisect--helper --bisect-clean-state" ),N_ ("git bisect--helper --bisect-reset [<commit>]" ),N_ ("git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>" ),N_ ("git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>" ),
@@ -861,7 +860,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)enum {NEXT_ALL =1 ,WRITE_TERMS , -BISECT_CLEAN_STATE ,CHECK_EXPECTED_REVS ,BISECT_RESET ,BISECT_WRITE ,
@@ -879,8 +877,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("perform 'git bisect next'"), NEXT_ALL),OPT_CMDMODE (0 ,"write-terms" , &cmdmode,N_ ("write the terms to .git/BISECT_TERMS" ),WRITE_TERMS ), -OPT_CMDMODE (0 ,"bisect-clean-state" , &cmdmode, -N_ ("cleanup the bisection state" ),BISECT_CLEAN_STATE ),OPT_CMDMODE (0 ,"check-expected-revs" , &cmdmode,N_ ("check for expected revs" ),CHECK_EXPECTED_REVS ), OPT_CMDMODE(0, "bisect-reset", &cmdmode,
@@ -922,10 +918,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)if (argc !=2 )return error (_ ("--write-terms requires two arguments" ));return write_terms (argv[0 ], argv[1 ]); -case BISECT_CLEAN_STATE : -if (argc !=0 ) -return error (_ ("--bisect-clean-state requires no arguments" )); -return bisect_clean_state ();case CHECK_EXPECTED_REVS :check_expected_revs (argv, argc);return 0 ;
Signature · 1 line
2.25.0
PATCH v10 3/7 bisect--helper: retire `--next-all` subcommand
In reply to Miriam RubioFrom: Pranit Bauva <[email protected]>
The --next-all subcommand is no longer used from the git-bisect.sh shell script. Instead the function bisect_next_all() is called from the C implementation of bisect_next().
--- builtin/bisect--helper.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
builtin/bisect--helper.c +1 -8
@@ -20,7 +20,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { -N_ ("git bisect--helper --next-all" ),N_ ("git bisect--helper --write-terms <bad_term> <good_term>" ),N_ ("git bisect--helper --bisect-reset [<commit>]" ),N_ ("git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>" ),
@@ -858,8 +857,7 @@ static int bisect_autostart(struct bisect_terms *terms)int cmd_bisect__helper (int argc,const char **argv,const char *prefix) {enum { -NEXT_ALL =1 , -WRITE_TERMS , +WRITE_TERMS =1 ,CHECK_EXPECTED_REVS ,BISECT_RESET ,BISECT_WRITE ,
@@ -873,8 +871,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } cmdmode =0 ;int res =0 , nolog =0 ;struct option options[] = { -OPT_CMDMODE (0 ,"next-all" , &cmdmode, -N_ ("perform 'git bisect next'" ),NEXT_ALL ),OPT_CMDMODE (0 ,"write-terms" , &cmdmode,N_ ("write the terms to .git/BISECT_TERMS" ),WRITE_TERMS ), OPT_CMDMODE(0, "check-expected-revs", &cmdmode,
@@ -911,9 +907,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)usage_with_options (git_bisect_helper_usage, options);switch (cmdmode) { -case NEXT_ALL : - res =bisect_next_all (the_repository, prefix); -break ;case WRITE_TERMS :if (argc !=2 )return error (_ ("--write-terms requires two arguments" ));
Signature · 1 line
2.25.0
PATCH v10 4/7 bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in C
In reply to Miriam RubioFrom: Pranit Bauva <[email protected]>
Reimplement the bisect_state() shell functions in C and also add a subcommand --bisect-state to git-bisect--helper to call them from git-bisect.sh .
Using --bisect-state subcommand is a temporary measure to port shell function to C so as to use the existing test suite. As more functions are ported, this subcommand will be retired and will be called by some other methods.
bisect_head() is only called from bisect_state(), thus it is not required to introduce another subcommand.
Note that the eval in the changed line of git-bisect.sh cannot be
dropped: it is necessary because the rev and the tail variables may contain multiple, quoted arguments that need to be passed to bisect--helper (without the quotes, naturally).
--- builtin/bisect--helper.c | 84 +++++++++++++++++++++++++++++++++++++++- git-bisect.sh | 55 ++------------------------ 2 files changed, 87 insertions(+), 52 deletions(-)
builtin/bisect--helper.c +83 -1
@@ -31,6 +31,8 @@ static const char * const git_bisect_helper_usage[] = {N_ ("git bisect--helper --bisect-next" ),N_ ("git bisect--helper --bisect-auto-next" ),N_ ("git bisect--helper --bisect-autostart" ), +N_ ("git bisect--helper --bisect-state (bad|new) [<rev>]" ), +N_ ("git bisect--helper --bisect-state (good|old) [<rev>...]" ), NULL };
@@ -854,6 +856,78 @@ static int bisect_autostart(struct bisect_terms *terms)return res; } +static enum bisect_error bisect_state (struct bisect_terms *terms,const char **argv, +int argc) +{ +const char *state; +int i, verify_expected =1 ; +struct object_id oid, expected; +struct strbuf buf =STRBUF_INIT ; +struct oid_array revs =OID_ARRAY_INIT ; + +if (!argc) +return error (_ ("Please call `--bisect-state` with at least one argument" )); + +if (bisect_autostart (terms)) +return BISECT_FAILED ; + + state = argv[0 ]; +if (check_and_set_terms (terms, state) || + !one_of (state, terms->term_good, terms->term_bad,"skip" ,NULL )) +return BISECT_FAILED ; + + argv++; + argc--; +if (argc >1 && !strcmp (state, terms->term_bad)) +return error (_ ("'git bisect %s' can take only one argument." ), terms->term_bad); + +if (argc ==0 ) { +const char *head ="BISECT_HEAD" ; +enum get_oid_result res_head =get_oid (head, &oid); + +if (res_head ==MISSING_OBJECT ) { + head ="HEAD" ; + res_head =get_oid (head, &oid); + } + +if (res_head) +error (_ ("Bad rev input: %s" ), head); +oid_array_append (&revs, &oid); + } + +/* +* All input revs must be checked before executing bisect_write() +* to discard junk revs. +*/ + +for (; argc; argc--, argv++) { +if (get_oid (*argv, &oid)){ +error (_ ("Bad rev input: %s" ), *argv); +return BISECT_FAILED ; + } +oid_array_append (&revs, &oid); + } + +if (strbuf_read_file (&buf,git_path_bisect_expected_rev (),0 ) < the_hash_algo->hexsz || +get_oid_hex (buf.buf, &expected) <0 ) + verify_expected =0 ;/* Ignore invalid file contents */ +strbuf_release (&buf); + +for (i =0 ; i < revs.nr; i++) { +if (bisect_write (state,oid_to_hex (&revs.oid[i]), terms,0 )) +return BISECT_FAILED ; + +if (verify_expected && !oideq (&revs.oid[i], &expected)) { +unlink_or_warn (git_path_bisect_ancestors_ok ()); +unlink_or_warn (git_path_bisect_expected_rev ()); + verify_expected =0 ; + } + } + +oid_array_clear (&revs); +return bisect_auto_next (terms,NULL ); +} +int cmd_bisect__helper (int argc,const char **argv,const char *prefix) {enum {
@@ -867,7 +941,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)BISECT_START ,BISECT_AUTOSTART ,BISECT_NEXT , - BISECT_AUTO_NEXT +BISECT_AUTO_NEXT , + BISECT_STATE } cmdmode =0 ;int res =0 , nolog =0 ;struct option options[] = {
@@ -893,6 +968,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT),OPT_CMDMODE (0 ,"bisect-autostart" , &cmdmode,N_ ("start the bisection if it has not yet been started" ),BISECT_AUTOSTART ), +OPT_CMDMODE (0 ,"bisect-state" , &cmdmode, +N_ ("mark the state of ref (or refs)" ),BISECT_STATE ),OPT_BOOL (0 ,"no-log" , &nolog,N_ ("no log for BISECT_WRITE" )),OPT_END ()
@@ -963,6 +1040,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)set_terms (&terms,"bad" ,"good" ); res =bisect_autostart (&terms);break ; +case BISECT_STATE : +set_terms (&terms,"bad" ,"good" ); +get_terms (&terms); + res =bisect_state (&terms, argv, argc); +break ;default :BUG ("unknown subcommand %d" , cmdmode); }
git-bisect.sh +4 -51
85 lines not on this page · raw message
Signature · 1 line
2.25.0
Re: [PATCH v10 4/7] bisect--helper: reimplement `bisect_state` & `bisect_head` shell functions in C
Hi Miriam,
I read through the entire patch series, and have only _tiny_ nitpicks left. Well done!
Quoted 54 lines · Miriam Rubio
builtin/bisect--helper.c +39
-0@@ -31,6 +31,8 @@ static const char * const git_bisect_helper_usage[] = {N_ ("git bisect--helper --bisect-next" ),N_ ("git bisect--helper --bisect-auto-next" ),N_ ("git bisect--helper --bisect-autostart" ), +N_ ("git bisect--helper --bisect-state (bad|new) [<rev>]" ), +N_ ("git bisect--helper --bisect-state (good|old) [<rev>...]" ), NULL };@@ -854,6 +856,78 @@ static int bisect_autostart(struct bisect_terms *terms)return res; } +static enum bisect_error bisect_state (struct bisect_terms *terms,const char **argv, +int argc) +{ +const char *state; +int i, verify_expected =1 ; +struct object_id oid, expected; +struct strbuf buf =STRBUF_INIT ; +struct oid_array revs =OID_ARRAY_INIT ; + +if (!argc) +return error (_ ("Please call `--bisect-state` with at least one argument" )); + +if (bisect_autostart (terms)) +return BISECT_FAILED ; + + state = argv[0 ]; +if (check_and_set_terms (terms, state) || + !one_of (state, terms->term_good, terms->term_bad,"skip" ,NULL )) +return BISECT_FAILED ; + + argv++; + argc--; +if (argc >1 && !strcmp (state, terms->term_bad)) +return error (_ ("'git bisect %s' can take only one argument." ), terms->term_bad); + +if (argc ==0 ) { +const char *head ="BISECT_HEAD" ; +enum get_oid_result res_head =get_oid (head, &oid); + +if (res_head ==MISSING_OBJECT ) { + head ="HEAD" ; + res_head =get_oid (head, &oid); + } + +if (res_head) +error (_ ("Bad rev input: %s" ), head); +oid_array_append (&revs, &oid);
builtin/bisect--helper.c static int bisect_autostart(struct bisect_terms *terms) · line 905
Quoted 10 lines
builtin/bisect--helper.c +10
-0+ } + +/* +* All input revs must be checked before executing bisect_write() +* to discard junk revs. +*/ + +for (; argc; argc--, argv++) { +if (get_oid (*argv, &oid)){ +error (_ ("Bad rev input: %s" ), *argv);
Here, we leak revs. Maybe
oid_array_clear(&revs);
?
builtin/bisect--helper.c static int bisect_autostart(struct bisect_terms *terms) · line 917
Quoted 12 lines
builtin/bisect--helper.c +12
-0+return BISECT_FAILED ; + } +oid_array_append (&revs, &oid); + } + +if (strbuf_read_file (&buf,git_path_bisect_expected_rev (),0 ) < the_hash_algo->hexsz || +get_oid_hex (buf.buf, &expected) <0 ) + verify_expected =0 ;/* Ignore invalid file contents */ +strbuf_release (&buf); + +for (i =0 ; i < revs.nr; i++) { +if (bisect_write (state,oid_to_hex (&revs.oid[i]), terms,0 ))
Same here.
It is not exactly clear to me how problematic this leak would be, as we're only calling this function from cmd_*() and return immediately afterwards. It might be worth cleaning up memory, though, in case we want to move this code into libgit.a and potentially call it from elsewhere (where we would _not_ necessarily exit() immediately upon seeing a failure).
Otherwise, the patch series looks good to me!
Thank you for your patient efforts,
Dscho
Quoted 145 lines
builtin/bisect--helper.c +22
-1+return BISECT_FAILED ; + +if (verify_expected && !oideq (&revs.oid[i], &expected)) { +unlink_or_warn (git_path_bisect_ancestors_ok ()); +unlink_or_warn (git_path_bisect_expected_rev ()); + verify_expected =0 ; + } + } + +oid_array_clear (&revs); +return bisect_auto_next (terms,NULL ); +} +int cmd_bisect__helper (int argc,const char **argv,const char *prefix) {enum {@@ -867,7 +941,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)BISECT_START ,BISECT_AUTOSTART ,BISECT_NEXT , - BISECT_AUTO_NEXT +BISECT_AUTO_NEXT , + BISECT_STATE } cmdmode =0 ;int res =0 , nolog =0 ;struct option options[] = {@@ -893,6 +968,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("verify the next bisection state then checkout the next bisection commit"), BISECT_AUTO_NEXT),OPT_CMDMODE (0 ,"bisect-autostart" , &cmdmode,N_ ("start the bisection if it has not yet been started" ),BISECT_AUTOSTART ), +OPT_CMDMODE (0 ,"bisect-state" , &cmdmode, +N_ ("mark the state of ref (or refs)" ),BISECT_STATE ),OPT_BOOL (0 ,"no-log" , &nolog,N_ ("no log for BISECT_WRITE" )),OPT_END ()@@ -963,6 +1040,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)set_terms (&terms,"bad" ,"good" ); res =bisect_autostart (&terms);break ; +case BISECT_STATE : +set_terms (&terms,"bad" ,"good" ); +get_terms (&terms); + res =bisect_state (&terms, argv, argc); +break ;default :BUG ("unknown subcommand %d" , cmdmode); }git-bisect.sh +4
-52@@ -39,16 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40" TERM_BAD=bad TERM_GOOD=good -bisect_head() -{ - if git rev-parse --verify -q BISECT_HEAD > /dev/null - then - echo BISECT_HEAD - else - echo HEAD - fi -} - bisect_skip() { all='' for arg in "$@"@@ -61,43 +51,7 @@ bisect_skip() { esac all="$all $revs" done - eval bisect_state 'skip' $all -} - -bisect_state() { - git bisect--helper --bisect-autostart || exit - state=$1 - git bisect--helper --check-and-set-terms $state $TERM_GOOD $TERM_BAD || exit - get_terms - case "$#,$state" in - 0,*) - die "Please call 'bisect_state' with at least one argument." ;; - 1,"$TERM_BAD"|1,"$TERM_GOOD"|1,skip) - bisected_head=$(bisect_head) - rev=$(git rev-parse --verify "$bisected_head") || - die "$(eval_gettext "Bad rev input: \$bisected_head")" - git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit - git bisect--helper --check-expected-revs "$rev" ;; - 2,"$TERM_BAD"|*,"$TERM_GOOD"|*,skip) - shift - hash_list='' - for rev in "$@" - do - sha=$(git rev-parse --verify "$rev^{commit}") || - die "$(eval_gettext "Bad rev input: \$rev")" - hash_list="$hash_list $sha" - done - for rev in $hash_list - do - git bisect--helper --bisect-write "$state" "$rev" "$TERM_GOOD" "$TERM_BAD" || exit - done - git bisect--helper --check-expected-revs $hash_list ;; - *,"$TERM_BAD") - die "$(eval_gettext "'git bisect \$TERM_BAD' can take only one argument.")" ;; - *) - usage ;; - esac - git bisect--helper --bisect-auto-next + eval git bisect--helper --bisect-state 'skip' $all } bisect_visualize() {@@ -187,8 +141,7 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 state="$TERM_GOOD" fi - # We have to use a subshell because "bisect_state" can exit. - ( bisect_state $state >"$GIT_DIR/BISECT_RUN" ) + git bisect--helper --bisect-state $state >"$GIT_DIR/BISECT_RUN" res=$? cat "$GIT_DIR/BISECT_RUN"@@ -203,7 +156,7 @@ exit code \$res from '\$command' is < 0 or >= 128" >&2 if [ $res -ne 0 ] then eval_gettextln "bisect run failed: -'bisect_state \$state' exited with error code \$res" >&2 +'bisect-state \$state' exited with error code \$res" >&2 exit $res fi@@ -244,7 +197,7 @@ case "$#" in start) git bisect--helper --bisect-start "$@" ;; bad|good|new|old|"$TERM_BAD"|"$TERM_GOOD") - bisect_state "$cmd" "$@" ;; + git bisect--helper --bisect-state "$cmd" "$@" ;; skip) bisect_skip "$@" ;; next) --2.25.0
PATCH v10 5/7 bisect--helper: retire `--check-expected-revs` subcommand
In reply to Miriam RubioFrom: Pranit Bauva <[email protected]>
The --check-expected-revs subcommand is no longer used from the git-bisect.sh shell script. Functions check_expected_revs and is_expected_revs are also deleted.
--- builtin/bisect--helper.c | 30 ------------------------------ 1 file changed, 30 deletions(-)
builtin/bisect--helper.c +0 -30
@@ -187,30 +187,6 @@ static int write_terms(const char *bad, const char *good)return res; } -static int is_expected_rev (const char *expected_hex) -{ -struct strbuf actual_hex =STRBUF_INIT ; -int res =0 ; -if (strbuf_read_file (&actual_hex,git_path_bisect_expected_rev (),0 ) >=40 ) { -strbuf_trim (&actual_hex); - res = !strcmp (actual_hex.buf, expected_hex); - } -strbuf_release (&actual_hex); -return res; -} - -static void check_expected_revs (const char **revs,int rev_nr) -{ -int i; - -for (i =0 ; i < rev_nr; i++) { -if (!is_expected_rev (revs[i])) { -unlink_or_warn (git_path_bisect_ancestors_ok ()); -unlink_or_warn (git_path_bisect_expected_rev ()); - } - } -} -static int bisect_reset (const char *commit) {struct strbuf branch =STRBUF_INIT ;
@@ -932,7 +908,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) {enum {WRITE_TERMS =1 , -CHECK_EXPECTED_REVS ,BISECT_RESET ,BISECT_WRITE ,CHECK_AND_SET_TERMS ,
@@ -948,8 +923,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)struct option options[] = {OPT_CMDMODE (0 ,"write-terms" , &cmdmode,N_ ("write the terms to .git/BISECT_TERMS" ),WRITE_TERMS ), -OPT_CMDMODE (0 ,"check-expected-revs" , &cmdmode, -N_ ("check for expected revs" ),CHECK_EXPECTED_REVS ),OPT_CMDMODE (0 ,"bisect-reset" , &cmdmode,N_ ("reset the bisection state" ),BISECT_RESET ), OPT_CMDMODE(0, "bisect-write", &cmdmode,
@@ -988,9 +961,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)if (argc !=2 )return error (_ ("--write-terms requires two arguments" ));return write_terms (argv[0 ], argv[1 ]); -case CHECK_EXPECTED_REVS : -check_expected_revs (argv, argc); -return 0 ;case BISECT_RESET :if (argc >1 )return error (_ ("--bisect-reset requires either no argument or a commit" ));
Signature · 1 line
2.25.0
PATCH v10 6/7 bisect--helper: retire `--write-terms` subcommand
In reply to Miriam RubioFrom: Pranit Bauva <[email protected]>
The --write-terms subcommand is no longer used from the git-bisect.sh shell script. Instead the function write_terms() is called from the C implementation of set_terms() and bisect_start().
--- builtin/bisect--helper.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
builtin/bisect--helper.c +1 -9
@@ -20,7 +20,6 @@ static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES") static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT") static const char * const git_bisect_helper_usage[] = { -N_ ("git bisect--helper --write-terms <bad_term> <good_term>" ),N_ ("git bisect--helper --bisect-reset [<commit>]" ),N_ ("git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>" ),N_ ("git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>" ),
@@ -907,8 +906,7 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **aint cmd_bisect__helper (int argc,const char **argv,const char *prefix) {enum { -WRITE_TERMS =1 , -BISECT_RESET , +BISECT_RESET =1 ,BISECT_WRITE ,CHECK_AND_SET_TERMS ,BISECT_NEXT_CHECK ,
@@ -921,8 +919,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) } cmdmode =0 ;int res =0 , nolog =0 ;struct option options[] = { -OPT_CMDMODE (0 ,"write-terms" , &cmdmode, -N_ ("write the terms to .git/BISECT_TERMS" ),WRITE_TERMS ),OPT_CMDMODE (0 ,"bisect-reset" , &cmdmode,N_ ("reset the bisection state" ),BISECT_RESET ), OPT_CMDMODE(0, "bisect-write", &cmdmode,
@@ -957,10 +953,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)usage_with_options (git_bisect_helper_usage, options);switch (cmdmode) { -case WRITE_TERMS : -if (argc !=2 ) -return error (_ ("--write-terms requires two arguments" )); -return write_terms (argv[0 ], argv[1 ]);case BISECT_RESET :if (argc >1 )return error (_ ("--bisect-reset requires either no argument or a commit" ));
Signature · 1 line
2.25.0
PATCH v10 7/7 bisect--helper: retire `--bisect-autostart` subcommand
In reply to Miriam RubioFrom: Pranit Bauva <[email protected]>
The --bisect-autostart subcommand is no longer used from the git-bisect.sh shell script. Instead the function bisect_autostart() is directly called from the C implementation.
--- builtin/bisect--helper.c | 9 --------- 1 file changed, 9 deletions(-)
builtin/bisect--helper.c +0 -9
@@ -29,7 +29,6 @@ static const char * const git_bisect_helper_usage[] = { " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),N_ ("git bisect--helper --bisect-next" ),N_ ("git bisect--helper --bisect-auto-next" ), -N_ ("git bisect--helper --bisect-autostart" ),N_ ("git bisect--helper --bisect-state (bad|new) [<rev>]" ),N_ ("git bisect--helper --bisect-state (good|old) [<rev>...]" ),NULL
@@ -935,8 +934,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix) N_("find the next bisection commit"), BISECT_NEXT),OPT_CMDMODE (0 ,"bisect-auto-next" , &cmdmode,N_ ("verify the next bisection state then checkout the next bisection commit" ),BISECT_AUTO_NEXT ), -OPT_CMDMODE (0 ,"bisect-autostart" , &cmdmode, -N_ ("start the bisection if it has not yet been started" ),BISECT_AUTOSTART ),OPT_CMDMODE (0 ,"bisect-state" , &cmdmode,N_ ("mark the state of ref (or refs)" ),BISECT_STATE ), OPT_BOOL(0, "no-log", &nolog,
@@ -996,12 +993,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)get_terms (&terms); res =bisect_auto_next (&terms, prefix);break ; -case BISECT_AUTOSTART : -if (argc) -return error (_ ("--bisect-autostart does not accept arguments" )); -set_terms (&terms,"bad" ,"good" ); - res =bisect_autostart (&terms); -break ;case BISECT_STATE :set_terms (&terms,"bad" ,"good" );get_terms (&terms);
Signature · 1 line
2.25.0