Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3304218imu; Sun, 11 Nov 2018 12:00:33 -0800 (PST) X-Google-Smtp-Source: AJdET5dh2jL6T/9lYvUyx95kfoWdMKSNO+DCfdpUmxZjN4hMyveuLgj+dDnkO+QqLiP3pvpbEAOF X-Received: by 2002:a65:42c2:: with SMTP id l2-v6mr14323190pgp.139.1541966433864; Sun, 11 Nov 2018 12:00:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541966433; cv=none; d=google.com; s=arc-20160816; b=FpGldiLPQV3QyVhiP5BqW1qVk2C2n28B4JS8y21ehJwh9/q9YuVERbrHfM9Idiyzn/ mE+W6T88kDD0c5xFu81zn/010Gbv1Jq61PwL0MJEeM5ILZ7OZrS2y+GUWDMIQYQItpmM EL3e6tlkyTZAPkwZuq+vUwBrtbziBc+Vhu6coKXYX8Z1vFKpA6iMTTDDwJyHupkLYeyS dFbBbqhJdV/84MufnQQU79O3XBz4ENQgQVgE1YQ5UXiEyuZoUWpIcjuk+rmSNzDvUX5Z qXLZO06HbNbJ4G71u3sFeD2lwiHgGY3VlFm4lzufSKY0+SDNDc4jq1hxUbNiuuldQXJH xppA== 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=67T0JvgBXVpGJM0JhAkd9LTJMveyQlsOlw1svrrNXUs=; b=Y9K14PH1elAYxgDU2cYFUpB13eJYmorQUbPa/wI7dcniaYdQmr86htvbzPA4bb5M+i h1/h92Y5TGt2z9RKMEGA5pf9f6i3pnDxlinzBsw2mVRL4WaReQA7qfXz6L+IYk/faZxO zW11aRk+5KYHB8HthKsxiku9gE/ZjGUBFESFQqjwbb6f6vzdBX56s/TYrPXEzh3ii9bc Y2u/nX2/BwAkCbrsrYIY5vcsKN97ZiCfQxvxm4N8LFYp51qilUY1IbbLRI4+gZQJIL7h hHbWO8owkjoBgExtsVXgi4MysZd+zjum9YHXUhvqIEsP/TOgf9nM5Xz3FCs5hmtFs8aF PhrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="XIuKJG/q"; 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 o1-v6si14759536pll.325.2018.11.11.12.00.18; Sun, 11 Nov 2018 12:00:33 -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="XIuKJG/q"; 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 S1730933AbeKLFsv (ORCPT + 99 others); Mon, 12 Nov 2018 00:48:51 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:51913 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729472AbeKLFsv (ORCPT ); Mon, 12 Nov 2018 00:48:51 -0500 Received: by mail-it1-f195.google.com with SMTP id m34-v6so9844099iti.1 for ; Sun, 11 Nov 2018 11:59:23 -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=67T0JvgBXVpGJM0JhAkd9LTJMveyQlsOlw1svrrNXUs=; b=XIuKJG/qIpVxUUZ7zPBF3TpHhN/yOk5pNsRvq/mItdjsJHLbrZ1XK79nZjEiYznTz7 UI+IlmybWS6/Rcfbq6nnbjwMbq8u1SpHoFtacLZNheh5UwoBSM+tq/X4BGe52V5cVPgE pyIB6CSapEdXDYDLVcDUp8O3lTseZBPuBUJ1eMlWi0ypzQVP+35fVaqByMdTF3Tpcq9M SxxRSEJpZuRZsyKPpVKlGOAhOdN4NhxlFHpeoMPM85h2hKLzBYwCR6lOaUMiN1Jlo+Bq +jtOso39TUiDq6p6FHpAG9M4rPMivW1j5wAHVXLZpa+QbxFqpOgWE3F2qy85AjPBlmPh L0AA== 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=67T0JvgBXVpGJM0JhAkd9LTJMveyQlsOlw1svrrNXUs=; b=EsPSDMyHT8bOYUwFVow+Xkmaf8Cn0S1ONFZtlX2ciUJvl4UFaKerCFyGND2UME/d/4 8v6n48YOQODG/vyKyoWkJKQHwy5jJAcTIqf1X3BVzc4npg60PDqbWOBt+YsFaHZOY7e6 BDcI1nFqjMkdWn/UasdBZIguXO1bCPVUf7hRsMaBbmlFrgItZ91i50tuBOQ96MRfuZM3 nO4KZZJP89jOjnB7Famp4KRY2vhkcKVzIxPmQqlM2facQRyeWj4gqnpZM4MwELvbW+gd 4Bq7tbl9HU8G5s2MlH79St0rgO6J4QSFgfH+2uw0Kl3eneEMj9AJ7tLBy83PAwZuLiWd pA7A== X-Gm-Message-State: AGRZ1gLfC3p33A9GQYShZqI88dbETVM/qMjSaqfYJ84qUI8QIBQ8F2Ds MGeBoJH2FWz27610of4sQiwspJ2sPchL9vu742l7QNGo/2g= X-Received: by 2002:a24:5e93:: with SMTP id h141-v6mr9891113itb.103.1541966362900; Sun, 11 Nov 2018 11:59:22 -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: <20181111.174140.002789201@genki.is> From: Alexander Kapshuk Date: Sun, 11 Nov 2018 21:59:06 +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, briannorris@chromium.org, Masahiro Yamada , dianders@chromium.org, 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 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