All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: "Torsten Bögershausen" <tboegi@web.de>,
	"Anders Kaseorg" <andersk@mit.edu>,
	gitster@pobox.com
Cc: git@vger.kernel.org
Subject: Re: [PATCH] rebase -p: avoid grep on potentailly non-ASCII data
Date: Tue, 8 Mar 2016 14:45:20 +0100	[thread overview]
Message-ID: <56DED770.4050603@drmicha.warpmail.net> (raw)
In-Reply-To: <56DEC4B4.2000902@web.de>

Torsten Bögershausen venit, vidit, dixit 08.03.2016 13:25:
> On 03/08/2016 08:59 AM, Anders Kaseorg wrote:
>> The included test case, which uses rebase -p with non-ASCII commit
>> messages, was failing as follows:
>>
>>    Warning: the command isn't recognized in the following line:
>>     - Binary file (standard input) matches
>>
>>    You can fix this with 'git rebase --edit-todo'.
>>    Or you can abort the rebase with 'git rebase --abort'.
>>
>> Possibly related to recent GNU grep changes, as with commit
>> 316336379cf7937c2ecf122c7197cfe5da6b2061.  Avoid the issue by using sed
>> instead.
>>
>> Signed-off-by: Anders Kaseorg <andersk@mit.edu>
>> ---
>>   git-rebase--interactive.sh        |  2 +-
>>   t/t3409-rebase-preserve-merges.sh | 21 +++++++++++++++++++++
>>   2 files changed, 22 insertions(+), 1 deletion(-)
>>
>> diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
>> index c0cfe88..0efc65c 100644
>> --- a/git-rebase--interactive.sh
>> +++ b/git-rebase--interactive.sh
>> @@ -1241,7 +1241,7 @@ then
>>   			# be rebasing on top of it
>>   			git rev-list --parents -1 $rev | cut -d' ' -s -f2 > "$dropped"/$rev
>>   			sha1=$(git rev-list -1 $rev)
>> -			sane_grep -v "^[a-z][a-z]* $sha1" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
>> +			sed "/^[a-z][a-z]* $sha1/d" <"$todo" > "${todo}2" ; mv "${todo}2" "$todo"
>>   			rm "$rewritten"/$rev
>>   		fi
>>   	done
>> diff --git a/t/t3409-rebase-preserve-merges.sh b/t/t3409-rebase-preserve-merges.sh
>> index 8c251c5..1f01b29 100755
>> --- a/t/t3409-rebase-preserve-merges.sh
>> +++ b/t/t3409-rebase-preserve-merges.sh
>> @@ -119,4 +119,25 @@ test_expect_success 'rebase -p ignores merge.log config' '
>>   	)
>>   '
>>   
>> +test_expect_success 'rebase -p works with non-ASCII commit message' '
>> +	(
>> +	mkdir non-ascii &&
> #The cd should be done in a subshell:
> (
>> +	cd non-ascii &&
>> +	git init &&
>> +	echo a > a &&
>> +	git add a &&
>> +	git commit -m a &&
>> +	echo b > b &&
> #Style: No space after ">" (and even above and below)

And also on the sane_grep/sed line.

> 
> echo b >b
> 
> 
>> +	git add b &&
>> +	git commit -m b &&
>> +	git branch foo &&
>> +	git reset --hard HEAD^ &&
>> +	git cherry-pick -x foo &&
>> +	echo c > c &&
>> +	git add c &&
>> +	git commit -m "$(printf "I \\342\\231\\245 Unicode")" &&
>> +	git rebase -p foo
>> +	)
>> +
> #end of subshell
> )

The whole test is in a subshell already, although that is easy to miss
(missing indentation).

>> '
>> +
>>   test_done
> 

It may be worth noting whether other occurrences of "sane_grep" are safe
from binary input.

After all, one my question the degree of sanity of our sane_grep, or
whether we need asane_grep and bisane_grep in our shell library - "make
our grep sane again".

Michael

  reply	other threads:[~2016-03-08 13:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08  7:59 [PATCH] rebase -p: avoid grep on potentailly non-ASCII data Anders Kaseorg
2016-03-08 12:25 ` Torsten Bögershausen
2016-03-08 13:45   ` Michael J Gruber [this message]
2016-03-08 14:35     ` Jeff King
2016-03-08 23:20       ` Junio C Hamano
2016-03-08 23:36         ` Junio C Hamano
2016-03-09  0:11           ` Jeff King
2016-03-09  0:10         ` Jeff King
2016-03-09  2:31         ` Anders Kaseorg
2016-03-09 20:26           ` Junio C Hamano
2016-03-10  7:42             ` Torsten Bögershausen
2016-03-10 17:22               ` 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=56DED770.4050603@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=andersk@mit.edu \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=tboegi@web.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.