linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Kapshuk <alexander.kapshuk@gmail.com>
To: sky@genki.is
Cc: schwab@linux-m68k.org, briannorris@chromium.org,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	dianders@chromium.org, Guenter Roeck <linux@roeck-us.net>,
	lists@nerdbynature.de,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks
Date: Sun, 11 Nov 2018 16:48:38 +0200	[thread overview]
Message-ID: <CAJ1xhMXDFAdiWMV6ODcJM8bfjs-ddyv8utf6N+Yh7+-Ne-KaHw@mail.gmail.com> (raw)
In-Reply-To: <20181110.201050.925673938@genki.is>

On Sat, Nov 10, 2018 at 10:12 PM Genki Sky <sky@genki.is> wrote:
>
> Hi Andreas,
>
> On Sat, 10 Nov 2018 11:42:11 +0100, Andreas Schwab <schwab@linux-m68k.org> wrote:
> > On Nov 10 2018, Genki Sky <sky@genki.is> wrote:
> > > On Fri, 9 Nov 2018 10:34:37 -0800, Brian Norris <briannorris@chromium.org> wrote:
> > >> +          git_status="$(git --no-optional-locks status -uno --porcelain 2>/dev/null)"
> > >> +          if [ $? -eq 0 ]; then
> > >> +                  if echo "$git_status" | grep -qv '^.. scripts/package'; then
> > >
> > > Shouldn't this be:
> > >
> > >     if printf '%s' "$git_status" | grep -qv '^.. scripts/package'; then
> > >
> > > I.e., use printf not echo? Because of echo introducing a newline.
> >
> > The input to grep should be a text file, thus should end with a newline.
>
> Ah okay, thanks. I guess GNU grep was being lenient. Well then, I
> think the line at least needs to be changed to:
>
>         if [ -n "$git_status" ] && echo "$git_status" | grep -qv '^.. scripts/package'; then
>
> I'm just trying to say that in the proposed patch, if git doesn't
> print anything, the echo adds a newline that wasn't there before. This
> causes the grep -qv to exit with status 0 (because there's at least
> one line that doesn't contain '^.. scripts/package'). Meaning it will
> print dirty.

Piping the output of the git command to grep and using the return status
of grep as the test condition within the if block, would be sufficient
to determine whether or not '-dirty' should be printed.

Sample run:
% if git --no-optional-locks \
        status -uno --porcelain \
        2>/dev/null |
        grep -qv '^.. scripts/package'
then
        printf '%s' -dirty
fi
%

  reply	other threads:[~2018-11-11 14:48 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 18:10 [PATCH] Revert "scripts/setlocalversion: git: Make -dirty check more robust" Guenter Roeck
2018-11-06 19:23 ` Genki Sky
2018-11-07  2:22   ` Brian Norris
2018-11-07  2:58     ` Christian Kujau
2018-11-07  3:10       ` Guenter Roeck
2018-11-07  4:00       ` Brian Norris
2018-11-07 18:44         ` Brian Norris
2018-11-07 20:43           ` Genki Sky
2018-11-07 20:55             ` Guenter Roeck
2018-11-07 21:07               ` Genki Sky
2018-11-07 21:18                 ` Doug Anderson
2018-11-07 21:26                   ` Genki Sky
2018-11-08  3:16                   ` Brian Norris
2018-11-09  2:55                     ` Masahiro Yamada
2018-11-09 18:34                       ` [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks Brian Norris
2018-11-09 20:43                         ` Guenter Roeck
2018-11-10  8:58                         ` Genki Sky
2018-11-10 10:42                           ` Andreas Schwab
2018-11-10 20:10                             ` Genki Sky
2018-11-11 14:48                               ` Alexander Kapshuk [this message]
2018-11-11 15:03                                 ` Alexander Kapshuk
2018-11-11 17:41                                 ` Genki Sky
2018-11-11 19:59                                   ` Alexander Kapshuk
2018-11-12  8:42                                     ` Alexander Kapshuk
2018-11-13  0:09                                       ` Brian Norris
2018-11-13  8:35                                         ` Alexander Kapshuk
2018-11-13 18:32                                           ` Brian Norris
2018-11-13 19:03                                             ` [PATCH v2] " Brian Norris
2018-11-13 19:47                                               ` Genki Sky
2018-11-13 22:03                                               ` Andreas Schwab
2018-11-15  2:06                                                 ` Brian Norris
2018-11-15  2:11                                                   ` [PATCH v3] " Brian Norris
2018-11-16 15:17                                                     ` Masahiro Yamada
2018-11-19 14:42                                                     ` Masahiro Yamada
2018-11-13 19:15                                             ` [PATCH] " Alexander Kapshuk
2018-11-09  2:55               ` [PATCH] Revert "scripts/setlocalversion: git: Make -dirty check more robust" Masahiro Yamada
2018-11-09 16:39       ` Masahiro Yamada
2018-11-09 16:39 ` Masahiro Yamada

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=CAJ1xhMXDFAdiWMV6ODcJM8bfjs-ddyv8utf6N+Yh7+-Ne-KaHw@mail.gmail.com \
    --to=alexander.kapshuk@gmail.com \
    --cc=briannorris@chromium.org \
    --cc=dianders@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=lists@nerdbynature.de \
    --cc=schwab@linux-m68k.org \
    --cc=sky@genki.is \
    --cc=yamada.masahiro@socionext.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).