Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1212524imu; Fri, 9 Nov 2018 12:44:27 -0800 (PST) X-Google-Smtp-Source: AJdET5d0zzmSSihe5BEYKLowvTnF1xmKbPwXuDZ5cVGbkRt/tghls+wpIfpJt0/2Jm0BgPjCMr39 X-Received: by 2002:a65:65c9:: with SMTP id y9mr9046362pgv.438.1541796267776; Fri, 09 Nov 2018 12:44:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541796267; cv=none; d=google.com; s=arc-20160816; b=GYjoGnlJhRIjx3+PnJaNEB/rpgk6sJdXTKRiBVwNfQ3T7naxb13CFNzF3Ajg5dPrlb MkAudacurWOfM5qsKL8NG4vQg9XbDC0qWMCUC4cdL+8irPPMC71WRQ1M3aw9m83r2DeX wRJllNyJmEONxrWDnLSSAVUDO+kPhFzeEuZMA1juOw3JxeJhzhXwBmOV4EM+QTaAQ+t+ 9L2TVtzO42E09dRefFSbfcjRSZQnflpWCa9aAJMjrelQXH3xVI5QgMrMb+N/SuIhw9WD S9dJDzpI3GXUCEqcVJwz/khwpzzOpFB9ymT1Ip8y61fV3Het0HpNUnk2+HlFxM+Fmvnz QOUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=e3SfWPtbWnrvTxx7ryc2hKc5WGKd/vHTE+uvsgMrSwU=; b=BkY7I2BeuMhtOeHx5xRS8hn2b41Ltgop87ogQDvHj8pktz9CjIJQ3vNYge233pCw2L XTo5WSmXLl5NWOHd1xrEx4hdUxVTvP/LoPHW3kHqnvSycMhzLtEtddMaeprLzWFvx8OA EZbSM1dY0XjT3gK8DgEKprsdla/l9G1GhJUpaNnUSBog/KM8kfFrH2HD1k1M77ThCkjZ Pu0gW7cwJUynw/CqZN1atJwfMQ2oOpu2R47yr++LQ310R41tYuCXo8m4O9lCmeSnU4qm emxRM6PC6P7jeLvTXpBHo9+J8veihLnyA/iRVHCEO/07YphPTggjTbAuW8y4S1wADWaP mVbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=IxrmCphr; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p22si7459667pgl.340.2018.11.09.12.44.12; Fri, 09 Nov 2018 12:44:27 -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=fail header.i=@gmail.com header.s=20161025 header.b=IxrmCphr; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbeKJGZu (ORCPT + 99 others); Sat, 10 Nov 2018 01:25:50 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38606 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbeKJGZu (ORCPT ); Sat, 10 Nov 2018 01:25:50 -0500 Received: by mail-pf1-f194.google.com with SMTP id b11-v6so1443342pfi.5 for ; Fri, 09 Nov 2018 12:43:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=e3SfWPtbWnrvTxx7ryc2hKc5WGKd/vHTE+uvsgMrSwU=; b=IxrmCphr2F0ucAcA3Nu750M2xfgN8DS2weNqjGcIbJ5w3VZ+VTQcDaGFBbtuKfjrTE zuVmvlRQ1TMa5Ra/BMV7iNMXny64QgPqrcir/6deAgqOdDuQon6nhfd6WW86f/vFW+Bu LujA/mn+3QP11E+U4n66JgFuMqMZbyeO3OJGYvP3K1dw/8dlrLeL+oFlrtyXM1bJERsv SiFEXLbxbXtiTuUQuvH6xYRDKdNHi0z0ZIPn30ECoAWKmMe4im2p5ay/J0MzNK96e66e DYN2OJQav3MuM3SZ6qdVQ5AyAZaqXMs8RDaYPUHOHuPdFn7EXfSdVMRS9i5akKWqyf3s h6Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=e3SfWPtbWnrvTxx7ryc2hKc5WGKd/vHTE+uvsgMrSwU=; b=F2Q0TXEwxPmJkecaqkaZfpfOSZ/PQYV3gmJdPdZofJUqwOyOQu/LkcQrAPGP1teoFQ yTZinM8VvL4pQsf4AfDIAqbKDqXUUDkVeSAjLMxLE+rZlGUSk7B3dKM7jHYZE9vpeTLn LsY+fuzkNFTGGEttgYIqlkPmMxWWivXTkAm99+pxXCMkNlxTXPwOpsZHTVVwwl9iXKuy 1uMHYNQfQgoBhN3RrQkWAOyXDoKAKxhBbNA/d6/jnJbl+Auv1b2Fk1XN45rCTADXQpMn 4ZOR2UpPsNpgHbCWVBqdH3cwS4iNhgZUFhAcHmO4IwzcX0sKlo22VHInAjRGs/1nH2SK g/dg== X-Gm-Message-State: AGRZ1gIR52tvJryvwI2jMbUtx4zCGXBO8xHACg8tysr4BIXGEkHRmIM1 Gf586Zrbh0xU85llN/8coSs= X-Received: by 2002:a63:e101:: with SMTP id z1mr8853748pgh.310.1541796215244; Fri, 09 Nov 2018 12:43:35 -0800 (PST) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id h62-v6sm9790920pfg.27.2018.11.09.12.43.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 12:43:34 -0800 (PST) Date: Fri, 9 Nov 2018 12:43:33 -0800 From: Guenter Roeck To: Brian Norris Cc: Masahiro Yamada , Douglas Anderson , Genki Sky , Christian Kujau , Linux Kernel Mailing List Subject: Re: [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks Message-ID: <20181109204333.GA8498@roeck-us.net> References: <20181107184435.GA168339@google.com> <20181107.204358.257636196@genki.is> <20181107205514.GB12273@roeck-us.net> <20181107.210731.330601031@genki.is> <20181109183436.GA45531@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181109183436.GA45531@google.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 09, 2018 at 10:34:37AM -0800, Brian Norris wrote: > git-diff-index does not refresh the index for you, so using it for a > "-dirty" check can give misleading results. Commit 6147b1cf19651 > ("scripts/setlocalversion: git: Make -dirty check more robust") tried to > fix this by switching to git-status, but it overlooked the fact that > git-status also writes to the .git directory of the source tree, which > is definitely not kosher for an out-of-tree (O=) build. That is getting > reverted. > > Fortunately, git-status now supports avoiding writing to the index via > the --no-optional-locks flag, as of git 2.14. It still calculates an > up-to-date index, but it avoids writing it out to the .git directory. > > So, let's retry the solution from commit 6147b1cf19651 using this new > flag first, and if it fails, we assume this is an older version of git > and just use the old git-diff-index method. > > Cc: Genki Sky > Cc: Christian Kujau > Cc: Guenter Roeck > Signed-off-by: Brian Norris Working for me with git v2.7.4. Tested-by: Guenter Roeck > --- > On Fri, Nov 09, 2018 at 11:55:26AM +0900, Masahiro Yamada wrote: > > > On Wed, Nov 7, 2018 at 1:18 PM Doug Anderson wrote: > > > > On Wed, Nov 7, 2018 at 1:07 PM Genki Sky wrote: > > > > > On Wed, 7 Nov 2018 12:55:14 -0800, Guenter Roeck wrote: > > > > > > Ubuntu 16.04 ships with git version 2.7.4. > > > > > > > > > > Okay. I guess --no-optional-locks is a no-go then. > > > > > > > > In theory you could wrap it. If passing git with > > > > "--no-optional-locks" doesn't work you could fall back to the old > > > > code? That would mean only people with newer git would get your new > > > > feature and everyone else would stick with the pre-existing behavior. > > > > > > +1, that's what I was going to suggest. Presumably older git would > > > give non-zero exit status for unknown flags, and we take that as > > > signal to try to the old way? > > > > I also like this idea! > > > > I will pick-up this revert patch soon. > > > > > > Brian, > > Could you please send a patch on top of that? > > Done. > > It's not supremely beautiful, but I believe it works. I tested with new > git, and with a faked git wrapper that rejects --no-optional-locks, > dumps an error to stderr, and returns a non-zero exit code. I don't > happen to have an older copy of git lying around at the moment... > > scripts/setlocalversion | 15 +++++++++++++-- > 1 file changed, 13 insertions(+), 2 deletions(-) > > diff --git a/scripts/setlocalversion b/scripts/setlocalversion > index 71f39410691b..eab1f90de50d 100755 > --- a/scripts/setlocalversion > +++ b/scripts/setlocalversion > @@ -73,8 +73,19 @@ scm_version() > printf -- '-svn%s' "`git svn find-rev $head`" > fi > > - # Check for uncommitted changes > - if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then > + # Check for uncommitted changes. > + # First, with git-status, but --no-optional-locks is only > + # supported in git >= 2.14, so fall back to git-diff-index if > + # it fails. Note that git-diff-index does not refresh the > + # index, so it may give misleading results. See > + # git-update-index(1), git-diff-index(1), and git-status(1). > + local git_status > + 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 > + printf '%s' -dirty > + fi > + elif git diff-index --name-only HEAD | grep -qv "^scripts/package"; then > printf '%s' -dirty > fi > > -- > 2.19.1.930.g4563a0d9d0-goog