Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3823196imu; Mon, 12 Nov 2018 00:44:56 -0800 (PST) X-Google-Smtp-Source: AJdET5fmVb0sPPt6HEGVzTWReQaxFiP8rrLqkLX9+WnC5J3z7YqlRdKtaEfiqmpzMGMEEVa8v051 X-Received: by 2002:a63:193:: with SMTP id 141mr75696pgb.136.1542012296776; Mon, 12 Nov 2018 00:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542012296; cv=none; d=google.com; s=arc-20160816; b=c2XxLe3OIm+Vzcj6nGLN332oqygZl6feCiasdTcb94x/+5loBs00xUEft7dkFmhBC3 GN1qiwTr9s9QsbYMrYfy/jNH46lkoU1tQBa0pRoQ06QAfbjF6KmErR6CMBM7wkxYpCkf nGs+7XglCw/SubWMFsBJL0bbhTV6XSqrBVvkeguhgGza7spKGa54wOi3oNlHrAZdVfvd Gn5vZRPj+utKAfR4NZR+eS0f9By4Kt8GOqTaLTk3gBvm2tzo/x21zWBTcv1QroaD/NfX eRtEZmyKkVhYTOzsd53vRg6sLNBX4lJ52an6h55A6sD49D0hbRYi84NZ9k1h/gUyb7p7 KDKA== 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=rwnwzLkwqjgmuGG+Six6aXEDrO9SOqG70d+3LUeliaE=; b=x8VTjnf4W2HKkkp/SaB2RJ9cKNkfNkjbrCz1Y07HpLgBbtGHuoOcUjAIO3UsDNkoKk iL5g5WmWyB+lFHlkthnQOqib34bKoBApCxE7+EPmfnze5gGPIbqKUwD1Vl5NEAF2ViiE Z4B96xiLM7DvC7WgYuZy9GVzF4j0S4TvQvd3PssOufEoSuaSysL5sTZGRv8tGHZBydNV VrsdrzK5hVtLX4uwv6zHQdt+vMWgTBCa+ViB0yCdmRns9k01hGJYOy2a1wRWljghgPoX KzDBvvXWmOWTmvrhHEW+xKqzQKydLXlWJyDAB9tLHeMdB7i4AS1cRyTXF7JRJthnRD/m /5Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="umrM7U/Z"; 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 u10si2142096plr.439.2018.11.12.00.44.41; Mon, 12 Nov 2018 00:44:56 -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="umrM7U/Z"; 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 S1728538AbeKLSfO (ORCPT + 99 others); Mon, 12 Nov 2018 13:35:14 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:39164 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726207AbeKLSfN (ORCPT ); Mon, 12 Nov 2018 13:35:13 -0500 Received: by mail-it1-f195.google.com with SMTP id m15so12052608itl.4 for ; Mon, 12 Nov 2018 00:43:03 -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=rwnwzLkwqjgmuGG+Six6aXEDrO9SOqG70d+3LUeliaE=; b=umrM7U/Ze+vcZweW7orWobMlCxR9n5t/y70BU9yyNeV8OzmWOVHDJ9WVZU79c8fZr5 Z0REOv/pEUhIwlo3qGygPBdI0uyAwMoNVArNBfWzipebp6vRKpAZdRDX3qP7OSh2CgHx S/v5xl2vpZ2xEhIjjvje9ffRpSJ8MBYqiB1IscW4mokSmgJ09tgXgHtfJQjWw7Xm55o2 TlTpQK1LSvnjlOJlYQhRMxBYvmW8zpoAoz3/DeB9B/p32yt62auTAVde07GKsR3dBXz0 3w/wY22TDri4nDaerDFo45ponnfaCBpFjkHPXxapQfBuT4EAZKerKr5dnltbR8rlNyZi QxIg== 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=rwnwzLkwqjgmuGG+Six6aXEDrO9SOqG70d+3LUeliaE=; b=r0X1PHHFEHQIGoQk0qrPVrSF6imrdM0bNvzsLC+7Z1ZLAfzwAB2xmOxUuS6Ie0yKMi BaJHsOs6iFwo4MAHlk61iQhmuBRH1E/pWWQkZtIzMK1cY7CL2WaCjig35Fzaz/h8KtfF gQMBoRWYqBAPxVc+SkZ6aNa9Z4d7NsSonWjIONtFtvC5r9Aqk2T9uqDqvsh0wokLla7L AZzpO1ZfBiC5YAN4idbGqn0hf/8KxRO/NAY01z2DYcPkSCX4xtZToq3s71LSHXoHnhHr J0Q8r/I7fIOIhvLmKrBsVH7UfEot1gkb/WUxm62zUJcuhsex1fJl1FqVeJJftsaGehg/ uKgA== X-Gm-Message-State: AGRZ1gLPEzK6dYBmsRqcdjwb13y3V+kNPoUotABloNahv1EdkLH4CNnK 9gMYoZeVUw/zoheRaZh0dGyCOCo/VOMg+H4SlJ4= X-Received: by 2002:a24:70ca:: with SMTP id f193-v6mr10611085itc.59.1542012182922; Mon, 12 Nov 2018 00:43:02 -0800 (PST) MIME-Version: 1.0 References: <20181107022156.GA254567@google.com> <20181107184435.GA168339@google.com> <20181107.204358.257636196@genki.is> <20181107205514.GB12273@roeck-us.net> <20181107.210731.330601031@genki.is> <20181109183436.GA45531@google.com> <20181110.085826.230851261@genki.is> <20181110.201050.925673938@genki.is> <20181111.174140.002789201@genki.is> In-Reply-To: From: Alexander Kapshuk Date: Mon, 12 Nov 2018 10:42:26 +0200 Message-ID: Subject: Re: [PATCH] scripts/setlocalversion: Improve -dirty check with git-status --no-optional-locks To: sky@genki.is Cc: schwab@linux-m68k.org, Brian Norris , 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 Sun, Nov 11, 2018 at 9:59 PM Alexander Kapshuk wrote: > > On Sun, Nov 11, 2018 at 7:41 PM Genki Sky wrote: > > > > Hi Alexander, > > > > On Sun, 11 Nov 2018 16:48:38 +0200, Alexander Kapshuk wrote: > > > 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 > > > > I don't think this works well for us. We need to check whether > > --no-optional-locks is available before using the output to determine > > whether the tree is dirty or not. If it's not available, we have to > > fall back on diff-index. Let me know if I'm misreading you. > > It was I who failed to read the proposed patch in its entirety in the > first place. I did not get the full picture as a result. My apologies. > > Would something like this work for you? > > local git_status > git_status=$(git --no-optional-locks status -uno --porcelain 2>/dev/null) > test $? -eq 0 || > git_status=$(git diff-index --name-only HEAD) > if printf '%s' "$git_status" | grep -qv scripts/package; then > printf '%s' -dirty > fi 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