summaryrefslogtreecommitdiff
path: root/builtin/bisect--helper.c
diff options
context:
space:
mode:
authorLibravatar Pranit Bauva <pranit.bauva@gmail.com>2021-02-03 22:54:37 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-02-03 14:52:09 -0800
commite4c7b33747dccc6600bc528b51e91c11b474eb04 (patch)
treefefe82dc2dba4103f2d757b3085ee408630c9da5 /builtin/bisect--helper.c
parentbisect--helper: retire `--bisect-auto-next` subcommand (diff)
downloadtgif-e4c7b33747dccc6600bc528b51e91c11b474eb04.tar.xz
bisect--helper: reimplement `bisect_skip` shell function in C
Reimplement the `bisect_skip()` shell function in C and also add `bisect-skip` subcommand to `git bisect--helper` to call it from git-bisect.sh Using `--bisect-skip` subcommand is a temporary measure to port shell function to C so as to use the existing test suite. Mentored-by: Lars Schneider <larsxschneider@gmail.com> Mentored-by: Christian Couder <chriscool@tuxfamily.org> Mentored-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Pranit Bauva <pranit.bauva@gmail.com> Signed-off-by: Tanushree Tumane <tanushreetumane@gmail.com> Signed-off-by: Miriam Rubio <mirucam@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/bisect--helper.c')
-rw-r--r--builtin/bisect--helper.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/builtin/bisect--helper.c b/builtin/bisect--helper.c
index 31eba522ff..7ad9b4d55b 100644
--- a/builtin/bisect--helper.c
+++ b/builtin/bisect--helper.c
@@ -30,6 +30,7 @@ static const char * const git_bisect_helper_usage[] = {
N_("git bisect--helper --bisect-state (bad|new) [<rev>]"),
N_("git bisect--helper --bisect-state (good|old) [<rev>...]"),
N_("git bisect--helper --bisect-replay <filename>"),
+ N_("git bisect--helper --bisect-skip [(<rev>|<range>)...]"),
NULL
};
@@ -992,6 +993,41 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f
return bisect_auto_next(terms, NULL);
}
+static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **argv, int argc)
+{
+ int i;
+ enum bisect_error res;
+ struct strvec argv_state = STRVEC_INIT;
+
+ strvec_push(&argv_state, "skip");
+
+ for (i = 0; i < argc; i++) {
+ const char *dotdot = strstr(argv[i], "..");
+
+ if (dotdot) {
+ struct rev_info revs;
+ struct commit *commit;
+
+ init_revisions(&revs, NULL);
+ setup_revisions(2, argv + i - 1, &revs, NULL);
+
+ if (prepare_revision_walk(&revs))
+ die(_("revision walk setup failed\n"));
+ while ((commit = get_revision(&revs)) != NULL)
+ strvec_push(&argv_state,
+ oid_to_hex(&commit->object.oid));
+
+ reset_revision_walk();
+ } else {
+ strvec_push(&argv_state, argv[i]);
+ }
+ }
+ res = bisect_state(terms, argv_state.v, argv_state.nr);
+
+ strvec_clear(&argv_state);
+ return res;
+}
+
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
{
enum {
@@ -1004,7 +1040,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
BISECT_NEXT,
BISECT_STATE,
BISECT_LOG,
- BISECT_REPLAY
+ BISECT_REPLAY,
+ BISECT_SKIP
} cmdmode = 0;
int res = 0, nolog = 0;
struct option options[] = {
@@ -1026,6 +1063,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
N_("list the bisection steps so far"), BISECT_LOG),
OPT_CMDMODE(0, "bisect-replay", &cmdmode,
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_BOOL(0, "no-log", &nolog,
N_("no log for BISECT_WRITE")),
OPT_END()
@@ -1088,6 +1127,10 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
set_terms(&terms, "bad", "good");
res = bisect_replay(&terms, argv[0]);
break;
+ case BISECT_SKIP:
+ set_terms(&terms, "bad", "good");
+ res = bisect_skip(&terms, argv, argc);
+ break;
default:
BUG("unknown subcommand %d", cmdmode);
}