git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Christopher Warrington via GitGitGadget <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Christopher Warrington <chwarr@microsoft.com>
Subject: Re: [PATCH] bisect: fix replay of CRLF logs
Date: Thu, 7 May 2020 18:25:10 -0400	[thread overview]
Message-ID: <20200507222510.GA42822@coredump.intra.peff.net> (raw)
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:

> 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

  parent reply	other threads:[~2020-05-07 22:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 21:29 [PATCH] bisect: fix replay of CRLF logs Christopher Warrington via GitGitGadget
2020-05-07 22:13 ` Eric Sunshine
2020-05-07 22:25 ` Jeff King [this message]
2020-05-07 23:07   ` Junio C Hamano
2020-05-08 13:08     ` Jeff King
2020-05-08 15:07       ` Junio C Hamano
2020-05-08 16:28         ` Junio C Hamano
2020-05-08 17:12           ` Jeff King
2020-05-08 17:53             ` Junio C Hamano
2020-05-09 22:17             ` brian m. carlson
2020-05-10 10:54               ` Achim Gratz
2020-05-08 22:59           ` [EXTERNAL] " Christopher Warrington (CHRISTOPHER)
2020-05-09 16:28             ` Junio C Hamano

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=20200507222510.GA42822@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=chwarr@microsoft.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@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;
as well as URLs for NNTP newsgroup(s).