git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Fix git-bisect when show-branch is configured to run with pager

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 26, 2021, 18:39 UTC
Message-ID
<xmqq4kcgkjhk.fsf@gitster.g>
In-Reply-To
<pull.1003.git.1627311659384.gitgitgadget@gmail.com>
"Oded S via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Subject: Re: [PATCH] Fix git-bisect when show-branch is configured to run with pager
Perhaps
    Subject: bisect: disable pager while invoking show-branch
cf. Documentation/SubmittingPatches (describe-changes)
> From: Oded Shimon <oded@istraresearch.com>

Here is the space for you to answer these potential questions by future readers of your code in "git log -p" output in advance:

 * The title says "fix", but how is it broken?  If the user prefers
   to run show-branch with their pager, why would it be a good
   change to unilaterally countermand that preference?
 * When is show-branch invoked in the "git bisect" session?  Perhaps
   that justifies the unilateral disabling of the pager, but it is
   not explained here so we cannot tell why the author of this
   change thought it was a good idea.
 * We see in the patch context that "checkout" is also invoked
   somewhere in the same program, but it does not gain the
   "--no-pager" option.  Why?  If those who prefer show-branch to
   page have trouble using "bisect", wouldn't those who prefer
   "checkout" to page have the same trouble?
> Signed-off-by: Oded Shimon <oded@istraresearch.com>

Thanks for trying to make Git better. I cannot quite tell without these questions (and there may be others) answered in the proposed log message if the proposed change is a good one.

Also, in the longer term, I suspect that we probably should stop calling show-branch from this codepath and here is why.

If we look at "git show v1.5.3:git-bisect.sh" and look for invocation of show-branch, and look for show-branch in the current codebase wrt bisect, i.e.

    $ git grep show-branch bisect.c git-bisect.sh builtin/bisect--helper.c

we notice that we used to call the command in many more places to write into BISECT_LOG and also after checking out the commit to be tested. In today's code, the latter is the only place that still uses show-branch. What happend to the use of the other one? IOW, how do we write BISECT_LOG these days in such a way that it is compatible/comparable to the output we got from show-branch in olden times? Would it easy to emulate it so that we do not use show-branch at all? If so, reusing how the part that writes BISECT_LOG does to show the revision after checking it out may be a good clean-up, regardless of "show-branch pages" issue.

In any case, if the "for those with show-branch configured to page, the current behaviour of bisect needs fixing" is true, then I think your patch may even be worth applying before such a longer-term change.

Thanks.
Show 35 quoted lines
>     Fix git-bisect when show-branch is configured to run with pager
>     
>     Signed-off-by: Oded Shimon oded@istraresearch.com
>
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1003%2Foded-ist%2Fmaster-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1003/oded-ist/master-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/1003
>
>  bisect.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/bisect.c b/bisect.c
> index af2863d044b..c02bcc3359f 100644
> --- a/bisect.c
> +++ b/bisect.c
> @@ -23,7 +23,7 @@ static struct oid_array skipped_revs;
>  static struct object_id *current_bad_oid;
>  
>  static const char *argv_checkout[] = {"checkout", "-q", NULL, "--", NULL};
> -static const char *argv_show_branch[] = {"show-branch", NULL, NULL};
> +static const char *argv_show_branch[] = {"-P", "show-branch", NULL, NULL};
>  
>  static const char *term_bad;
>  static const char *term_good;
> @@ -748,7 +748,7 @@ static enum bisect_error bisect_checkout(const struct object_id *bisect_rev, int
>  			return -abs(res);
>  	}
>  
> -	argv_show_branch[1] = bisect_rev_hex;
> +	argv_show_branch[2] = bisect_rev_hex;
>  	res = run_command_v_opt(argv_show_branch, RUN_GIT_CMD);
>  	/*
>  	 * Errors in `run_command()` itself, signaled by res < 0,
>
> base-commit: eb27b338a3e71c7c4079fbac8aeae3f8fbb5c687
Previous: Christian CouderNext: Junio C Hamano
Message 3 of 10 in “Fix git-bisect when show-branch is configured to run with pager”
  1. Fix git-bisect when show-branch is configured to run with pagerOded S via GitGitGadget, Jul 26, 2021
  2. Christian CouderJul 26, 2021
  3. Junio C HamanoJul 26, 2021
  4. Junio C HamanoJul 27, 2021
  5. Christian CouderJul 28, 2021
  6. Junio C HamanoJul 28, 2021
  7. Re* [PATCH] Fix git-bisect when show-branch is configured to run with pagerJunio C Hamano, Jul 28, 2021
  8. Christian CouderJul 29, 2021
  9. bisect: disable pager while invoking show-branchOded S via GitGitGadget, Jul 27, 2021
  10. Junio C HamanoJul 27, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.