From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Miriam Rubio <mirucam@gmail.com>
Cc: git@vger.kernel.org, Pranit Bauva <pranit.bauva@gmail.com>,
Christian Couder <chriscool@tuxfamily.org>,
Tanushree Tumane <tanushreetumane@gmail.com>
Subject: Re: [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C
Date: Tue, 17 Aug 2021 13:30:42 +0200 (CEST) [thread overview]
Message-ID: <nycvar.QRO.7.76.6.2108171329241.55@tvgsbejvaqbjf.bet> (raw)
In-Reply-To: <20210817081458.53136-5-mirucam@gmail.com>
Hi Miriam,
this looks good!
Just one suggestion (but I won't insist on it):
On Tue, 17 Aug 2021, Miriam Rubio wrote:
> @@ -1036,6 +1037,44 @@ static enum bisect_error bisect_skip(struct bisect_terms *terms, const char **ar
> return res;
> }
>
> +static int bisect_visualize(struct bisect_terms *terms, const char **argv, int argc)
> +{
> + struct strvec args = STRVEC_INIT;
> + int flags = RUN_COMMAND_NO_STDIN, res = 0;
> + struct strbuf sb = STRBUF_INIT;
> +
> + if (bisect_next_check(terms, NULL) != 0)
> + return BISECT_FAILED;
> +
> + if (!argc) {
> + if ((getenv("DISPLAY") || getenv("SESSIONNAME") || getenv("MSYSTEM") ||
> + getenv("SECURITYSESSIONID")) && exists_in_PATH("gitk"))
> + strvec_push(&args, "gitk");
> + else {
> + strvec_pushl(&args, "log", NULL);
This could be written more concisely as `strvec_push(&args, "log")`.
> + flags |= RUN_GIT_CMD;
> + }
> + } else {
> + if (argv[0][0] == '-') {
> + strvec_pushl(&args, "log", NULL);
Same here.
Otherwise, it looks good to me!
Thank you,
Dscho
> + flags |= RUN_GIT_CMD;
> + } else if (strcmp(argv[0], "tig") && !starts_with(argv[0], "git"))
> + flags |= RUN_GIT_CMD;
> +
> + strvec_pushv(&args, argv);
> + }
> +
> + strvec_pushl(&args, "--bisect", "--", NULL);
> +
> + strbuf_read_file(&sb, git_path_bisect_names(), 0);
> + sq_dequote_to_strvec(sb.buf, &args);
> + strbuf_release(&sb);
> +
> + res = run_command_v_opt(args.v, flags);
> + strvec_clear(&args);
> + return res;
> +}
> +
> int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> {
> enum {
> @@ -1048,7 +1087,8 @@ int cmd_bisect__helper(int argc, const char **argv, const char *prefix)
> BISECT_STATE,
> BISECT_LOG,
> BISECT_REPLAY,
> - BISECT_SKIP
> + BISECT_SKIP,
> + BISECT_VISUALIZE,
> } cmdmode = 0;
> int res = 0, nolog = 0;
> struct option options[] = {
> @@ -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);
> }
> diff --git a/git-bisect.sh b/git-bisect.sh
> index 6a7afaea8d..95f7f3fb8c 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -39,29 +39,6 @@ _x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
> TERM_BAD=bad
> TERM_GOOD=good
>
> -bisect_visualize() {
> - git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
> -
> - if test $# = 0
> - then
> - if test -n "${DISPLAY+set}${SESSIONNAME+set}${MSYSTEM+set}${SECURITYSESSIONID+set}" &&
> - type gitk >/dev/null 2>&1
> - then
> - set gitk
> - else
> - set git log
> - fi
> - else
> - case "$1" in
> - git*|tig) ;;
> - -*) set git log "$@" ;;
> - *) set git "$@" ;;
> - esac
> - fi
> -
> - eval '"$@"' --bisect -- $(cat "$GIT_DIR/BISECT_NAMES")
> -}
> -
> bisect_run () {
> git bisect--helper --bisect-next-check $TERM_GOOD $TERM_BAD fail || exit
>
> @@ -152,7 +129,7 @@ case "$#" in
> # Not sure we want "next" at the UI level anymore.
> git bisect--helper --bisect-next "$@" || exit ;;
> visualize|view)
> - bisect_visualize "$@" ;;
> + git bisect--helper --bisect-visualize "$@" || exit;;
> reset)
> git bisect--helper --bisect-reset "$@" ;;
> replay)
> --
> 2.29.2
>
>
next prev parent reply other threads:[~2021-08-17 11:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-17 8:14 [PATCH v4 0/6]Finish converting git bisect to C part 4 Miriam Rubio
2021-08-17 8:14 ` [PATCH v4 1/6] t6030-bisect-porcelain: add tests to control bisect run exit cases Miriam Rubio
2021-08-17 9:00 ` Bagas Sanjaya
2021-08-17 9:23 ` Christian Couder
2021-08-17 20:19 ` Miriam R.
2021-08-17 8:14 ` [PATCH v4 2/6] t6030-bisect-porcelain: add test for bisect visualize Miriam Rubio
2021-08-17 9:03 ` Bagas Sanjaya
2021-08-17 20:17 ` Miriam R.
2021-08-17 8:14 ` [PATCH v4 3/6] run-command: make `exists_in_PATH()` non-static Miriam Rubio
2021-08-17 8:14 ` [PATCH v4 4/6] bisect--helper: reimplement `bisect_visualize()`shell function in C Miriam Rubio
2021-08-17 11:30 ` Johannes Schindelin [this message]
2021-08-17 20:19 ` Miriam R.
2021-08-17 8:14 ` [PATCH v4 5/6] bisect--helper: reimplement `bisect_run` shell " Miriam Rubio
2021-08-17 11:42 ` Johannes Schindelin
2021-08-17 20:22 ` Miriam R.
2021-08-17 21:36 ` Johannes Schindelin
2021-08-18 8:33 ` Christian Couder
2021-08-18 9:43 ` Miriam R.
2021-08-17 8:14 ` [PATCH v4 6/6] bisect--helper: retire `--bisect-next-check` subcommand Miriam Rubio
2021-08-17 11:57 ` Johannes Schindelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=nycvar.QRO.7.76.6.2108171329241.55@tvgsbejvaqbjf.bet \
--to=johannes.schindelin@gmx.de \
--cc=chriscool@tuxfamily.org \
--cc=git@vger.kernel.org \
--cc=mirucam@gmail.com \
--cc=pranit.bauva@gmail.com \
--cc=tanushreetumane@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).