From: Tobias Klauser <tklauser@distanz.ch>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Junio C Hamano <gitster@pobox.com>,
Matthieu Moy <Matthieu.Moy@imag.fr>,
Git List <git@vger.kernel.org>
Subject: Re: [PATCH v2 3/4] stripspace: Implement --count-lines option
Date: Mon, 19 Oct 2015 15:31:51 +0200 [thread overview]
Message-ID: <20151019133150.GK2468@distanz.ch> (raw)
In-Reply-To: <CAPig+cQ=8FO8yFY4sHUwr0mYuyvMu4d-eizHZeadE9f0BgpXpQ@mail.gmail.com>
On 2015-10-18 at 01:57:57 +0200, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Fri, Oct 16, 2015 at 11:16 AM, Tobias Klauser <tklauser@distanz.ch> wrote:
> > Implement the --count-lines options for git stripspace [...]
> >
> > This will make it easier to port git-rebase--interactive.sh to C later
> > on.
>
> Is there any application beyond git-rebase--interactive where a
> --count-lines options is expected to be useful? It's not obvious from
> the commit message that this change is necessarily a win for later
> porting of git-rebase--interactive to C since the amount of extra code
> and support material added by this patch probably outweighs the amount
> of code a C version of git-rebase--interactive would need to count the
> lines itself.
Agreed, it doesn't make much sense anymore in the current form. An
strbuf helper function implementing the line counting would probably be
the better way. But I guess this should only be introduced once someone
decides to write a C version of git-rebase--interactive (or any other
use for line counting appears).
> Stated differently, are the two or three instances of piping through
> 'wc' in git-rebase--interactive sufficient justification for
> introducing extra complexity into git-stripspace and its documentation
> and tests?
IMO it doesn't add a lot of complexity, but on the other hand it also
doesn't provide a large benefit apart from getting rid of a few
calls to an external program in a code path which is not performance
critical.
So I suggest I'll drop patches 3/4 and 4/4 for v3. Once someone really
needs the line counting functionality in C, an strbuf helper can still
be added.
> More below.
>
> > Furthermore, add the corresponding documentation and tests.
> >
> > Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
> > ---
> > diff --git a/t/t0030-stripspace.sh b/t/t0030-stripspace.sh
> > index 29e91d8..9c00cb9 100755
> > --- a/t/t0030-stripspace.sh
> > +++ b/t/t0030-stripspace.sh
> > @@ -438,4 +438,40 @@ test_expect_success 'avoid SP-HT sequence in commented line' '
> > test_cmp expect actual
> > '
> >
> > +test_expect_success '--count-lines with newline only' '
> > + printf "0\n" >expect &&
> > + printf "\n" | git stripspace --count-lines >actual &&
> > + test_cmp expect actual
> > +'
>
> What is the expected behavior when the input is an empty file, a file
> with content but no newline, a file with one or more lines but lacking
> a newline on the final line? Should these cases be tested, as well?
Not really sure. For the implementation I followed the behavior of 'wc
-l' which doesn't consider the final line if it lacks a newline. Should
this be different for git's purposes? In any case, I agree that these
cases should excplicitely be tested/documented.
next prev parent reply other threads:[~2015-10-19 13:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-16 15:16 [PATCH v2 0/4] stripspace: Implement and use --count-lines option Tobias Klauser
2015-10-16 15:16 ` [PATCH v2 1/4] strbuf: make stripspace() part of strbuf Tobias Klauser
2015-10-16 15:16 ` [PATCH v2 2/4] stripspace: Use parse-options for command-line parsing Tobias Klauser
2015-10-16 17:07 ` Junio C Hamano
2015-10-16 17:29 ` Junio C Hamano
2015-10-17 10:31 ` Tobias Klauser
2015-10-17 21:24 ` Junio C Hamano
2015-10-20 8:48 ` Tobias Klauser
2015-10-20 15:47 ` Junio C Hamano
2015-10-17 10:30 ` Tobias Klauser
2015-10-16 15:16 ` [PATCH v2 3/4] stripspace: Implement --count-lines option Tobias Klauser
2015-10-17 23:57 ` Eric Sunshine
2015-10-18 17:18 ` Junio C Hamano
2015-10-19 13:46 ` Tobias Klauser
2015-10-19 17:03 ` Christian Couder
2015-10-19 19:24 ` Eric Sunshine
2015-10-19 19:42 ` Matthieu Moy
2015-10-19 13:31 ` Tobias Klauser [this message]
2015-10-16 15:16 ` [PATCH v2 4/4] git rebase -i: Use newly added --count-lines option for stripspace Tobias Klauser
2015-10-16 16:41 ` [PATCH v2 0/4] stripspace: Implement and use --count-lines option Junio C Hamano
2015-10-17 10:27 ` Tobias Klauser
2015-10-16 16:54 ` Matthieu Moy
2015-10-17 10:28 ` Tobias Klauser
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151019133150.GK2468@distanz.ch \
--to=tklauser@distanz.ch \
--cc=Matthieu.Moy@imag.fr \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
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 NNTP newsgroup(s).