git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Emily Shaffer <emilyshaffer@google.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: Git List <git@vger.kernel.org>, Jonathan Nieder <jrnieder@gmail.com>
Subject: Re: [PATCH] revision: remove stray whitespace when name empty
Date: Wed, 12 Jun 2019 12:23:02 -0700	[thread overview]
Message-ID: <20190612192302.GA233791@google.com> (raw)
In-Reply-To: <CAPig+cS7ocDU3fGRPnQZqN+rT1Ujd2b=v5b1p5V6G++XmNPmsQ@mail.gmail.com>

On Fri, Jun 07, 2019 at 08:42:45PM -0400, Eric Sunshine wrote:
> On Fri, Jun 7, 2019 at 6:59 PM Emily Shaffer <emilyshaffer@google.com> wrote:
> > Teach show_object_with_name() to avoid writing a space before a name
> > which is empty. Also teach tests for rev-list --objects --filter to not
> > require a space between the object ID and name.
> > [...]
> > Signed-off-by: Emily Shaffer <emilyshaffer@google.com>
> > ---
> > Not sure if making the whitespace optional is the right solution for the
> > test, although I couldn't come up with a cleaner approach. Maybe
> > something like this would be better, even though handling it in the
> > regex is shorter?
> >
> >   if [[ -z "$name" ]] then
> 
> In Git, we avoid Bash-isms. Just use 'test'. And, style is to place
> 'then' on its own line.
> 
>     if test -z "$name"
>     then
> 
> > diff --git a/revision.c b/revision.c
> > @@ -40,7 +40,8 @@ void show_object_with_name(FILE *out, struct object *obj, const char *name)
> >  {
> > -       fprintf(out, "%s ", oid_to_hex(&obj->oid));
> > +       fprintf(out, "%s%s", oid_to_hex(&obj->oid),
> > +               strcmp(name, "") == 0 ? "" : " ");
> >         for (p = name; *p && *p != '\n'; p++)
> >                 fputc(*p, out);
> >         fputc('\n', out);
> 
> It's subjective, but this starts to be a bit too noisy and unreadable.
> An alternative:
> 
>     fputs(oid_to_hex(...), out);
>     if (*name)
>         putc(' ', out);
> 
> > diff --git a/t/t6112-rev-list-filters-objects.sh b/t/t6112-rev-list-filters-objects.sh
> > @@ -288,7 +288,7 @@ expect_has () {
> >         hash=$(git -C r3 rev-parse $commit:$name) &&
> > -       grep "^$hash $name$" actual
> > +       grep "^$hash \?$name$" actual
> 
> This would be the first use of \? with 'grep' in the test suite. I
> would worry about portability. Your suggestion earlier to tailor
> 'grep' invocation based upon whether $name is empty would be safer.


Thanks for the review, Eric. I'm going to try again from scratch with
Peff and Junio's suggestion about adding an option to remove object
names, and I'll try to keep your general style concerns in mind when I
do so.

 - Emily

  reply	other threads:[~2019-06-12 19:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-07 22:59 [PATCH] revision: remove stray whitespace when name empty Emily Shaffer
2019-06-08  0:42 ` Eric Sunshine
2019-06-12 19:23   ` Emily Shaffer [this message]
2019-06-09 13:00 ` Jeff King
2019-06-10 16:29   ` Junio C Hamano
2019-06-12 19:37     ` Emily Shaffer
2019-06-13 15:20       ` Jeff King
2019-06-13 21:51 ` [PATCH v2] rev-list: teach --oid-only to enable piping Emily Shaffer
2019-06-14 16:07   ` Jeff King
2019-06-14 20:25     ` Junio C Hamano
2019-06-14 23:18       ` Emily Shaffer
2019-06-14 23:29     ` Emily Shaffer
2019-06-19 21:24       ` Jeff King
2019-06-14 23:48   ` [PATCH v3] rev-list: teach --no-object-names " Emily Shaffer
2019-06-17 22:32     ` Junio C Hamano
2019-06-18 22:08       ` Emily Shaffer
2019-06-18 22:29     ` [PATCH v4] " Emily Shaffer
2019-06-19 14:08       ` Junio C Hamano
2019-06-19 19:31         ` Emily Shaffer
2019-06-19 21:30           ` Jeff King
2019-06-19 20:56       ` [PATCH v5] " Emily Shaffer
2019-06-19 21:38         ` Jeff King

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=20190612192302.GA233791@google.com \
    --to=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@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).