On Fri, Jan 25, 2019 at 11:51 AM Eric Sunshine <sunshine@xxxxxxxxxxxxxx> wrote: > > On Fri, Jan 25, 2019 at 12:52 PM Elijah Newren <newren@xxxxxxxxx> wrote: > > On Fri, Jan 25, 2019 at 9:41 AM Derrick Stolee <stolee@xxxxxxxxx> wrote: > > > On 1/25/2019 11:54 AM, Elijah Newren wrote: > > > > + printf "0f9645804ebb04cc3eef91f799eb7fb54d70cefb\0::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect && > > > > > > I'm guessing that you use printf here because the > > > 'cat <<-\EOF' approach doesn't work with the special > > > tabs? Kudos for putting in the extra effort here for > > > the special formatting! > > > > Yeah, I didn't know how to easily get NUL bytes in the stream without > > printf, and once I was using printf the EOF HEREDOC no longer had a > > useful purpose. In the first testcase, since there were only > > printable characters in the expected output, a HEREDOC worked well. I > > guess I could have just used printf for both testcases, but having the > > literal output shown where it's possible for a human to read it seemed > > like an advantage worth capitalizing on. > > If the readability of a here-doc is preferred, you should be able to > achieve the desired result with the q_to_tab() and lf_to_nul() > functions. For instance: > > q_to_tab <<-\EOF | lf_to_nul >expect && > ...Q...Q... > EOF I like the idea and I tried it out...but it actually looks harder to read to me: diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh index 5bccc323f6..ddbd27d16a 100755 --- a/t/t4038-diff-combined.sh +++ b/t/t4038-diff-combined.sh @@ -457,8 +457,8 @@ test_expect_success 'setup for --combined-with-paths' ' ' test_expect_success '--combined-all-names and --raw' ' - cat <<-\EOF >expect && - ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR "file\twith\ttabs" "i\tam\ttabbed" "fickle\tnaming" + q_to_tab <<-\EOF >expect && + ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RRQ"file\twith\ttabs"Q"i\tam\ttabbed"Q"fickle\tnaming" EOF git diff-tree -c -M --raw --combined-all-names HEAD >actual.tmp && sed 1d <actual.tmp >actual && @@ -466,7 +466,13 @@ test_expect_success '--combined-all-names and --raw' ' ' test_expect_success '--combined-all-names and --raw -and -z' ' - printf "0f9645804ebb04cc3eef91f799eb7fb54d70cefb\0::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR\0file\twith\ttabs\0i\tam\ttabbed\0fickle\tnaming\0" >expect && + q_to_tab <<-\EOF | lf_to_nul >expect && + 0f9645804ebb04cc3eef91f799eb7fb54d70cefb + ::100644 100644 100644 f00c965d8307308469e537302baa73048488f162 088bd5d92c2a8e0203ca8e7e4c2a5c692f6ae3f7 333b9c62519f285e1854830ade0fe1ef1d40ee1b RR + fileQwithQtabs + iQamQtabbed + fickleQnaming + EOF git diff-tree -c -M --raw --combined-all-names -z HEAD >actual && test_cmp -a expect actual ' So I'm going to stick with the original. Thanks for pointing out q_to_tab and lf_to_nul, though; they may come in handy in the future.