Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5714387imu; Tue, 13 Nov 2018 10:33:42 -0800 (PST) X-Google-Smtp-Source: AJdET5dbqG7CG0iWwSqWDJ6nO18H7P3S5f/ewShF2yGKXVLYN9+v4IYO7q1U64apu9f7J/BWnbtG X-Received: by 2002:a62:399b:: with SMTP id u27mr3052190pfj.181.1542134022807; Tue, 13 Nov 2018 10:33:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542134022; cv=none; d=google.com; s=arc-20160816; b=ftNFLblUHkzD5c2eLmFzmZm2woZrlVbrXzSX+BhwsDH4+rx4xq+w4eGfJlcSNBrVmK 1T0eu43T7pA/LbVWGqQBghZL0eFNthfAcyNl+95yTE0mtmXNbjxskTcV436qBiXXmUFR QTJIyG6bZhKxPAWU7H6CPPxLpUj0mQiO8GfidukaBvxfdljqkpCxLjOFiEqmYkJXrw/t r8QGIGuqZF9w3WDuymuYnaVN1JIQVDtAGEqmp8eLNC2mwMWPOI4xG2HoNWks+J0ogHw8 m0ad7glnZS+EjO5UcPeVaM5IPIWdwQ+aUG3tpr5DljUeaJLql44eWb7U5LUtVcz92lWh PkyA== 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=Zlca0T0EYrXqtOfnHKohlWU7P1OTjKQ7GWHaTJ7BHB4=; b=Mp82RrEkcJyWXE0xYc+4lfkRREXU7lLUXWp03lzql5H7cdzLi0sOoIo/kR5i7eSJqq uExOE8KDlqxw90A80LDPiTYjiyo6XU2RQdpeWTwaBJu6snC6VgwIe4sdWxWB6e4FG6QO ia+aFvrqFuf5JBGPtBV3sW2SD04sAko3OKBz0F+sZhNaIp0uP6Hq0VKmXOl6e1AbfeLw fwPF6rbS6qFe4wy+hT8/iKRakxSPmM50y5Qd62viW3iSa8f5z63ccCExLnYt4ysvz1VB JZ4caVvIqgPcDOpZjRJveUDo8o3uXXdjowwMx5yTyVMmdnwCyYs92gX5ctAwI1ZdgyzT DKbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=LNR2N8nR; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z126-v6si23244454pfb.280.2018.11.13.10.33.09; Tue, 13 Nov 2018 10:33:42 -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=@chromium.org header.s=google header.b=LNR2N8nR; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727193AbeKNEbu (ORCPT + 99 others); Tue, 13 Nov 2018 23:31:50 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:35767 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726459AbeKNEbt (ORCPT ); Tue, 13 Nov 2018 23:31:49 -0500 Received: by mail-it1-f196.google.com with SMTP id v11so19991452itj.0 for ; Tue, 13 Nov 2018 10:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zlca0T0EYrXqtOfnHKohlWU7P1OTjKQ7GWHaTJ7BHB4=; b=LNR2N8nR89/IcDp4WtpH6lAtrTcRnqMCisYv8ytAViOIo4WC2EmRm72bKZCTcTD8Yj 5tHLfbBrHBaYM7JNAOFvTYxHmFsYv8NArtpWaO4KWAtmedvtb/oWLhL3/ubjTSvKtu3f oBWfWHD5lv1EXIEbNo3FnUjmkBJ5nZMvvHkpE= 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=Zlca0T0EYrXqtOfnHKohlWU7P1OTjKQ7GWHaTJ7BHB4=; b=K6FgSPLnIilKiyFClJeRKGE8b4EqmOFQOWk4i75FPuABZk2rSdnDugZI6BNU0+HfKV MYAxJ/cjLO1N844uV+Dqplwl1AbUwN2liBxq4VYY/EioQ+/1z4X639QDsz2OdZKUt2M7 nuoGKhmB1KGu6eiTEeQQZcpTY7JGUydzhVJRuS47dIJaBoCM/JqbkCFTs4WOTu5iACNj b2swScTXe8XH0mpW24K2EL6ieG+HYvw6gsDOoMSTr/J9QAybYEa5P/3cJZ7fSm47q4uk p9gNQVYMHxh7vmh7l6fFiJGNbw5cvekEfBqSalONC8CI0r9J6DEAlficl+Qhosq+paeB 8dYA== X-Gm-Message-State: AGRZ1gLdQlRn24JrDUAlBFsLHRWk9rjRnBxqxN3PhKn+06wIPAuTqsNV k8sr9f1yqjVt2JdUDw7g/RfbSV1hnEA= X-Received: by 2002:a24:90c2:: with SMTP id x185-v6mr4805380itd.170.1542133950427; Tue, 13 Nov 2018 10:32:30 -0800 (PST) Received: from mail-it1-f174.google.com (mail-it1-f174.google.com. [209.85.166.174]) by smtp.gmail.com with ESMTPSA id p22-v6sm6448236iog.3.2018.11.13.10.32.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Nov 2018 10:32:28 -0800 (PST) Received: by mail-it1-f174.google.com with SMTP id m15so19961961itl.4 for ; Tue, 13 Nov 2018 10:32:28 -0800 (PST) X-Received: by 2002:a24:9582:: with SMTP id m124-v6mr4295613itd.109.1542133948005; Tue, 13 Nov 2018 10:32:28 -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: Brian Norris Date: Tue, 13 Nov 2018 10:32:16 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks To: alexander.kapshuk@gmail.com Cc: sky@genki.is, schwab@linux-m68k.org, yamada.masahiro@socionext.com, Doug 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 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