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

Re: [PATCH] bisect: fix replay of CRLF logs

From
Jeff King <peff@peff.net>
Date
May 7, 2020, 22:25 UTC
Message-ID
<20200507222510.GA42822@coredump.intra.peff.net>
In-Reply-To
<pull.629.git.1588886980377.gitgitgadget@gmail.com>
On Thu, May 07, 2020 at 09:29:40PM +0000, Christopher Warrington via GitGitGadget wrote:
Show 23 quoted lines
> diff --git a/git-bisect.sh b/git-bisect.sh
> index efee12b8b1e..8406a9adc36 100755
> --- a/git-bisect.sh
> +++ b/git-bisect.sh
> @@ -209,7 +209,11 @@ bisect_replay () {
>  	test "$#" -eq 1 || die "$(gettext "No logfile given")"
>  	test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
>  	git bisect--helper --bisect-reset || exit
> -	while read git bisect command rev
> +
> +	# We remove any CR in the input to handle bisect log files that have
> +	# CRLF line endings. The assumption is that CR within bisect
> +	# commands also don't matter.
> +	tr -d '\r' <"$file" | while read git bisect command rev
>  	do
>  		test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
>  		if test "$git" = "git-bisect"
> @@ -231,7 +235,9 @@ bisect_replay () {
>  		*)
>  			die "$(gettext "?? what are you talking about?")" ;;
>  		esac
> -	done <"$file"
> +	done

This puts the while-loop on the right-hand side of a pipe, which means that it's not running in the main shell environment any longer. So any variables set will be lost after the loop ends, any calls to exit will only exit the loop and not the whole script, etc.

It looks like we might call into bisect_start inside the loop, which does exit. I didn't trace all the way through its sub-functions to see if they set variables.

The simplest fix is probably to clean up "$file" into another tempfile, and then read from that.

-Peff
Previous: Eric SunshineNext: Junio C Hamano
Message 3 of 13 in “bisect: fix replay of CRLF logs”
  1. bisect: fix replay of CRLF logsChristopher Warrington via GitGitGadget, May 7, 2020
  2. Eric SunshineMay 7, 2020
  3. Jeff KingMay 7, 2020
  4. Junio C HamanoMay 7, 2020
  5. Jeff KingMay 8, 2020
  6. Junio C HamanoMay 8, 2020
  7. Junio C HamanoMay 8, 2020
  8. Jeff KingMay 8, 2020
  9. Junio C HamanoMay 8, 2020
  10. brian m. carlsonMay 9, 2020
  11. Achim GratzMay 10, 2020
  12. Christopher Warrington (CHRISTOPHER)May 8, 2020
  13. Junio C HamanoMay 9, 2020

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.