Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3057916imu; Sun, 11 Nov 2018 06:49:33 -0800 (PST) X-Google-Smtp-Source: AJdET5eIQXI51yTooPXyji2FWDIcTWfR11vQosdKritDZA47s00uVFpozjdqKt7eDUxjNQqaOsuv X-Received: by 2002:a62:cfc1:: with SMTP id b184-v6mr16420375pfg.162.1541947773688; Sun, 11 Nov 2018 06:49:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541947773; cv=none; d=google.com; s=arc-20160816; b=mmeQt29lCrYoeppLXP9HTgy6ZKEFZAEdoL4S3HaIj8kNxxLwktNzeUG+HSn/sSMrmV I9KxTDimP48Xt+j6dqByHsZs5/VINYtgLjFhMx7V3mPAGwVtQfHhk9YtG7c/qZ65k84V 7d2528dLhc6M0g6IbiKwVPvFNc2YDLp+joRKeHU1nvMXcrkoHoOp3fWEnX9tTIWeixgb IkLffRGnWwGrh/HTJsTE5u/+aFIU7V9J3bnzn6mvIhfTjeQqHtrFvKQ7J/3OPYCakMRs u/c8aEPZMjtfotu7pKNSnDDIoF3m7j5znX9oFUoKOG1ch4dJCXTOl+t/ctUIu1/X0Yt4 81kg== 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=Zis/jZynlIeU/NB7VQqGY1++TiKZ788KlLvEtfVWkv0=; b=nH+3SbQJkIBL/rsRm5SeR+74WEiEdvR5eZPpKhbRkc0NMwxoLu3ZajpF18c54Zfcih 81IOrG+lhoNXo7SXvY6G33+JL8+iQn8TrwYq1H2JzzruCFHArkAwhSKc9PL8hxPHektU ntmD02xBlol+xTKho/JSSgo4SBTIiGiFlPZo+XoUio8Zi8Y/6dHGUSMLxxPRTQfv8kMI M8UsxhGiZw9I0fdPB8bn+CVu1sbPo++423IvL+3q4skrxUTk8qckWAqBSsPirtNHbDzC G8kpYAK4+1IyMoTcVPInC8KvqdcpJVz3Yhl0rcxED2lqPQHZF1NDwnBNaayzRYqPlON5 lwpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Xh0a5Wr/"; 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 d19-v6si12843705pgg.227.2018.11.11.06.49.17; Sun, 11 Nov 2018 06:49: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="Xh0a5Wr/"; 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 S1728430AbeKLAhm (ORCPT + 99 others); Sun, 11 Nov 2018 19:37:42 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:50794 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728357AbeKLAhm (ORCPT ); Sun, 11 Nov 2018 19:37:42 -0500 Received: by mail-it1-f196.google.com with SMTP id k206-v6so9241024ite.0 for ; Sun, 11 Nov 2018 06:48:56 -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=Zis/jZynlIeU/NB7VQqGY1++TiKZ788KlLvEtfVWkv0=; b=Xh0a5Wr/T4ftTq7perkhJAmt4Lc4lcj6ylApfJ6FABhJW10UPh/gilGRHmtUQYsg7o Jq57pRPZ785V13rEHDl1JZfh7qLJWG0xaeIRHlw3pk+UnLzXvkO4w977c0YaJyBmOA8r oBezzZGxgAB+X9HwTEcilWzPPKKMgGGXESTwBgpZVOJb6GG8jhKxrYXu0WbtQck5oVTc 0TsSqGU/I5xtiQC2g/NaacwITvI1ljKwJhV/+2qkt5Kqwswym2w7Q9xaRwQuDHJIMZb5 NxOgboDageQ9cVSFbh1x48WKmhb/gYmZkqZTwtFHQr514bFykeYWln6Il5pcYah51jR6 0zhw== 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=Zis/jZynlIeU/NB7VQqGY1++TiKZ788KlLvEtfVWkv0=; b=pXeBt7jKWbv5PBT9SstVhQQOJ1luhjYErazMq/ufpzbTu5MrgK5vBzYVlTfXBWtJom y2ugHj7IgD9tE6EbyoTKcTDti40eN7mysIBfKjRQVu5hclVFHCRHUif6E7XZAl3QyIo8 kui9fzSslCQFd4GWqJu67y6Lxa4b7TW5x8YXHn6hF9Vl+QkUio8S71Rr78ghzmYtpcqX wswFH10rMcOo5bH/thhxoLybin4NZRNgoiNSL/XiNPZ70isUG3siJCHLieFtzehIslsW OfEjxFduISnbCIZZ+1c3nAyMApqfU1CrY1S912tJA9rU6OGzE8I25aUQcF5xT3lCrwET 6aow== X-Gm-Message-State: AGRZ1gKufUZunbz+0O21PvYg3vsQYJtvbUxbv0iR/2vcDo1fSC4qGS17 0EL/Hc18lTNTGCWk6+88QD8YoC1LCRwcIWEua60= X-Received: by 2002:a24:5e93:: with SMTP id h141-v6mr9129972itb.103.1541947735833; Sun, 11 Nov 2018 06:48:55 -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> In-Reply-To: <20181110.201050.925673938@genki.is> From: Alexander Kapshuk Date: Sun, 11 Nov 2018 16:48:38 +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 Sat, Nov 10, 2018 at 10:12 PM Genki Sky wrote: > > Hi Andreas, > > On Sat, 10 Nov 2018 11:42:11 +0100, Andreas Schwab wrote: > > On Nov 10 2018, Genki Sky wrote: > > > On Fri, 9 Nov 2018 10:34:37 -0800, Brian Norris wrote: > > >> + 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 > > > > > > Shouldn't this be: > > > > > > if printf '%s' "$git_status" | grep -qv '^.. scripts/package'; then > > > > > > I.e., use printf not echo? Because of echo introducing a newline. > > > > The input to grep should be a text file, thus should end with a newline. > > Ah okay, thanks. I guess GNU grep was being lenient. Well then, I > think the line at least needs to be changed to: > > if [ -n "$git_status" ] && echo "$git_status" | grep -qv '^.. scripts/package'; then > > I'm just trying to say that in the proposed patch, if git doesn't > print anything, the echo adds a newline that wasn't there before. This > causes the grep -qv to exit with status 0 (because there's at least > one line that doesn't contain '^.. scripts/package'). Meaning it will > print dirty. 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 %