Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5761474imu; Tue, 13 Nov 2018 11:18:03 -0800 (PST) X-Google-Smtp-Source: AJdET5chTe7FuQhOnCLgaxsOrQZGuFF0Vq4hrc18eMbs+8gAQtxCwTFJ8LmAyPOTO1Rtoh/98Jil X-Received: by 2002:a63:d40a:: with SMTP id a10mr5775667pgh.394.1542136683121; Tue, 13 Nov 2018 11:18:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542136683; cv=none; d=google.com; s=arc-20160816; b=VrxkkQZry1aD29DraI+GD5LbxXYx+K8QtpZf+YblhxpTsDioNTLMabuxf9/VKpY2Hi DrQ+skCqCShkODd7KhNx0wR/Iv0HLAof5+541r0GSCgySyKZP6KKsYm3MiEP3CEEZtNJ eJDZf91gILcyDYuyqq670sY7eWabK9FoqCZgH8kpJzWW2YASnT+Q40/vjyWf/EvTTchU XJXbDwpoNh5+EQeaJS8T5gE5xM4JGFsNABIua4ssnIMmHOqIPX5JSItLymkIHXjyRzu5 Cwe274a4zgJ6fAOXIs/JlLZ35DKh3HljOx+WmU61PAz9nIpmEdamaRn9k7vdgHejFtku KDtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Dh+rjCM32ehGaFSxkcnS1rCN5Fcj+0J/RO/nokDH0wc=; b=bnmMo8bmgU/pyKd7/d6p1Lzxs2VJo2cucguiVj8JZg6DLpgt9Y6A6R1YJAM/vzCuPm gaTlT3iqJHTog2Eqs4QvO1SNwAQwMhB1J7jwQjioF/Wi9oiWTvH6ojUzNMs49EsPUmL8 1ELSU9wmJb24V6GZaudvmsrypgSO5dysFPlvz0FqI5sZHUxBXoOixhUbr7xiqCVif9vO u2Gl66s8HHzgTzohy7+vLmOKmXxVLEd39PuksBF/C65Sy7SQsGwTmXKXJsyrjfVZw5bt RDs65uhoiNU9halzfaWIa+F5CAl5T7BCR2JH3fgJiygjJO9G3Vw7LT6856ExQzCGIonV EJkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o8RHWX2e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j29si20080227pgm.554.2018.11.13.11.17.43; Tue, 13 Nov 2018 11:18:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=o8RHWX2e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727599AbeKNFPL (ORCPT + 99 others); Wed, 14 Nov 2018 00:15:11 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:55902 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725748AbeKNFPL (ORCPT ); Wed, 14 Nov 2018 00:15:11 -0500 Received: by mail-it1-f193.google.com with SMTP id o19so10864210itg.5 for ; Tue, 13 Nov 2018 11:15:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Dh+rjCM32ehGaFSxkcnS1rCN5Fcj+0J/RO/nokDH0wc=; b=o8RHWX2eJDuujK6wBnGT094q6678wNqe2YyKwFi994ozGAq4sKD3X6B7gHUtgFTqgz wbEV05VfUXu0UQRs3aFHjgL7DFRSHZZOzZzg1NEAK7c9zQSjyhO11BUeTJ2Kzx2vl+Z/ nZa2dgf0OGk06otj9ZZVAr6sLgBPsII7A2jLtjQg6mHf4JEgwL5vbBzikUJYWwl73Mda pDCABEFWGPylmA4TZpWkvvJhwPbQV3GlkUhNtlMXkcb9dHC7HiQadxJ6n1w8MQufS9Yv F1TOpoluwXHfX9YUKEVQoGMaUY3WkEdIhbulCFPVgoluQBzuKeSR64VvSYFJKgfHym1+ nUMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Dh+rjCM32ehGaFSxkcnS1rCN5Fcj+0J/RO/nokDH0wc=; b=rQG/1wqLMjIaAPodtFW3DdwO6FUfsVeoX094gufPaA90illFQ23xiAkF46tCUeDVkw 7BMN6U7jrr891lm/5Btf2qhAG6cAY8rKoneytxFH83w9B/RDt+HJ92DpFjh8wKM5UwYq EPV/GSKsWj7RDSLAqZhqYJ6+ApeOQZzEW1hJMg1bWmZgqcmE1RpXwGQmtsZhIPaSJSsc EAatZ1I5knD5rjxxk0OUGT017Rn8XH5g7VzeOLTmzEAKNgYVBxa9WG41lLfL8OXzsCW2 n8i/89T6GRZqBGd/6F0jgoLaLiTm6Vxe/AUuuKbtS6Ado+bRW8UsdLyUxMABrlyau3Xs JTrQ== X-Gm-Message-State: AGRZ1gJivmr5YZ+oiXip/bxvKsUKj/aMN/BV47VwbDrnU1I1qmYOXHCy ggvAT2jff1lGMzRNYc3PBrn/DXcP/j8cGBUuDD0= X-Received: by 2002:a02:a0c9:: with SMTP id i9-v6mr6019537jah.116.1542136541251; Tue, 13 Nov 2018 11:15:41 -0800 (PST) MIME-Version: 1.0 References: <20181109183436.GA45531@google.com> <20181110.085826.230851261@genki.is> <20181110.201050.925673938@genki.is> <20181111.174140.002789201@genki.is> <20181113000938.GA16783@google.com> In-Reply-To: From: Alexander Kapshuk Date: Tue, 13 Nov 2018 21:15:26 +0200 Message-ID: Subject: Re: [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks To: Brian Norris Cc: sky@genki.is, schwab@linux-m68k.org, Masahiro Yamada , Douglas Anderson , Guenter Roeck , lists@nerdbynature.de, linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 13, 2018 at 8:32 PM Brian Norris wrote: > > Hi Alexander, > > On Tue, Nov 13, 2018 at 12:36 AM Alexander Kapshuk > wrote: > > > > On Tue, Nov 13, 2018 at 2:09 AM Brian Norris wrote: > > > > > > 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 > > > > Thanks for your input. > > I've found the following grep command, that uses extended regular > > expressions, to work as required: > > Is there any good reason you switched to extended? It looks like my > (basic regex) grep was equivalent. > > > { > > echo hello > > echo scripts/package > > echo '.. scripts/package' > > echo tools/some/other-scripts/package > > } | grep -Ev '^(.. )?scripts/package' > > > > [Output] > > hello > > tools/some/other-scripts/package > > > > If the participants of this email exchange consider the proposed > > implementation as fitting the bill, > > > > { > > git --no-optional-locks status -uno --porcelain 2>/dev/null || > > git diff-index --name-only HEAD > > } | grep -Eqv '^(.. )?scripts/package' && > > printf '%s' -dirty > > > > Was the original committer of the patch proposed here, > > https://lkml.org/lkml/2018/11/10/55, going to take it in, and resend it > > as v2 of the patch, or did you want me to submit the patch instead? > > I would be happy with either way. > > I can submit it. I expect Masahiro-san would prefer a proper v2 patch > for review, given how much would change from my v1. > > And this time, I'll actually test it with a non-dirty tree! (Of > course, my tree is naturally dirty when developing the patch, but I > missed testing post-commit...) > > Brian Hi Brian, Thanks for taking my proposed patch in and submitting it. I went with the ERE because, in my opinion, the pattern looks 'cleaner' without having the metacharacters like '()?' escaped. EREs are POSIX-compatible, so should be supported by any POSIX-compliant shell. Your non-ERE version does generate the same output as my ERE one. So it just boils down to one's personal preference. Thanks.