lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sun, 11 Nov 2018 16:48:38 +0200
From:   Alexander Kapshuk <alexander.kapshuk@...il.com>
To:     sky@...ki.is
Cc:     schwab@...ux-m68k.org, briannorris@...omium.org,
        Masahiro Yamada <yamada.masahiro@...ionext.com>,
        dianders@...omium.org, Guenter Roeck <linux@...ck-us.net>,
        lists@...dbynature.de, linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] scripts/setlocalversion: Improve -dirty check with
 git-status --no-optional-locks

On Sat, Nov 10, 2018 at 10:12 PM Genki Sky <sky@...ki.is> wrote:
>
> Hi Andreas,
>
> On Sat, 10 Nov 2018 11:42:11 +0100, Andreas Schwab <schwab@...ux-m68k.org> wrote:
> > On Nov 10 2018, Genki Sky <sky@...ki.is> wrote:
> > > On Fri, 9 Nov 2018 10:34:37 -0800, Brian Norris <briannorris@...omium.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
%

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ