{"thread":{"id":"55050","subject":"[PATCH v4 0/7] Finish converting git bisect to C part 3","startedAt":"2021-01-26T05:01:11Z","lastAt":"2021-01-30T09:50:22Z","messageCount":19,"participants":["Miriam Rubio","Junio C Hamano","Miriam R.","Christian Couder","Đoàn Trần Công Danh"],"isPatch":true,"patchVersion":4,"patchTotal":7},"messages":[{"id":"415267","messageId":"20210125191710.45161-1-mirucam@gmail.com","threadId":"55050","inReplyTo":null,"subject":"[PATCH v4 0/7] Finish converting git bisect to C part 3","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:03Z","receivedAt":"2021-01-26T05:01:11Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"These patches correspond to a third part of patch series \nof Outreachy project \"Finish converting `git bisect` from shell to C\" \nstarted by Pranit Bauva and Tanushree Tumane\n(https://public-inbox.org/git/pull.117.git.gitgitgadget@gmail.com) and\ncontinued by me.\n\nThis third part is formed by reimplementations of some `git bisect` \nsubcommands and removal of some temporary subcommands.\n\nThese patch series emails were generated from:\nhttps://gitlab.com/mirucam/git/commits/git-bisect-work-part3_v3.\n\nI would like to thank Rafael Silva and Junio Hamano for their\nreviews and suggestions.\n\nSpecific changes\n----------------\n\n[1/7] bisect--helper: reimplement `bisect_log` shell function in C\n* Add a missing space.\n---\n\n[2/7] bisect--helper: reimplement `bisect_replay` shell function in C\n* Fix declaration after statement warning.\n\n\nPranit Bauva (7):\n  bisect--helper: reimplement `bisect_log` shell function in C\n  bisect--helper: reimplement `bisect_replay` shell function in C\n  bisect--helper: retire `--bisect-write` subcommand\n  bisect--helper: use `res` instead of return in BISECT_RESET case\n    option\n  bisect--helper: retire `--bisect-auto-next` subcommand\n  bisect--helper: reimplement `bisect_skip` shell function in C\n  bisect--helper: retire `--check-and-set-terms` subcommand\n\n builtin/bisect--helper.c | 179 ++++++++++++++++++++++++++++++++-------\n git-bisect.sh            |  58 +------------\n 2 files changed, 151 insertions(+), 86 deletions(-)\n\n-- \n2.29.2\n\n"},{"id":"415268","messageId":"20210125191710.45161-2-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 1/7] bisect--helper: reimplement `bisect_log` shell function in C","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:04Z","receivedAt":"2021-01-26T05:01:59Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nReimplement the `bisect_log()` shell function in C and also add\n`--bisect-log` subcommand to `git bisect--helper` to call it from\ngit-bisect.sh .\n\nUsing `--bisect-log` subcommand is a temporary measure to port shell\nfunction to C so as to use the existing test suite.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 22 +++++++++++++++++++++-\n git-bisect.sh            |  7 +------\n 2 files changed, 22 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 709eb713a3..a65244a0f5 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -904,6 +904,18 @@ static enum bisect_error bisect_state(struct bisect_terms *terms, const char **a\n \treturn bisect_auto_next(terms, NULL);\n }\n \n+static enum bisect_error bisect_log(void)\n+{\n+\tint fd, status;\n+\tfd = open(git_path_bisect_log(), O_RDONLY);\n+\tif (fd < 0)\n+\t\treturn BISECT_FAILED;\n+\n+\tstatus = copy_fd(fd, STDOUT_FILENO);\n+\tclose(fd);\n+\treturn status ? BISECT_FAILED : BISECT_OK;\n+}\n+\n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tenum {\n@@ -916,7 +928,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tBISECT_AUTOSTART,\n \t\tBISECT_NEXT,\n \t\tBISECT_AUTO_NEXT,\n-\t\tBISECT_STATE\n+\t\tBISECT_STATE,\n+\t\tBISECT_LOG\n \t} cmdmode = 0;\n \tint res = 0, nolog = 0;\n \tstruct option options[] = {\n@@ -938,6 +951,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"verify the next bisection state then checkout the next bisection commit\"), BISECT_AUTO_NEXT),\n \t\tOPT_CMDMODE(0, \"bisect-state\", &cmdmode,\n \t\t\t N_(\"mark the state of ref (or refs)\"), BISECT_STATE),\n+\t\tOPT_CMDMODE(0, \"bisect-log\", &cmdmode,\n+\t\t\t N_(\"list the bisection steps so far\"), BISECT_LOG),\n \t\tOPT_BOOL(0, \"no-log\", &nolog,\n \t\t\t N_(\"no log for BISECT_WRITE\")),\n \t\tOPT_END()\n@@ -1000,6 +1015,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tget_terms(&terms);\n \t\tres = bisect_state(&terms, argv, argc);\n \t\tbreak;\n+\tcase BISECT_LOG:\n+\t\tif (argc)\n+\t\t\treturn error(_(\"--bisect-log requires 0 arguments\"));\n+\t\tres = bisect_log();\n+\t\tbreak;\n \tdefault:\n \t\tBUG(\"unknown subcommand %d\", cmdmode);\n \t}\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 1f3f6e9fc5..05863cc142 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -169,11 +169,6 @@ exit code \\$res from '\\$command' is < 0 or >= 128\" >&2\n \tdone\n }\n \n-bisect_log () {\n-\ttest -s \"$GIT_DIR/BISECT_LOG\" || die \"$(gettext \"We are not bisecting.\")\"\n-\tcat \"$GIT_DIR/BISECT_LOG\"\n-}\n-\n get_terms () {\n \tif test -s \"$GIT_DIR/BISECT_TERMS\"\n \tthen\n@@ -210,7 +205,7 @@ case \"$#\" in\n \treplay)\n \t\tbisect_replay \"$@\" ;;\n \tlog)\n-\t\tbisect_log ;;\n+\t\tgit bisect--helper --bisect-log || exit ;;\n \trun)\n \t\tbisect_run \"$@\" ;;\n \tterms)\n-- \n2.29.2\n\n"},{"id":"415269","messageId":"20210125191710.45161-8-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 7/7] bisect--helper: retire `--check-and-set-terms` subcommand","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:10Z","receivedAt":"2021-01-26T05:02:43Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nThe `--check-and-set-terms` subcommand is no longer from the\ngit-bisect.sh shell script. Instead the function\n`check_and_set_terms()` is called from the C implementation.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 10 ----------\n 1 file changed, 10 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 145e1a6998..e26d9baa18 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -21,7 +21,6 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, \"BISECT_FIRST_PARENT\")\n \n static const char * const git_bisect_helper_usage[] = {\n \tN_(\"git bisect--helper --bisect-reset [<commit>]\"),\n-\tN_(\"git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>\"),\n \tN_(\"git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]\"),\n \tN_(\"git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]\"),\n \tN_(\"git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]\"\n@@ -1028,7 +1027,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tenum {\n \t\tBISECT_RESET = 1,\n-\t\tCHECK_AND_SET_TERMS,\n \t\tBISECT_NEXT_CHECK,\n \t\tBISECT_TERMS,\n \t\tBISECT_START,\n@@ -1043,8 +1041,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT_CMDMODE(0, \"bisect-reset\", &cmdmode,\n \t\t\t N_(\"reset the bisection state\"), BISECT_RESET),\n-\t\tOPT_CMDMODE(0, \"check-and-set-terms\", &cmdmode,\n-\t\t\t N_(\"check and set terms in a bisection state\"), CHECK_AND_SET_TERMS),\n \t\tOPT_CMDMODE(0, \"bisect-next-check\", &cmdmode,\n \t\t\t N_(\"check whether bad or good terms exist\"), BISECT_NEXT_CHECK),\n \t\tOPT_CMDMODE(0, \"bisect-terms\", &cmdmode,\n@@ -1080,12 +1076,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\t\treturn error(_(\"--bisect-reset requires either no argument or a commit\"));\n \t\tres = bisect_reset(argc ? argv[0] : NULL);\n \t\tbreak;\n-\tcase CHECK_AND_SET_TERMS:\n-\t\tif (argc != 3)\n-\t\t\treturn error(_(\"--check-and-set-terms requires 3 arguments\"));\n-\t\tset_terms(&terms, argv[2], argv[1]);\n-\t\tres = check_and_set_terms(&terms, argv[0]);\n-\t\tbreak;\n \tcase BISECT_NEXT_CHECK:\n \t\tif (argc != 2 && argc != 3)\n \t\t\treturn error(_(\"--bisect-next-check requires 2 or 3 arguments\"));\n-- \n2.29.2\n\n"},{"id":"415270","messageId":"20210125191710.45161-5-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 4/7] bisect--helper: use `res` instead of return in BISECT_RESET case option","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:07Z","receivedAt":"2021-01-26T05:02:44Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nUse `res` variable to store `bisect_reset()` output in BISECT_RESET\ncase option to make bisect--helper.c more consistent.\n\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 0b16653f13..8232e795fa 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -1043,7 +1043,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \tcase BISECT_RESET:\n \t\tif (argc > 1)\n \t\t\treturn error(_(\"--bisect-reset requires either no argument or a commit\"));\n-\t\treturn !!bisect_reset(argc ? argv[0] : NULL);\n+\t\tres = bisect_reset(argc ? argv[0] : NULL);\n \t\tbreak;\n \tcase CHECK_AND_SET_TERMS:\n \t\tif (argc != 3)\n-- \n2.29.2\n\n"},{"id":"415271","messageId":"20210125191710.45161-7-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 6/7] bisect--helper: reimplement `bisect_skip` shell function in C","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:09Z","receivedAt":"2021-01-26T05:02:50Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nReimplement the `bisect_skip()` shell function in C and also add\n`bisect-skip` subcommand to `git bisect--helper` to call it from\ngit-bisect.sh\n\nUsing `--bisect-skip` subcommand is a temporary measure to port shell\nfunction to C so as to use the existing test suite.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 45 +++++++++++++++++++++++++++++++++++++++-\n git-bisect.sh            | 17 +--------------\n 2 files changed, 45 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 3672994c19..145e1a6998 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -30,6 +30,7 @@ static const char * const git_bisect_helper_usage[] = {\n \tN_(\"git bisect--helper --bisect-state (bad|new) [<rev>]\"),\n \tN_(\"git bisect--helper --bisect-state (good|old) [<rev>...]\"),\n \tN_(\"git bisect--helper --bisect-replay <filename>\"),\n+\tN_(\"git bisect--helper --bisect-skip [(<rev>|<range>)...]\"),\n \tNULL\n };\n \n@@ -988,6 +989,41 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f\n \treturn bisect_auto_next(terms, NULL);\n }\n \n+static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **argv, int argc)\n+{\n+\tint i;\n+\tenum bisect_error res;\n+\tstruct strvec argv_state = STRVEC_INIT;\n+\n+\tstrvec_push(&argv_state, \"skip\");\n+\n+\tfor (i = 0; i < argc; i++) {\n+\t\tconst char *dotdot = strstr(argv[i], \"..\");\n+\n+\t\tif (dotdot) {\n+\t\t\tstruct rev_info revs;\n+\t\t\tstruct commit *commit;\n+\n+\t\t\tinit_revisions(&revs, NULL);\n+\t\t\tsetup_revisions(2, argv + i - 1, &revs, NULL);\n+\n+\t\t\tif (prepare_revision_walk(&revs))\n+\t\t\t\tdie(_(\"revision walk setup failed\\n\"));\n+\t\t\twhile ((commit = get_revision(&revs)) != NULL)\n+\t\t\t\tstrvec_push(&argv_state,\n+\t\t\t\t\t\toid_to_hex(&commit->object.oid));\n+\n+\t\t\treset_revision_walk();\n+\t\t} else {\n+\t\t\tstrvec_push(&argv_state, argv[i]);\n+\t\t}\n+\t}\n+\tres = bisect_state(terms, argv_state.v, argv_state.nr);\n+\n+\tstrvec_clear(&argv_state);\n+\treturn res;\n+}\n+\n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tenum {\n@@ -1000,7 +1036,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tBISECT_NEXT,\n \t\tBISECT_STATE,\n \t\tBISECT_LOG,\n-\t\tBISECT_REPLAY\n+\t\tBISECT_REPLAY,\n+\t\tBISECT_SKIP\n \t} cmdmode = 0;\n \tint res = 0, nolog = 0;\n \tstruct option options[] = {\n@@ -1022,6 +1059,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"list the bisection steps so far\"), BISECT_LOG),\n \t\tOPT_CMDMODE(0, \"bisect-replay\", &cmdmode,\n \t\t\t N_(\"replay the bisection process from the given file\"), BISECT_REPLAY),\n+\t\tOPT_CMDMODE(0, \"bisect-skip\", &cmdmode,\n+\t\t\t N_(\"skip some commits for checkout\"), BISECT_SKIP),\n \t\tOPT_BOOL(0, \"no-log\", &nolog,\n \t\t\t N_(\"no log for BISECT_WRITE\")),\n \t\tOPT_END()\n@@ -1084,6 +1123,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tset_terms(&terms, \"bad\", \"good\");\n \t\tres = bisect_replay(&terms, argv[0]);\n \t\tbreak;\n+\tcase BISECT_SKIP:\n+\t\tset_terms(&terms, \"bad\", \"good\");\n+\t\tres = bisect_skip(&terms, argv, argc);\n+\t\tbreak;\n \tdefault:\n \t\tBUG(\"unknown subcommand %d\", cmdmode);\n \t}\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex e834154e29..6a7afaea8d 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -39,21 +39,6 @@ _x40=\"$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40\"\n TERM_BAD=bad\n TERM_GOOD=good\n \n-bisect_skip() {\n-\tall=''\n-\tfor arg in \"$@\"\n-\tdo\n-\t\tcase \"$arg\" in\n-\t\t*..*)\n-\t\t\trevs=$(git rev-list \"$arg\") || die \"$(eval_gettext \"Bad rev input: \\$arg\")\" ;;\n-\t\t*)\n-\t\t\trevs=$(git rev-parse --sq-quote \"$arg\") ;;\n-\t\tesac\n-\t\tall=\"$all $revs\"\n-\tdone\n-\teval git bisect--helper --bisect-state 'skip' $all\n-}\n-\n bisect_visualize() {\n \tgit bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit\n \n@@ -162,7 +147,7 @@ case \"$#\" in\n \tbad|good|new|old|\"$TERM_BAD\"|\"$TERM_GOOD\")\n \t\tgit bisect--helper --bisect-state \"$cmd\" \"$@\" ;;\n \tskip)\n-\t\tbisect_skip \"$@\" ;;\n+\t\tgit bisect--helper --bisect-skip \"$@\" || exit;;\n \tnext)\n \t\t# Not sure we want \"next\" at the UI level anymore.\n \t\tgit bisect--helper --bisect-next \"$@\" || exit ;;\n-- \n2.29.2\n\n"},{"id":"415272","messageId":"20210125191710.45161-6-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 5/7] bisect--helper: retire `--bisect-auto-next` subcommand","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:08Z","receivedAt":"2021-01-26T05:03:07Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nThe --bisect-auto-next subcommand is no longer used from the\ngit-bisect.sh shell script. Instead the function bisect_auto_next()\nis directly called from the C implementation.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 10 ----------\n 1 file changed, 10 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex 8232e795fa..3672994c19 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -27,7 +27,6 @@ static const char * const git_bisect_helper_usage[] = {\n \tN_(\"git bisect--helper --bisect-start [--term-{new,bad}=<term> --term-{old,good}=<term>]\"\n \t\t\t\t\t    \" [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]\"),\n \tN_(\"git bisect--helper --bisect-next\"),\n-\tN_(\"git bisect--helper --bisect-auto-next\"),\n \tN_(\"git bisect--helper --bisect-state (bad|new) [<rev>]\"),\n \tN_(\"git bisect--helper --bisect-state (good|old) [<rev>...]\"),\n \tN_(\"git bisect--helper --bisect-replay <filename>\"),\n@@ -999,7 +998,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tBISECT_START,\n \t\tBISECT_AUTOSTART,\n \t\tBISECT_NEXT,\n-\t\tBISECT_AUTO_NEXT,\n \t\tBISECT_STATE,\n \t\tBISECT_LOG,\n \t\tBISECT_REPLAY\n@@ -1018,8 +1016,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"start the bisect session\"), BISECT_START),\n \t\tOPT_CMDMODE(0, \"bisect-next\", &cmdmode,\n \t\t\t N_(\"find the next bisection commit\"), BISECT_NEXT),\n-\t\tOPT_CMDMODE(0, \"bisect-auto-next\", &cmdmode,\n-\t\t\t N_(\"verify the next bisection state then checkout the next bisection commit\"), BISECT_AUTO_NEXT),\n \t\tOPT_CMDMODE(0, \"bisect-state\", &cmdmode,\n \t\t\t N_(\"mark the state of ref (or refs)\"), BISECT_STATE),\n \t\tOPT_CMDMODE(0, \"bisect-log\", &cmdmode,\n@@ -1072,12 +1068,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tget_terms(&terms);\n \t\tres = bisect_next(&terms, prefix);\n \t\tbreak;\n-\tcase BISECT_AUTO_NEXT:\n-\t\tif (argc)\n-\t\t\treturn error(_(\"--bisect-auto-next requires 0 arguments\"));\n-\t\tget_terms(&terms);\n-\t\tres = bisect_auto_next(&terms, prefix);\n-\t\tbreak;\n \tcase BISECT_STATE:\n \t\tset_terms(&terms, \"bad\", \"good\");\n \t\tget_terms(&terms);\n-- \n2.29.2\n\n"},{"id":"415273","messageId":"20210125191710.45161-4-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 3/7] bisect--helper: retire `--bisect-write` subcommand","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:06Z","receivedAt":"2021-01-26T05:03:32Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nThe `--bisect-write` subcommand is no longer used from the\ngit-bisect.sh shell script. Instead the function `bisect_write()`\nis directly called from the C implementation.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 9 ---------\n 1 file changed, 9 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex d65b2f44c6..0b16653f13 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -21,7 +21,6 @@ static GIT_PATH_FUNC(git_path_bisect_first_parent, \"BISECT_FIRST_PARENT\")\n \n static const char * const git_bisect_helper_usage[] = {\n \tN_(\"git bisect--helper --bisect-reset [<commit>]\"),\n-\tN_(\"git bisect--helper --bisect-write [--no-log] <state> <revision> <good_term> <bad_term>\"),\n \tN_(\"git bisect--helper --bisect-check-and-set-terms <command> <good_term> <bad_term>\"),\n \tN_(\"git bisect--helper --bisect-next-check <good_term> <bad_term> [<term>]\"),\n \tN_(\"git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]\"),\n@@ -994,7 +993,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tenum {\n \t\tBISECT_RESET = 1,\n-\t\tBISECT_WRITE,\n \t\tCHECK_AND_SET_TERMS,\n \t\tBISECT_NEXT_CHECK,\n \t\tBISECT_TERMS,\n@@ -1010,8 +1008,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \tstruct option options[] = {\n \t\tOPT_CMDMODE(0, \"bisect-reset\", &cmdmode,\n \t\t\t N_(\"reset the bisection state\"), BISECT_RESET),\n-\t\tOPT_CMDMODE(0, \"bisect-write\", &cmdmode,\n-\t\t\t N_(\"write out the bisection state in BISECT_LOG\"), BISECT_WRITE),\n \t\tOPT_CMDMODE(0, \"check-and-set-terms\", &cmdmode,\n \t\t\t N_(\"check and set terms in a bisection state\"), CHECK_AND_SET_TERMS),\n \t\tOPT_CMDMODE(0, \"bisect-next-check\", &cmdmode,\n@@ -1048,11 +1044,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tif (argc > 1)\n \t\t\treturn error(_(\"--bisect-reset requires either no argument or a commit\"));\n \t\treturn !!bisect_reset(argc ? argv[0] : NULL);\n-\tcase BISECT_WRITE:\n-\t\tif (argc != 4 && argc != 5)\n-\t\t\treturn error(_(\"--bisect-write requires either 4 or 5 arguments\"));\n-\t\tset_terms(&terms, argv[3], argv[2]);\n-\t\tres = bisect_write(argv[0], argv[1], &terms, nolog);\n \t\tbreak;\n \tcase CHECK_AND_SET_TERMS:\n \t\tif (argc != 3)\n-- \n2.29.2\n\n"},{"id":"415321","messageId":"20210125191710.45161-3-mirucam@gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"[PATCH v4 2/7] bisect--helper: reimplement `bisect_replay` shell function in C","fromName":"Miriam Rubio","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-25T19:17:05Z","receivedAt":"2021-01-26T20:51:54Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"From: Pranit Bauva <pranit.bauva@gmail.com>\n\nReimplement the `bisect_replay` shell function in C and also add\n`--bisect-replay` subcommand to `git bisect--helper` to call it from\ngit-bisect.sh\n\nUsing `--bisect-replay` subcommand is a temporary measure to port shell\nfunction to C so as to use the existing test suite.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 85 +++++++++++++++++++++++++++++++++++++++-\n git-bisect.sh            | 34 +---------------\n 2 files changed, 85 insertions(+), 34 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex a65244a0f5..d65b2f44c6 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -31,6 +31,7 @@ static const char * const git_bisect_helper_usage[] = {\n \tN_(\"git bisect--helper --bisect-auto-next\"),\n \tN_(\"git bisect--helper --bisect-state (bad|new) [<rev>]\"),\n \tN_(\"git bisect--helper --bisect-state (good|old) [<rev>...]\"),\n+\tN_(\"git bisect--helper --bisect-replay <filename>\"),\n \tNULL\n };\n \n@@ -916,6 +917,79 @@ static enum bisect_error bisect_log(void)\n \treturn status ? BISECT_FAILED : BISECT_OK;\n }\n \n+static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)\n+{\n+\tconst char *p = line->buf + strspn(line->buf, \" \\t\");\n+\tchar *word_end, *rev;\n+\n+\tif ((!skip_prefix(p, \"git bisect\", &p) &&\n+\t!skip_prefix(p, \"git-bisect\", &p)) || !isspace(*p))\n+\t\treturn 0;\n+\tp += strspn(p, \" \\t\");\n+\n+\tword_end = (char *)p + strcspn(p, \" \\t\");\n+\trev = word_end + strspn(word_end, \" \\t\");\n+\t*word_end = '\\0'; /* NUL-terminate the word */\n+\n+\tget_terms(terms);\n+\tif (check_and_set_terms(terms, p))\n+\t\treturn -1;\n+\n+\tif (!strcmp(p, \"start\")) {\n+\t\tstruct strvec argv = STRVEC_INIT;\n+\t\tint res;\n+\t\tsq_dequote_to_strvec(rev, &argv);\n+\t\tres = bisect_start(terms, argv.v, argv.nr);\n+\t\tstrvec_clear(&argv);\n+\t\treturn res;\n+\t}\n+\n+\tif (one_of(p, terms->term_good,\n+\t   terms->term_bad, \"skip\", NULL))\n+\t\treturn bisect_write(p, rev, terms, 0);\n+\n+\tif (!strcmp(p, \"terms\")) {\n+\t\tstruct strvec argv = STRVEC_INIT;\n+\t\tint res;\n+\t\tsq_dequote_to_strvec(rev, &argv);\n+\t\tres = bisect_terms(terms, argv.nr == 1 ? argv.v[0] : NULL);\n+\t\tstrvec_clear(&argv);\n+\t\treturn res;\n+\t}\n+\terror(_(\"'%s'?? what are you talking about?\"), p);\n+\n+\treturn -1;\n+}\n+\n+static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *filename)\n+{\n+\tFILE *fp = NULL;\n+\tenum bisect_error res = BISECT_OK;\n+\tstruct strbuf line = STRBUF_INIT;\n+\n+\tif (is_empty_or_missing_file(filename))\n+\t\treturn error(_(\"cannot read file '%s' for replaying\"), filename);\n+\n+\tif (bisect_reset(NULL))\n+\t\treturn BISECT_FAILED;\n+\n+\tfp = fopen(filename, \"r\");\n+\tif (!fp)\n+\t\treturn BISECT_FAILED;\n+\n+\twhile ((strbuf_getline(&line, fp) != EOF) && !res){\n+\t\tres = process_replay_line(terms, &line);\n+\t}\n+\n+\tstrbuf_release(&line);\n+\tfclose(fp);\n+\n+\tif (res)\n+\t\treturn BISECT_FAILED;\n+\n+\treturn bisect_auto_next(terms, NULL);\n+}\n+\n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n \tenum {\n@@ -929,7 +1003,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\tBISECT_NEXT,\n \t\tBISECT_AUTO_NEXT,\n \t\tBISECT_STATE,\n-\t\tBISECT_LOG\n+\t\tBISECT_LOG,\n+\t\tBISECT_REPLAY\n \t} cmdmode = 0;\n \tint res = 0, nolog = 0;\n \tstruct option options[] = {\n@@ -953,6 +1028,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\t\t N_(\"mark the state of ref (or refs)\"), BISECT_STATE),\n \t\tOPT_CMDMODE(0, \"bisect-log\", &cmdmode,\n \t\t\t N_(\"list the bisection steps so far\"), BISECT_LOG),\n+\t\tOPT_CMDMODE(0, \"bisect-replay\", &cmdmode,\n+\t\t\t N_(\"replay the bisection process from the given file\"), BISECT_REPLAY),\n \t\tOPT_BOOL(0, \"no-log\", &nolog,\n \t\t\t N_(\"no log for BISECT_WRITE\")),\n \t\tOPT_END()\n@@ -1020,6 +1097,12 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n \t\t\treturn error(_(\"--bisect-log requires 0 arguments\"));\n \t\tres = bisect_log();\n \t\tbreak;\n+\tcase BISECT_REPLAY:\n+\t\tif (argc != 1)\n+\t\t\treturn error(_(\"no logfile given\"));\n+\t\tset_terms(&terms, \"bad\", \"good\");\n+\t\tres = bisect_replay(&terms, argv[0]);\n+\t\tbreak;\n \tdefault:\n \t\tBUG(\"unknown subcommand %d\", cmdmode);\n \t}\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 05863cc142..e834154e29 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -77,38 +77,6 @@ bisect_visualize() {\n \teval '\"$@\"' --bisect -- $(cat \"$GIT_DIR/BISECT_NAMES\")\n }\n \n-bisect_replay () {\n-\tfile=\"$1\"\n-\ttest \"$#\" -eq 1 || die \"$(gettext \"No logfile given\")\"\n-\ttest -r \"$file\" || die \"$(eval_gettext \"cannot read \\$file for replaying\")\"\n-\tgit bisect--helper --bisect-reset || exit\n-\toIFS=\"$IFS\" IFS=\"$IFS$(printf '\\015')\"\n-\twhile read git bisect command rev tail\n-\tdo\n-\t\ttest \"$git $bisect\" = \"git bisect\" || test \"$git\" = \"git-bisect\" || continue\n-\t\tif test \"$git\" = \"git-bisect\"\n-\t\tthen\n-\t\t\trev=\"$command\"\n-\t\t\tcommand=\"$bisect\"\n-\t\tfi\n-\t\tget_terms\n-\t\tgit bisect--helper --check-and-set-terms \"$command\" \"$TERM_GOOD\" \"$TERM_BAD\" || exit\n-\t\tget_terms\n-\t\tcase \"$command\" in\n-\t\tstart)\n-\t\t\teval \"git bisect--helper --bisect-start $rev $tail\" ;;\n-\t\t\"$TERM_GOOD\"|\"$TERM_BAD\"|skip)\n-\t\t\tgit bisect--helper --bisect-write \"$command\" \"$rev\" \"$TERM_GOOD\" \"$TERM_BAD\" || exit;;\n-\t\tterms)\n-\t\t\tgit bisect--helper --bisect-terms $rev || exit;;\n-\t\t*)\n-\t\t\tdie \"$(gettext \"?? what are you talking about?\")\" ;;\n-\t\tesac\n-\tdone <\"$file\"\n-\tIFS=\"$oIFS\"\n-\tgit bisect--helper --bisect-auto-next || exit\n-}\n-\n bisect_run () {\n \tgit bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit\n \n@@ -203,7 +171,7 @@ case \"$#\" in\n \treset)\n \t\tgit bisect--helper --bisect-reset \"$@\" ;;\n \treplay)\n-\t\tbisect_replay \"$@\" ;;\n+\t\tgit bisect--helper --bisect-replay \"$@\" || exit;;\n \tlog)\n \t\tgit bisect--helper --bisect-log || exit ;;\n \trun)\n-- \n2.29.2\n\n"},{"id":"415338","messageId":"CAN7CjDDQw-Vr_pV=yM0eRXi02F4LjcMfE-9gs5iLS_MU-JPYKQ@mail.gmail.com","threadId":"55050","inReplyTo":"xmqqh7n337nq.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v4 0/7] Finish converting git bisect to C part 3","fromName":"Miriam R.","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-26T18:27:26Z","receivedAt":"2021-01-26T22:19:27Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"Hi Junio,\n\nEl mar, 26 ene 2021 a las 18:55, Junio C Hamano (<gitster@pobox.com>) escribió:\n>\n> Miriam Rubio <mirucam@gmail.com> writes:\n>\n> > These patches correspond to a third part of patch series\n> > of Outreachy project \"Finish converting `git bisect` from shell to C\"\n> > started by Pranit Bauva and Tanushree Tumane\n> > (https://public-inbox.org/git/pull.117.git.gitgitgadget@gmail.com) and\n> > continued by me.\n>\n> Did we lose [2/7] somewhere in the mailing list?  I see the same\n> thing as what is shown in\n>\n> https://lore.kernel.org/git/20210125191710.45161-1-mirucam@gmail.com/\n>\n> i.e. a 7-patch series that lack its second part.\n\nI received the [2/7] patch:\n\n-------------------------------------------\nDe: Miriam Rubio <mirucam@gmail.com>\nDate: lun, 25 ene 2021 a las 20:17\nSubject: [PATCH v4 2/7] bisect--helper: reimplement `bisect_replay`\nshell function in C\nTo: <git@vger.kernel.org>\nCc: Pranit Bauva <pranit.bauva@gmail.com>, Lars Schneider\n<larsxschneider@gmail.com>, Christian Couder\n<chriscool@tuxfamily.org>, Johannes Schindelin\n<Johannes.Schindelin@gmx.de>, Tanushree Tumane\n<tanushreetumane@gmail.com>, Miriam Rubio <mirucam@gmail.com>\n\n\nFrom: Pranit Bauva <pranit.bauva@gmail.com>\n\nReimplement the `bisect_replay` shell function in C and also add\n`--bisect-replay` subcommand to `git bisect--helper` to call it from\ngit-bisect.sh\n\nUsing `--bisect-replay` subcommand is a temporary measure to port shell\nfunction to C so as to use the existing test suite.\n\nMentored-by: Lars Schneider <larsxschneider@gmail.com>\nMentored-by: Christian Couder <chriscool@tuxfamily.org>\nMentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\nSigned-off-by: Pranit Bauva <pranit.bauva@gmail.com>\nSigned-off-by: Tanushree Tumane <tanushreetumane@gmail.com>\nSigned-off-by: Miriam Rubio <mirucam@gmail.com>\n---\n builtin/bisect--helper.c | 85 +++++++++++++++++++++++++++++++++++++++-\n git-bisect.sh            | 34 +---------------\n 2 files changed, 85 insertions(+), 34 deletions(-)\n\ndiff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c\nindex a65244a0f5..d65b2f44c6 100644\n--- a/builtin/bisect--helper.c\n+++ b/builtin/bisect--helper.c\n@@ -31,6 +31,7 @@ static const char * const git_bisect_helper_usage[] = {\n        N_(\"git bisect--helper --bisect-auto-next\"),\n        N_(\"git bisect--helper --bisect-state (bad|new) [<rev>]\"),\n        N_(\"git bisect--helper --bisect-state (good|old) [<rev>...]\"),\n+       N_(\"git bisect--helper --bisect-replay <filename>\"),\n        NULL\n };\n\n@@ -916,6 +917,79 @@ static enum bisect_error bisect_log(void)\n        return status ? BISECT_FAILED : BISECT_OK;\n }\n\n+static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)\n+{\n+       const char *p = line->buf + strspn(line->buf, \" \\t\");\n+       char *word_end, *rev;\n+\n+       if ((!skip_prefix(p, \"git bisect\", &p) &&\n+       !skip_prefix(p, \"git-bisect\", &p)) || !isspace(*p))\n+               return 0;\n+       p += strspn(p, \" \\t\");\n+\n+       word_end = (char *)p + strcspn(p, \" \\t\");\n+       rev = word_end + strspn(word_end, \" \\t\");\n+       *word_end = '\\0'; /* NUL-terminate the word */\n+\n+       get_terms(terms);\n+       if (check_and_set_terms(terms, p))\n+               return -1;\n+\n+       if (!strcmp(p, \"start\")) {\n+               struct strvec argv = STRVEC_INIT;\n+               int res;\n+               sq_dequote_to_strvec(rev, &argv);\n+               res = bisect_start(terms, argv.v, argv.nr);\n+               strvec_clear(&argv);\n+               return res;\n+       }\n+\n+       if (one_of(p, terms->term_good,\n+          terms->term_bad, \"skip\", NULL))\n+               return bisect_write(p, rev, terms, 0);\n+\n+       if (!strcmp(p, \"terms\")) {\n+               struct strvec argv = STRVEC_INIT;\n+               int res;\n+               sq_dequote_to_strvec(rev, &argv);\n+               res = bisect_terms(terms, argv.nr == 1 ? argv.v[0] : NULL);\n+               strvec_clear(&argv);\n+               return res;\n+       }\n+       error(_(\"'%s'?? what are you talking about?\"), p);\n+\n+       return -1;\n+}\n+\n+static enum bisect_error bisect_replay(struct bisect_terms *terms,\nconst char *filename)\n+{\n+       FILE *fp = NULL;\n+       enum bisect_error res = BISECT_OK;\n+       struct strbuf line = STRBUF_INIT;\n+\n+       if (is_empty_or_missing_file(filename))\n+               return error(_(\"cannot read file '%s' for replaying\"),\nfilename);\n+\n+       if (bisect_reset(NULL))\n+               return BISECT_FAILED;\n+\n+       fp = fopen(filename, \"r\");\n+       if (!fp)\n+               return BISECT_FAILED;\n+\n+       while ((strbuf_getline(&line, fp) != EOF) && !res){\n+               res = process_replay_line(terms, &line);\n+       }\n+\n+       strbuf_release(&line);\n+       fclose(fp);\n+\n+       if (res)\n+               return BISECT_FAILED;\n+\n+       return bisect_auto_next(terms, NULL);\n+}\n+\n int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n {\n        enum {\n@@ -929,7 +1003,8 @@ int cmd_bisect__helper(int argc, const char\n**argv, const char *prefix)\n                BISECT_NEXT,\n                BISECT_AUTO_NEXT,\n                BISECT_STATE,\n-               BISECT_LOG\n+               BISECT_LOG,\n+               BISECT_REPLAY\n        } cmdmode = 0;\n        int res = 0, nolog = 0;\n        struct option options[] = {\n@@ -953,6 +1028,8 @@ int cmd_bisect__helper(int argc, const char\n**argv, const char *prefix)\n                         N_(\"mark the state of ref (or refs)\"), BISECT_STATE),\n                OPT_CMDMODE(0, \"bisect-log\", &cmdmode,\n                         N_(\"list the bisection steps so far\"), BISECT_LOG),\n+               OPT_CMDMODE(0, \"bisect-replay\", &cmdmode,\n+                        N_(\"replay the bisection process from the\ngiven file\"), BISECT_REPLAY),\n                OPT_BOOL(0, \"no-log\", &nolog,\n                         N_(\"no log for BISECT_WRITE\")),\n                OPT_END()\n@@ -1020,6 +1097,12 @@ int cmd_bisect__helper(int argc, const char\n**argv, const char *prefix)\n                        return error(_(\"--bisect-log requires 0 arguments\"));\n                res = bisect_log();\n                break;\n+       case BISECT_REPLAY:\n+               if (argc != 1)\n+                       return error(_(\"no logfile given\"));\n+               set_terms(&terms, \"bad\", \"good\");\n+               res = bisect_replay(&terms, argv[0]);\n+               break;\n        default:\n                BUG(\"unknown subcommand %d\", cmdmode);\n        }\ndiff --git a/git-bisect.sh b/git-bisect.sh\nindex 05863cc142..e834154e29 100755\n--- a/git-bisect.sh\n+++ b/git-bisect.sh\n@@ -77,38 +77,6 @@ bisect_visualize() {\n        eval '\"$@\"' --bisect -- $(cat \"$GIT_DIR/BISECT_NAMES\")\n }\n\n-bisect_replay () {\n-       file=\"$1\"\n-       test \"$#\" -eq 1 || die \"$(gettext \"No logfile given\")\"\n-       test -r \"$file\" || die \"$(eval_gettext \"cannot read \\$file for\nreplaying\")\"\n-       git bisect--helper --bisect-reset || exit\n-       oIFS=\"$IFS\" IFS=\"$IFS$(printf '\\015')\"\n-       while read git bisect command rev tail\n-       do\n-               test \"$git $bisect\" = \"git bisect\" || test \"$git\" =\n\"git-bisect\" || continue\n-               if test \"$git\" = \"git-bisect\"\n-               then\n-                       rev=\"$command\"\n-                       command=\"$bisect\"\n-               fi\n-               get_terms\n-               git bisect--helper --check-and-set-terms \"$command\"\n\"$TERM_GOOD\" \"$TERM_BAD\" || exit\n-               get_terms\n-               case \"$command\" in\n-               start)\n-                       eval \"git bisect--helper --bisect-start $rev $tail\" ;;\n-               \"$TERM_GOOD\"|\"$TERM_BAD\"|skip)\n-                       git bisect--helper --bisect-write \"$command\"\n\"$rev\" \"$TERM_GOOD\" \"$TERM_BAD\" || exit;;\n-               terms)\n-                       git bisect--helper --bisect-terms $rev || exit;;\n-               *)\n-                       die \"$(gettext \"?? what are you talking about?\")\" ;;\n-               esac\n-       done <\"$file\"\n-       IFS=\"$oIFS\"\n-       git bisect--helper --bisect-auto-next || exit\n-}\n-\n bisect_run () {\n        git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit\n\n@@ -203,7 +171,7 @@ case \"$#\" in\n        reset)\n                git bisect--helper --bisect-reset \"$@\" ;;\n        replay)\n-               bisect_replay \"$@\" ;;\n+               git bisect--helper --bisect-replay \"$@\" || exit;;\n        log)\n                git bisect--helper --bisect-log || exit ;;\n        run)\n--\n2.29.2\n>\nI have to resend only this patch to the mailing list? or what I have to do?\nThank you.\nMiriam.\n> Thanks.\n"},{"id":"415337","messageId":"xmqqh7n337nq.fsf@gitster.c.googlers.com","threadId":"55050","inReplyTo":"20210125191710.45161-1-mirucam@gmail.com","subject":"Re: [PATCH v4 0/7] Finish converting git bisect to C part 3","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-26T17:55:05Z","receivedAt":"2021-01-26T22:19:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miriam Rubio <mirucam@gmail.com> writes:\n\n> These patches correspond to a third part of patch series \n> of Outreachy project \"Finish converting `git bisect` from shell to C\" \n> started by Pranit Bauva and Tanushree Tumane\n> (https://public-inbox.org/git/pull.117.git.gitgitgadget@gmail.com) and\n> continued by me.\n\nDid we lose [2/7] somewhere in the mailing list?  I see the same\nthing as what is shown in\n\nhttps://lore.kernel.org/git/20210125191710.45161-1-mirucam@gmail.com/\n\ni.e. a 7-patch series that lack its second part.\n\nThanks.\n"},{"id":"415357","messageId":"CAPc5daWO8JT1p0xhBtNyAjvy1hzjt3s-ho7LCPxEe-E_y8-a-w@mail.gmail.com","threadId":"55050","inReplyTo":"CAN7CjDDQw-Vr_pV=yM0eRXi02F4LjcMfE-9gs5iLS_MU-JPYKQ@mail.gmail.com","subject":"Re: [PATCH v4 0/7] Finish converting git bisect to C part 3","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-26T20:05:09Z","receivedAt":"2021-01-26T22:19:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> > Did we lose [2/7] somewhere in the mailing list?  I see the same\n> > thing as what is shown in\n> >\n> > https://lore.kernel.org/git/20210125191710.45161-1-mirucam@gmail.com/\n> >\n> > i.e. a 7-patch series that lack its second part.\n>\n> I received the [2/7] patch:\n>\n> -------------------------------------------\n> De: Miriam Rubio <mirucam@gmail.com>\n> Date: lun, 25 ene 2021 a las 20:17\n> Subject: [PATCH v4 2/7] bisect--helper: reimplement `bisect_replay`\n> shell function in C\n> To: <git@vger.kernel.org>\n> Cc: Pranit Bauva <pranit.bauva@gmail.com>, Lars Schneider\n> <larsxschneider@gmail.com>, Christian Couder\n> <chriscool@tuxfamily.org>, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de>, Tanushree Tumane\n> <tanushreetumane@gmail.com>, Miriam Rubio <mirucam@gmail.com>\n\nIt does not count---you are on the direct path of the message\nand are not relying on the list to relay it back to you.\n\nIt seems that today's one of those days that the mailing list is\nhiccupping. The message I am responding to, which is sent both\nto the list and directly to me, hasn't appeared either on the public-inbox\nor the lore list archive, either.\n\nHopefully we'll see all 7 messages eventually ;-).\n"},{"id":"415419","messageId":"xmqqv9bjz5vm.fsf@gitster.c.googlers.com","threadId":"55050","inReplyTo":"CAPc5daWO8JT1p0xhBtNyAjvy1hzjt3s-ho7LCPxEe-E_y8-a-w@mail.gmail.com","subject":"Re: [PATCH v4 0/7] Finish converting git bisect to C part 3","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-26T22:32:29Z","receivedAt":"2021-01-27T13:37:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> > Did we lose [2/7] somewhere in the mailing list?  I see the same\n>> > thing as what is shown in\n>> >\n>> > https://lore.kernel.org/git/20210125191710.45161-1-mirucam@gmail.com/\n>> >\n>> > i.e. a 7-patch series that lack its second part.\n>>\n>> I received the [2/7] patch:\n>>\n>> -------------------------------------------\n>> De: Miriam Rubio <mirucam@gmail.com>\n>> Date: lun, 25 ene 2021 a las 20:17\n>> Subject: [PATCH v4 2/7] bisect--helper: reimplement `bisect_replay`\n>> shell function in C\n>> To: <git@vger.kernel.org>\n>> Cc: Pranit Bauva <pranit.bauva@gmail.com>, Lars Schneider\n>> <larsxschneider@gmail.com>, Christian Couder\n>> <chriscool@tuxfamily.org>, Johannes Schindelin\n>> <Johannes.Schindelin@gmx.de>, Tanushree Tumane\n>> <tanushreetumane@gmail.com>, Miriam Rubio <mirucam@gmail.com>\n>\n> It does not count---you are on the direct path of the message\n> and are not relying on the list to relay it back to you.\n>\n> It seems that today's one of those days that the mailing list is\n> hiccupping. The message I am responding to, which is sent both\n> to the list and directly to me, hasn't appeared either on the public-inbox\n> or the lore list archive, either.\n>\n> Hopefully we'll see all 7 messages eventually ;-).\n\nNow I am seeing it on the lore NNTP server (so presumably it has\nbeen relayed to list subscribers).\n\n"},{"id":"415425","messageId":"CAN7CjDDH+XyM2y+em=rRTG8aDR7Rb7jBmx+BdJ5BbEe_OESABA@mail.gmail.com","threadId":"55050","inReplyTo":"xmqqv9bjz5vm.fsf@gitster.c.googlers.com","subject":"Re: [PATCH v4 0/7] Finish converting git bisect to C part 3","fromName":"Miriam R.","fromEmail":"mirucam@gmail.com","sentAt":"2021-01-27T14:12:33Z","receivedAt":"2021-01-27T14:16:11Z","isPatch":true,"sender":{"key":"mirucam@gmail.com","avatar":"https://avatars.githubusercontent.com/u/56339109?v=4"},"body":"Hi Junio,\n\nEl mar, 26 ene 2021 a las 23:32, Junio C Hamano (<gitster@pobox.com>) escribió:\n>\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n> >> > Did we lose [2/7] somewhere in the mailing list?  I see the same\n> >> > thing as what is shown in\n> >> >\n> >> > https://lore.kernel.org/git/20210125191710.45161-1-mirucam@gmail.com/\n> >> >\n> >> > i.e. a 7-patch series that lack its second part.\n> >>\n> >> I received the [2/7] patch:\n> >>\n> >> -------------------------------------------\n> >> De: Miriam Rubio <mirucam@gmail.com>\n> >> Date: lun, 25 ene 2021 a las 20:17\n> >> Subject: [PATCH v4 2/7] bisect--helper: reimplement `bisect_replay`\n> >> shell function in C\n> >> To: <git@vger.kernel.org>\n> >> Cc: Pranit Bauva <pranit.bauva@gmail.com>, Lars Schneider\n> >> <larsxschneider@gmail.com>, Christian Couder\n> >> <chriscool@tuxfamily.org>, Johannes Schindelin\n> >> <Johannes.Schindelin@gmx.de>, Tanushree Tumane\n> >> <tanushreetumane@gmail.com>, Miriam Rubio <mirucam@gmail.com>\n> >\n> > It does not count---you are on the direct path of the message\n> > and are not relying on the list to relay it back to you.\n> >\n> > It seems that today's one of those days that the mailing list is\n> > hiccupping. The message I am responding to, which is sent both\n> > to the list and directly to me, hasn't appeared either on the public-inbox\n> > or the lore list archive, either.\n> >\n> > Hopefully we'll see all 7 messages eventually ;-).\n>\n> Now I am seeing it on the lore NNTP server (so presumably it has\n> been relayed to list subscribers).\nOk, perfect!\nBest,\nMiriam\n>\n"},{"id":"415541","messageId":"xmqqczxova6g.fsf@gitster.c.googlers.com","threadId":"55050","inReplyTo":"20210125191710.45161-8-mirucam@gmail.com","subject":"Re: [PATCH v4 7/7] bisect--helper: retire `--check-and-set-terms` subcommand","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-01-29T00:49:59Z","receivedAt":"2021-01-29T00:51:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Miriam Rubio <mirucam@gmail.com> writes:\n\n> From: Pranit Bauva <pranit.bauva@gmail.com>\n>\n> The `--check-and-set-terms` subcommand is no longer from the\n> git-bisect.sh shell script. Instead the function\n> `check_and_set_terms()` is called from the C implementation.\n\nNice to see these intermediate state going away.\n\nReviewers and mentors, how close do you folks think these patches\nare to the completion?  It looks quite good to me (admittedly I gave\nonly a cursory look to these recent iterations).\n\nThanks.\n"},{"id":"415565","messageId":"CAP8UFD2qK2BmdjLnaMzvdyMnr7Xi8phe2GhiCMsj5qNx9pTM-w@mail.gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-3-mirucam@gmail.com","subject":"Re: [PATCH v4 2/7] bisect--helper: reimplement `bisect_replay` shell function in C","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2021-01-29T07:51:12Z","receivedAt":"2021-01-29T07:52:46Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Mon, Jan 25, 2021 at 8:17 PM Miriam Rubio <mirucam@gmail.com> wrote:\n\n> +       while ((strbuf_getline(&line, fp) != EOF) && !res){\n\nIt looks like a space char is missing between \")\" and \"{\"...\n\n> +               res = process_replay_line(terms, &line);\n> +       }\n\n...but as there is only one line in the {...}, we could just get rid\nof the block like this:\n\n       while ((strbuf_getline(&line, fp) != EOF) && !res)\n               res = process_replay_line(terms, &line);\n\nBest,\nChristian.\n"},{"id":"415566","messageId":"CAP8UFD07Ajht9nj3ykYMGW6FnhrScKGBKuTpJMABVvVKuKx9gg@mail.gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-4-mirucam@gmail.com","subject":"Re: [PATCH v4 3/7] bisect--helper: retire `--bisect-write` subcommand","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2021-01-29T07:54:23Z","receivedAt":"2021-01-29T07:55:35Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Mon, Jan 25, 2021 at 8:17 PM Miriam Rubio <mirucam@gmail.com> wrote:\n\n> @@ -1048,11 +1044,6 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n>                 if (argc > 1)\n>                         return error(_(\"--bisect-reset requires either no argument or a commit\"));\n>                 return !!bisect_reset(argc ? argv[0] : NULL);\n\nHere we are returning so we never fall back into the BISECT_WRITE case below...\n\n> -       case BISECT_WRITE:\n> -               if (argc != 4 && argc != 5)\n> -                       return error(_(\"--bisect-write requires either 4 or 5 arguments\"));\n> -               set_terms(&terms, argv[3], argv[2]);\n> -               res = bisect_write(argv[0], argv[1], &terms, nolog);\n>                 break;\n\n...so the above \"break;\" could be removed too.\n\n>         case CHECK_AND_SET_TERMS:\n>                 if (argc != 3)\n"},{"id":"415567","messageId":"CAP8UFD0mezb35u3SPi2Q2w-oCfA8NYAmacropNQQHumC7Vdkxg@mail.gmail.com","threadId":"55050","inReplyTo":"20210125191710.45161-5-mirucam@gmail.com","subject":"Re: [PATCH v4 4/7] bisect--helper: use `res` instead of return in BISECT_RESET case option","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2021-01-29T07:57:40Z","receivedAt":"2021-01-29T07:59:05Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Mon, Jan 25, 2021 at 8:17 PM Miriam Rubio <mirucam@gmail.com> wrote:\n\n> @@ -1043,7 +1043,7 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n>         case BISECT_RESET:\n>                 if (argc > 1)\n>                         return error(_(\"--bisect-reset requires either no argument or a commit\"));\n> -               return !!bisect_reset(argc ? argv[0] : NULL);\n> +               res = bisect_reset(argc ? argv[0] : NULL);\n>                 break;\n\nThis \"break;\" was not necessary before but it becomes necessary when\nthe above \"return ...\" is replaced with something else.\n\n>         case CHECK_AND_SET_TERMS:\n>                 if (argc != 3)\n"},{"id":"415626","messageId":"YBS6YJq0W3VsGf6P@danh.dev","threadId":"55050","inReplyTo":"20210125191710.45161-2-mirucam@gmail.com","subject":"Re: [PATCH v4 1/7] bisect--helper: reimplement `bisect_log` shell function in C","fromName":"Đoàn Trần Công Danh","fromEmail":"congdanhqx@gmail.com","sentAt":"2021-01-30T01:46:08Z","receivedAt":"2021-01-30T01:49:41Z","isPatch":true,"sender":{"key":"congdanhqx@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42673067?v=4"},"body":"> +static enum bisect_error bisect_log(void)\n> +{\n> +\tint fd, status;\n> +\tfd = open(git_path_bisect_log(), O_RDONLY);\n> +\tif (fd < 0)\n> +\t\treturn BISECT_FAILED;\n> +\n> +\tstatus = copy_fd(fd, STDOUT_FILENO);\n> +\tclose(fd);\n> +\treturn status ? BISECT_FAILED : BISECT_OK;\n\nThe old code will write \"We are not bisection.\" to stderr when, well,\nwe're not bisecting. This message suggested an alternative\n https://lore.kernel.org/git/gohp6kv9bml9qc.fsf@gmail.com\n\n> +}\n> +\n>  int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n>  {\n>  \tenum {\n> @@ -916,7 +928,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n>  \t\tBISECT_AUTOSTART,\n>  \t\tBISECT_NEXT,\n>  \t\tBISECT_AUTO_NEXT,\n> -\t\tBISECT_STATE\n> +\t\tBISECT_STATE,\n> +\t\tBISECT_LOG\n>  \t} cmdmode = 0;\n>  \tint res = 0, nolog = 0;\n>  \tstruct option options[] = {\n> @@ -938,6 +951,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n>  \t\t\t N_(\"verify the next bisection state then checkout the next bisection commit\"), BISECT_AUTO_NEXT),\n>  \t\tOPT_CMDMODE(0, \"bisect-state\", &cmdmode,\n>  \t\t\t N_(\"mark the state of ref (or refs)\"), BISECT_STATE),\n> +\t\tOPT_CMDMODE(0, \"bisect-log\", &cmdmode,\n> +\t\t\t N_(\"list the bisection steps so far\"), BISECT_LOG),\n>  \t\tOPT_BOOL(0, \"no-log\", &nolog,\n>  \t\t\t N_(\"no log for BISECT_WRITE\")),\n>  \t\tOPT_END()\n> @@ -1000,6 +1015,11 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)\n>  \t\tget_terms(&terms);\n>  \t\tres = bisect_state(&terms, argv, argc);\n>  \t\tbreak;\n> +\tcase BISECT_LOG:\n> +\t\tif (argc)\n> +\t\t\treturn error(_(\"--bisect-log requires 0 arguments\"));\n> +\t\tres = bisect_log();\n> +\t\tbreak;\n>  \tdefault:\n>  \t\tBUG(\"unknown subcommand %d\", cmdmode);\n>  \t}\n> diff --git a/git-bisect.sh b/git-bisect.sh\n> index 1f3f6e9fc5..05863cc142 100755\n> --- a/git-bisect.sh\n> +++ b/git-bisect.sh\n> @@ -169,11 +169,6 @@ exit code \\$res from '\\$command' is < 0 or >= 128\" >&2\n>  \tdone\n>  }\n>  \n> -bisect_log () {\n> -\ttest -s \"$GIT_DIR/BISECT_LOG\" || die \"$(gettext \"We are not bisecting.\")\"\n> -\tcat \"$GIT_DIR/BISECT_LOG\"\n> -}\n> -\n>  get_terms () {\n>  \tif test -s \"$GIT_DIR/BISECT_TERMS\"\n>  \tthen\n> @@ -210,7 +205,7 @@ case \"$#\" in\n>  \treplay)\n>  \t\tbisect_replay \"$@\" ;;\n>  \tlog)\n> -\t\tbisect_log ;;\n> +\t\tgit bisect--helper --bisect-log || exit ;;\n\nThe original code was \"die\" when no bisect_log available.\n\nI think we need to \"exit 1\" here to indicate a failure, i.e.\n\n\tgit bisect--helper --bisect-log || exit 1 ;;\n\n>  \trun)\n>  \t\tbisect_run \"$@\" ;;\n>  \tterms)\n> -- \n> 2.29.2\n> \n\n-- \nDanh\n"},{"id":"415648","messageId":"CAP8UFD0iZ5WMMV8FZgNx9jFV9W4qMMPXMEN-ExG8jOkw9LLH6g@mail.gmail.com","threadId":"55050","inReplyTo":"YBS6YJq0W3VsGf6P@danh.dev","subject":"Re: [PATCH v4 1/7] bisect--helper: reimplement `bisect_log` shell function in C","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2021-01-30T09:49:14Z","receivedAt":"2021-01-30T09:50:22Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Sat, Jan 30, 2021 at 2:46 AM Đoàn Trần Công Danh\n<congdanhqx@gmail.com> wrote:\n\n> > @@ -210,7 +205,7 @@ case \"$#\" in\n> >       replay)\n> >               bisect_replay \"$@\" ;;\n> >       log)\n> > -             bisect_log ;;\n> > +             git bisect--helper --bisect-log || exit ;;\n>\n> The original code was \"die\" when no bisect_log available.\n>\n> I think we need to \"exit 1\" here to indicate a failure, i.e.\n>\n>         git bisect--helper --bisect-log || exit 1 ;;\n\nActually:\n\n             git bisect--helper --bisect-log || exit ;;\n\nwill indicate failure. See:\n\n$ ( false || exit )\n$ echo $?\n1\n\nThe difference with what you suggest is that the exit code will be the\nsame instead of always 1:\n\n$ ( ( exit 4 ) || exit )\necho $?\n4\n\nwhich is a good thing, as die() exits with code 128, so if `git\nbisect--helper --bisect-log` die()s then we will get a 128 exit code\nwith `|| exit` instead of 1 with `|| exit 1`.\n\nThanks for your review,\nChristian.\n"}]}