lkml.org 
[lkml]   [2018]   [Nov]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks
On Mon, Nov 12, 2018 at 10:42:26AM +0200, Alexander Kapshuk wrote:
> An even simpler approach would be:
>
> {
> git --no-optional-locks status -uno --porcelain 2>/dev/null ||
> git diff-index --name-only HEAD
> } | grep -qv scripts/package &&
> printf '%s' -dirty
>
> Sample run:
> cmd
> sh: cmd: command not found
>
> {
> cmd 2>/dev/null ||
> date
> } | grep -q 2018 &&
> printf '%s' ok
> ok

You lose accuracy here, because now you're skipping any line that
contains 'scripts/package', which would include, e.g., paths like

tools/some/other-scripts/package

Maybe if the grep expression were more like this?

grep -qv '^\(.. \)\?scripts/package'

I think it'd be safe enough to ignore paths that start with two
characters and a space, like:

xy scripts/package
x/ scripts/package

Brian

\
 
 \ /
  Last update: 2018-11-13 01:10    [W:0.107 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site