[PATCH 2/2] t4200: convert sed expression which operates on non-text file to perl

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

 



POSIX only requires sed to work on text files and MERGE_RR is not a text
file.  Some versions of sed complain that this file is not newline
terminated, and exit non-zero.  Use perl instead which does not have a
problem with it.

Signed-off-by: Brandon Casey <casey@xxxxxxxxxxxxxxx>
---


Initially, I changed this to use the tr workaround Junio suggested, so it
looked like this:

   sha1=$(tr '\000' '\012' <.git/MERGE_RR | sed -e 's/	.*//')

Then I noticed Jeff King's commit e85fe4d8 which changed uses of tr to perl
for portability's sake.  So the line became:

   sha1=$(perl -pe 'y/\000/\012/' .git/MERGE_RR | sed -e 's/	.*//')

Then I thought, "Why call sed?  I already started up perl, let _it_ do the
substitution.", so it became:

   sha1=$(perl -pe 'y/\000/\012/; s/	.*//' .git/MERGE_RR)

And then I thought, "Why do I need the transliteration?".  So we end up
with this simple patch.

-brandon


 t/t4200-rerere.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/t4200-rerere.sh b/t/t4200-rerere.sh
index 504802c..5a1721d 100755
--- a/t/t4200-rerere.sh
+++ b/t/t4200-rerere.sh
@@ -57,7 +57,7 @@ test_expect_success 'conflicting merge' '
 	test_must_fail git merge first
 '
 
-sha1=$(sed -e 's/	.*//' .git/MERGE_RR)
+sha1=$(perl -pe 's/	.*//' .git/MERGE_RR)
 rr=.git/rr-cache/$sha1
 test_expect_success 'recorded preimage' "grep ^=======$ $rr/preimage"
 
-- 
1.6.2.4.24.gde59d2

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]