[PATCH 2/2] t4200: convert sed expression which operates on non-text file to perl
- From
Brandon Casey <casey@nrlssc.navy.mil>
- Date
- May 6, 2009, 22:56 UTC
- Message-ID
- <Lle9L7vlL2vfnqjU75q2MW9kwH-igiKVkmBrtmLzQmOXU0OyvCI2tl4UD8Kdhyg0x_gCHDJIHDM@cipher.nrlssc.navy.mil>
- In-Reply-To
- <Lle9L7vlL2vfnqjU75q2MR6WXGGP9aOKv8J97cnRHcQgyJeGbOMDDB2xJugZ0LoonfCRYmzXx9E@cipher.nrlssc.navy.mil>
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@nrlssc.navy.mil> ---
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