From: Elijah Newren <newren@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Derrick Stolee <stolee@gmail.com>,
Git Mailing List <git@vger.kernel.org>, Jeff King <peff@peff.net>,
"brian m . carlson" <sandals@crustytoothpaste.net>
Subject: Re: [PATCH v2] log,diff-tree: add --combined-with-paths options for merges with renames
Date: Sat, 26 Jan 2019 14:07:52 -0800 [thread overview]
Message-ID: <CABPp-BHU9QUQrr9F9ncQSn-yeBhMUZiRO78jzX+C42zrg55tzA@mail.gmail.com> (raw)
In-Reply-To: <CAPig+cRefjWr3gNOfQou9JyW=yfACEvbXPPRzXU+VkJN_gCTzA@mail.gmail.com>
On Fri, Jan 25, 2019 at 11:51 AM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Fri, Jan 25, 2019 at 12:52 PM Elijah Newren <newren@gmail.com> wrote:
> > On Fri, Jan 25, 2019 at 9:41 AM Derrick Stolee <stolee@gmail.com> 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.
next prev parent reply other threads:[~2019-01-26 22:08 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-24 16:46 [PATCH] log,diff-tree: add --combined-with-paths options for merges with renames Elijah Newren
2019-01-25 2:19 ` brian m. carlson
2019-01-25 16:27 ` Elijah Newren
2019-01-25 14:45 ` Derrick Stolee
2019-01-25 16:30 ` Elijah Newren
2019-01-25 16:54 ` [PATCH v2] " Elijah Newren
2019-01-25 17:40 ` Derrick Stolee
2019-01-25 17:52 ` Elijah Newren
2019-01-25 19:51 ` Eric Sunshine
2019-01-26 22:07 ` Elijah Newren [this message]
2019-01-27 1:52 ` brian m. carlson
2019-01-26 22:18 ` [PATCH v3] log,diff-tree: add --combined-all-names option Elijah Newren
2019-02-04 20:07 ` [PATCH v4] " Elijah Newren
2019-02-04 21:20 ` Junio C Hamano
2019-02-05 15:51 ` Elijah Newren
2019-02-05 20:39 ` Junio C Hamano
2019-02-07 19:50 ` Elijah Newren
2019-02-07 20:25 ` Junio C Hamano
2019-02-07 22:10 ` Elijah Newren
2019-02-07 23:31 ` Junio C Hamano
2019-02-07 23:48 ` Elijah Newren
2019-02-05 9:48 ` Johannes Schindelin
2019-02-05 15:54 ` Elijah Newren
2019-02-05 18:04 ` Junio C Hamano
2019-02-07 22:28 ` Junio C Hamano
2019-02-07 23:48 ` Elijah Newren
2019-02-08 1:12 ` [PATCH v5 0/2] add --combined-all-paths option to log and diff-tree Elijah Newren
2019-02-08 1:12 ` [PATCH v5 1/2] log,diff-tree: add --combined-all-paths option Elijah Newren
2019-02-08 4:00 ` Junio C Hamano
2019-02-08 6:52 ` Elijah Newren
2019-02-08 17:50 ` Junio C Hamano
2019-02-08 1:12 ` [PATCH v5 2/2] squash! " Elijah Newren
2019-02-08 4:14 ` Junio C Hamano
2019-02-08 6:48 ` Elijah Newren
2019-01-25 19:29 ` [PATCH] log,diff-tree: add --combined-with-paths options for merges with renames Junio C Hamano
2019-01-25 20:04 ` Elijah Newren
2019-01-25 22:21 ` Junio C Hamano
2019-01-26 22:12 ` Elijah Newren
2019-01-28 0:19 ` 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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABPp-BHU9QUQrr9F9ncQSn-yeBhMUZiRO78jzX+C42zrg55tzA@mail.gmail.com \
--to=newren@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=sandals@crustytoothpaste.net \
--cc=stolee@gmail.com \
--cc=sunshine@sunshineco.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).