29
N_("git bisect--helper --bisect-terms [--term-good | --term-old | --term-bad | --term-new]"),
30
N_("git bisect--helper --bisect-start [--term-{old,good}=<term> --term-{new,bad}=<term>]"
31
" [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<paths>...]"),
32
+ N_("git bisect--helper --bisect-autostart"),
33
NULL
34
};
35
654
return res;
655
}
656
657
+static inline int file_is_not_empty(const char *path)
658
+{
659
+ return !is_empty_or_missing_file(path);
660
+}
661
+
662
+static int bisect_autostart(struct bisect_terms *terms)
663
+{
664
+ int res;
665
+ const char *yesno;
666
+
667
+ if (file_is_not_empty(git_path_bisect_start()))
668
+ return 0;
669
+
670
+ fprintf_ln(stderr, _("You need to start by \"git bisect "
671
+ "start\"\n"));
672
+
673
+ if (!isatty(STDIN_FILENO))
674
+ return -1;
675
+
676
+ /*
677
+ * TRANSLATORS: Make sure to include [Y] and [n] in your
678
+ * translation. The program will only accept English input
679
+ * at this point.
680
+ */
681
+ yesno = git_prompt(_("Do you want me to do it for you "
682
+ "[Y/n]? "), PROMPT_ECHO);
683
+ res = tolower(*yesno) == 'n' ?
684
+ -1 : bisect_start(terms, empty_strvec, 0);
685
+
686
+ return res;
687
+}
688
+
689
int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
690
{
691
enum {
698
CHECK_AND_SET_TERMS,
699
BISECT_NEXT_CHECK,
700
BISECT_TERMS,
668
- BISECT_START
701
+ BISECT_START,
702
+ BISECT_AUTOSTART,
703
} cmdmode = 0;
704
int res = 0, nolog = 0;
705
struct option options[] = {
723
N_("print out the bisect terms"), BISECT_TERMS),
724
OPT_CMDMODE(0, "bisect-start", &cmdmode,
725
N_("start the bisect session"), BISECT_START),
726
+ OPT_CMDMODE(0, "bisect-autostart", &cmdmode,
727
+ N_("start the bisection if it has not yet been started"), BISECT_AUTOSTART),
728
OPT_BOOL(0, "no-log", &nolog,
729
N_("no log for BISECT_WRITE")),
730
OPT_END()
784
set_terms(&terms, "bad", "good");
785
res = bisect_start(&terms, argv, argc);
786
break;
787
+ case BISECT_AUTOSTART:
788
+ if (argc)
789
+ return error(_("--bisect-autostart does not accept arguments"));
790
+ set_terms(&terms, "bad", "good");
791
+ res = bisect_autostart(&terms);
792
+ break;
793
default:
794
BUG("unknown subcommand %d", cmdmode);
795
}