From: Junio C Hamano <gitster@pobox.com>
To: "Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Harald Nordgren <haraldnordgren@gmail.com>
Subject: Re: [PATCH v2 1/3] bisect: read run output from the open descriptor
Date: Fri, 17 Jul 2026 15:42:58 -0700 [thread overview]
Message-ID: <xmqqpl0l1bm5.fsf@gitster.g> (raw)
In-Reply-To: <0de8b12f65530497320b6a4bca395dfd0556c959.1784312854.git.gitgitgadget@gmail.com> (Harald Nordgren via GitGitGadget's message of "Fri, 17 Jul 2026 18:27:32 +0000")
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Harald Nordgren <haraldnordgren@gmail.com>
>
> "git bisect run" redirects each step's output into BISECT_RUN, then
> prints it back by reopening the file by name. Read it from the already
> open descriptor instead; this behaves the same and no longer needs the
> file to be reachable by name.
>
> Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
> ---
> builtin/bisect.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/builtin/bisect.c b/builtin/bisect.c
> index 798e28f501..69ea14b1b6 100644
> --- a/builtin/bisect.c
> +++ b/builtin/bisect.c
> @@ -178,17 +178,13 @@ static int append_to_file(const char *path, const char *format, ...)
> return res;
> }
>
> -static int print_file_to_stdout(const char *path)
> +static int print_fd_to_stdout(int fd)
> {
> - int fd = open(path, O_RDONLY);
> - int ret = 0;
> -
> - if (fd < 0)
> - return error_errno(_("cannot open file '%s' for reading"), path);
> + if (lseek(fd, 0, SEEK_SET) < 0)
> + return error_errno(_("failed to rewind BISECT_RUN output"));
OK. So, instead of the usual 'O_CREAT | O_WRONLY', you use 'O_RDWR'
instead, so that we can switch from writing to reading at this
point. That makes sense.
I wonder if there are cases where we somehow fail to seek, and
yet are still able to open the path for reading and copy the
data successfully. If such a case is common, this change
would be a regression, but I cannot offhand think of a
scenario where that would occur.
Will queue.
Thanks.
next prev parent reply other threads:[~2026-07-17 22:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-16 5:35 [PATCH 0/3] bisect: add --auto-reset to leave when done Harald Nordgren via GitGitGadget
2026-07-16 5:35 ` [PATCH 1/3] bisect: read run output from the open descriptor Harald Nordgren via GitGitGadget
2026-07-16 5:35 ` [PATCH 2/3] bisect: let bisect_reset() optionally check out quietly Harald Nordgren via GitGitGadget
2026-07-16 5:35 ` [PATCH 3/3] bisect: add --auto-reset to leave when done Harald Nordgren via GitGitGadget
2026-07-16 17:22 ` Junio C Hamano
2026-07-16 21:22 ` Harald Nordgren
2026-07-17 5:00 ` Junio C Hamano
2026-07-17 9:16 ` Harald Nordgren
2026-07-17 16:43 ` Junio C Hamano
2026-07-17 18:27 ` [PATCH v2 0/3] " Harald Nordgren via GitGitGadget
2026-07-17 18:27 ` [PATCH v2 1/3] bisect: read run output from the open descriptor Harald Nordgren via GitGitGadget
2026-07-17 22:42 ` Junio C Hamano [this message]
2026-07-17 18:27 ` [PATCH v2 2/3] bisect: let bisect_reset() optionally check out quietly Harald Nordgren via GitGitGadget
2026-07-17 18:27 ` [PATCH v2 3/3] bisect: add --auto-reset to leave when done Harald Nordgren via GitGitGadget
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqpl0l1bm5.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=haraldnordgren@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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox