Re: [PATCH 2/3] bisect: remove CR characters from revision in replay

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Carlo Marcelo Arenas Belón  <carenas@xxxxxxxxx> writes:

> 6c722cbe5a (bisect: allow CRLF line endings in "git bisect replay"
> input, 2020-05-07) includes CR as a field separator, but doesn't
> account for it being included in the last field, breaking when
> running at least under OpenBSD 6.7's sh.
>
> Read the revision into a raw variable and strip it of any possible
> embeded CR characters, before use.

That's quite unsatisfactory, as the whole point of adding CR to IFS
was to avoid having to spawn extra processes for this kind of text
processing.  If we were to do the preprocessing, we are better off
just passing the whole input thru "tr -d '\015'".

>  	oIFS="$IFS" IFS="$IFS$(printf '\015')"
> -	while read git bisect command rev
> +	while read git bisect command rawrev
>  	do
>  		test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
>  		if test "$git" = "git-bisect"
>  		then
> -			rev="$command"
> +			rawrev="$command"
>  			command="$bisect"
>  		fi
> +		rev=$(echo $rawrev | tr -d '\015')

As we know that "rev" ought to consist of just hexadecimal and
cannot be split into two at $IFS even if we don't tell "read" that
"everything at the end of line is 'rev'", can we do

	while read git bisect command rev ignored

so that we'll get an empty string after CR in $ignored when reading
CRLF input, and an empty string because we ran out of the tokens
when reading LF input?

That is, ...

 git-bisect.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-bisect.sh b/git-bisect.sh
index 71b367a944..2a7599b486 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -210,7 +210,7 @@ bisect_replay () {
 	test -r "$file" || die "$(eval_gettext "cannot read \$file for replaying")"
 	git bisect--helper --bisect-reset || exit
 	oIFS="$IFS" IFS="$IFS$(printf '\015')"
-	while read git bisect command rev
+	while read git bisect command rev ignored
 	do
 		test "$git $bisect" = "git bisect" || test "$git" = "git-bisect" || continue
 		if test "$git" = "git-bisect"




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux