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

Re: [PATCH v2 1/3] bisect: read run output from the open descriptor

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 17, 2026, 22:42 UTC
Message-ID
<xmqqpl0l1bm5.fsf@gitster.g>
In-Reply-To
<0de8b12f65530497320b6a4bca395dfd0556c959.1784312854.git.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 30 quoted lines
> 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.
Previous: Harald Nordgren via GitGitGadgetNext: Johannes Sixt
Message 12 of 42 in “bisect: add --auto-reset to leave when done”
  1. 0/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 16, 2026
  2. 1/3 bisect: read run output from the open descriptorHarald Nordgren via GitGitGadget, Jul 16, 2026
  3. 2/3 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Jul 16, 2026
  4. 3/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 16, 2026
  5. Junio C HamanoJul 16, 2026
  6. Harald NordgrenJul 16, 2026
  7. Junio C HamanoJul 17, 2026
  8. Harald NordgrenJul 17, 2026
  9. Junio C HamanoJul 17, 2026
  10. 0/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 17, 2026
  11. 1/3 bisect: read run output from the open descriptorHarald Nordgren via GitGitGadget, Jul 17, 2026
  12. Junio C HamanoJul 17, 2026
  13. Johannes SixtJul 18, 2026
  14. 2/3 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Jul 17, 2026
  15. 3/3 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 17, 2026
  16. Johannes SixtJul 18, 2026
  17. Junio C HamanoJul 20, 2026
  18. 0/2 bisect: add --auto-reset to leave when doneHarald Nordgren via GitGitGadget, Jul 20, 2026
  19. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Jul 20, 2026
  20. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Jul 20, 2026
  21. Johannes SixtJul 23, 2026
  22. Junio C HamanoJul 23, 2026
  23. Harald NordgrenAug 1, 2026
  24. Junio C HamanoJul 20, 2026
  25. 0/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 1, 2026
  26. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Aug 1, 2026
  27. Junio C HamanoAug 1, 2026
  28. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 1, 2026
  29. Junio C HamanoAug 1, 2026
  30. Junio C HamanoAug 1, 2026
  31. 0/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  32. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Aug 2, 2026
  33. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  34. Junio C HamanoAug 2, 2026
  35. 0/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  36. 1/2 bisect: let bisect_reset() optionally check out quietlyHarald Nordgren via GitGitGadget, Aug 2, 2026
  37. 2/2 bisect: add --reset-when-found to leave when doneHarald Nordgren via GitGitGadget, Aug 2, 2026
  38. Junio C HamanoAug 3, 2026
  39. Harald NordgrenAug 6, 2026
  40. Junio C HamanoAug 6, 2026
  41. Harald NordgrenAug 6, 2026
  42. Junio C HamanoAug 6, 2026

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.