git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Lars Schneider <larsxschneider@gmail.com>
To: Johannes Sixt <j6t@kdbg.org>
Cc: git@vger.kernel.org, gitster@pobox.com, jnareb@gmail.com,
	peff@peff.net, ramsay@ramsayjones.plus.com, tboegi@web.de
Subject: Re: [PATCH v11 13/14] convert: add filter.<driver>.process option
Date: Thu, 3 Nov 2016 00:41:02 +0000	[thread overview]
Message-ID: <3763DDDB-9D53-4877-8399-32DF1780CAB7@gmail.com> (raw)
In-Reply-To: <3b09d218-33bd-dc7c-235c-8954a46afc41@kdbg.org>


> On 2 Nov 2016, at 18:03, Johannes Sixt <j6t@kdbg.org> wrote:
> 
>> Am 17.10.2016 um 01:20 schrieb larsxschneider@gmail.com:
>> +# Compare two files and ensure that `clean` and `smudge` respectively are
>> +# called at least once if specified in the `expect` file. The actual
>> +# invocation count is not relevant because their number can vary.
>> +# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/
>> +test_cmp_count () {
>> +    expect=$1
>> +    actual=$2
>> +    for FILE in "$expect" "$actual"
>> +    do
>> +        sort "$FILE" | uniq -c | sed "s/^[ ]*//" |
>> +            sed "s/^\([0-9]\) IN: clean/x IN: clean/" |
>> +            sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" &&
> 
> This is not sufficiently portable. Some versions of uniq write the
> count left-adjusted, not right-adjusted. How about this on top:
> 
> diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
> index a20b9f58e3..f60858c517 100755
> --- a/t/t0021-conversion.sh
> +++ b/t/t0021-conversion.sh
> @@ -40,10 +40,9 @@ test_cmp_count () {
>    actual=$2
>    for FILE in "$expect" "$actual"
>    do
> -        sort "$FILE" | uniq -c | sed "s/^[ ]*//" |
> -            sed "s/^\([0-9]\) IN: clean/x IN: clean/" |
> -            sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" &&
> -        mv "$FILE.tmp" "$FILE"
> +        sort "$FILE" | uniq -c |
> +        sed -e "s/^ *[0-9][0-9]* *IN: /x IN: /" >"$FILE.tmp" &&

This looks good (thanks for cleaning up the redundant clean/smudge stuff - that was a refactoring artifact!). One minor nit: doesn't sed understand '[0-9]+' ?

> +        mv "$FILE.tmp" "$FILE" || return

Why '|| return' here?

>    done &&
>    test_cmp "$expect" "$actual"
> }

Thank you,
Lars

  reply	other threads:[~2016-11-03  0:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-16 23:20 [PATCH v11 00/14] Git filter protocol larsxschneider
2016-10-16 23:20 ` [PATCH v11 01/14] convert: quote filter names in error messages larsxschneider
2016-10-16 23:20 ` [PATCH v11 02/14] convert: modernize tests larsxschneider
2016-10-16 23:20 ` [PATCH v11 03/14] run-command: move check_pipe() from write_or_die to run_command larsxschneider
2016-10-16 23:20 ` [PATCH v11 04/14] run-command: add clean_on_exit_handler larsxschneider
2016-10-16 23:20 ` [PATCH v11 05/14] pkt-line: rename packet_write() to packet_write_fmt() larsxschneider
2016-10-16 23:20 ` [PATCH v11 06/14] pkt-line: extract set_packet_header() larsxschneider
2016-10-16 23:20 ` [PATCH v11 07/14] pkt-line: add packet_write_fmt_gently() larsxschneider
2016-10-16 23:20 ` [PATCH v11 08/14] pkt-line: add packet_flush_gently() larsxschneider
2016-10-16 23:20 ` [PATCH v11 09/14] pkt-line: add packet_write_gently() larsxschneider
2016-10-16 23:20 ` [PATCH v11 10/14] pkt-line: add functions to read/write flush terminated packet streams larsxschneider
2016-10-16 23:20 ` [PATCH v11 11/14] convert: make apply_filter() adhere to standard Git error handling larsxschneider
2016-10-16 23:20 ` [PATCH v11 12/14] convert: prepare filter.<driver>.process option larsxschneider
2016-10-16 23:20 ` [PATCH v11 13/14] convert: add " larsxschneider
2016-11-02 18:03   ` Johannes Sixt
2016-11-03  0:41     ` Lars Schneider [this message]
2016-11-03 20:12       ` [PATCH] t0021: expect more variations in the output of uniq -c Johannes Sixt
2016-11-03 20:22         ` [PATCH (optional)] t0021: use arithmetic expansion to trim whitespace from wc -c output Johannes Sixt
2016-11-06 15:45           ` Lars Schneider
2016-11-06 19:31             ` Johannes Sixt
2016-11-06 19:43               ` Lars Schneider
2016-11-06 15:31         ` [PATCH] t0021: expect more variations in the output of uniq -c Lars Schneider
2016-11-06 21:40           ` Johannes Sixt
2016-10-16 23:20 ` [PATCH v11 14/14] contrib/long-running-filter: add long running filter example larsxschneider
2016-10-17 18:47 ` [PATCH v11 00/14] Git filter protocol 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=3763DDDB-9D53-4877-8399-32DF1780CAB7@gmail.com \
    --to=larsxschneider@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=jnareb@gmail.com \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=tboegi@web.de \
    /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).