From: Jeff King <peff@peff.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: Taylor Blau <me@ttaylorr.com>, git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] builtin/config.c: don't print a newline with --color
Date: Sun, 3 Mar 2019 12:24:29 -0500 [thread overview]
Message-ID: <20190303172428.GE23811@sigill.intra.peff.net> (raw)
In-Reply-To: <nycvar.QRO.7.76.6.1903022123160.45@tvgsbejvaqbjf.bet>
On Sat, Mar 02, 2019 at 09:25:28PM +0100, Johannes Schindelin wrote:
> > This bug has survived because there was never a test that would have
> > caught it. The old test used 'test_decode_color', which checks that its
> > input begins with a color, but stops parsing once it has parsed a single
> > color successfully. In this case, it was ignoring the trailing '\n'.
>
> Isn't the reason rather that our test compared the output to an expected
> text *with a newline*? IOW:
> [...]
> This should do the right thing if you write
>
> printf "<RED>" >expect
No, there are actually two problems that cancel each other out. Because
test_decode_color() is implemented in awk, it doesn't see if there's
actually a newline or not in each record. So it _always_ adds a newline
after printing out the line (and I don't think Taylor's explanation
above is quite right; it does have a loop to handle multiple colors).
So regardless of whether git-config is sending the newline or not, the
"actual" file will always have a newline in it.
And then to match that, we used "echo" which of course has a newline,
and matches the test_decode_color output.
So you're right that we need to switch to printf. But doing so without
dropping test_decode_color() would mean the test would always fail. We
have to printf the raw bytes, which is what the new test does.
-Peff
next prev parent reply other threads:[~2019-03-03 17:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-02 0:40 [PATCH] builtin/config.c: don't print a newline with --color Taylor Blau
2019-03-02 12:34 ` Eric Sunshine
2019-03-02 20:25 ` Johannes Schindelin
2019-03-03 17:24 ` Jeff King [this message]
2019-03-05 15:59 ` Johannes Schindelin
2019-03-06 23:44 ` Taylor Blau
2019-03-03 1:18 ` Junio C Hamano
2019-03-03 17:42 ` Jeff King
2019-03-04 4:28 ` Junio C Hamano
2019-03-04 5:05 ` Junio C Hamano
2019-03-05 4:20 ` Jeff King
2019-03-05 5:57 ` Junio C Hamano
2019-03-06 23:42 ` Taylor Blau
2019-03-07 0:50 ` Junio C Hamano
2019-03-07 2:57 ` Jeff King
2019-03-06 23:52 ` [PATCH v2] Documentation/config: note trailing newline with --type=color Taylor Blau
2019-03-07 2:58 ` Jeff King
2019-03-07 3:47 ` 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=20190303172428.GE23811@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.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).