Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3309724pxv; Mon, 12 Jul 2021 14:25:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3mWb1IF7tUNF/fXqZ0wOU7MeKZXQixMxyrVBCEqpOgBvU7uGZLKAE3MB6jf+aKsIgZeqc X-Received: by 2002:a92:190e:: with SMTP id 14mr577386ilz.70.1626125151003; Mon, 12 Jul 2021 14:25:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626125150; cv=none; d=google.com; s=arc-20160816; b=UP7mxvsIir6Xow8YY9011woO4ZF6HyVuhHs3RVw/a+T5FgEooNcXWIv9HnFPBaoXNQ LB33w6fKUKzTQx/TK3dVYN9DOfnt2Pykdf7vFzUFkgh9uLAx5AxDDYxINsfFdMPQ9PPy 1m0bDUoGXdKx/Fo9He5oztxmjBOX2v7PDmjsGjSTvu1v+K8/zrB+3PCc6I1teXC0fhgR ohaj2Uo58oRdUvlWobrGZhbQe1UhrV9si8IRy96biGnYQIFev08tFST0EVhPzsSV7Tae iANMExQr38Y60pqpnhPQcKXCVMc0mNJDJCP8mpUTBRqDpAIrBud/h/U8REls/IirE7qv J7Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:in-reply-to:subject :cc:to:from:user-agent:references; bh=FUxg5ntN4BaI0xP65EcVYIDY0c59hfOOUlv4J99cJpg=; b=QAgFajjdNzBtaePd51VO6wuaueo0drINNophGMv+9o5TP0mxHAFCN3hZaUfPFKWcbM YkXF5eEaez1cVsuRIjDPSya6hkQhzbjruogC6qlP+LWitafZ9Vu5Cn+7d0odE9ZaEFZZ kMLRD34WDl5qmAPNSS1RTVTjJBw75XlopBZWYcM5tJgYeVi6lY6qWpeeDQlFMTaLmaP+ 8JCZNis0vdrJ2v5rcQW9gR8TS8QlXZinmHkkKZWl3J2f9juXNYTG/xHYzt7gYLS+KBMe 02Rclvv7SV2AEHACIkiEjnPw8LiyA8tREDAVo0vDCIwW6Y5ARLmyY/chgeU4QNJyAYXR m1mQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u12si19482399ilm.144.2021.07.12.14.25.20; Mon, 12 Jul 2021 14:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231878AbhGLV10 (ORCPT + 99 others); Mon, 12 Jul 2021 17:27:26 -0400 Received: from mx.ungleich.ch ([185.203.112.16]:44392 "EHLO smtp.ungleich.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbhGLV10 (ORCPT ); Mon, 12 Jul 2021 17:27:26 -0400 X-Greylist: delayed 461 seconds by postgrey-1.27 at vger.kernel.org; Mon, 12 Jul 2021 17:27:26 EDT Received: from nb3.localdomain (localhost [IPv6:::1]) by smtp.ungleich.ch (Postfix) with ESMTP id D72791FE49; Mon, 12 Jul 2021 23:16:47 +0200 (CEST) Received: by nb3.localdomain (Postfix, from userid 1000) id A9A4814CC252; Mon, 12 Jul 2021 23:17:35 +0200 (CEST) References: User-agent: mu4e 1.4.15; emacs 27.2 From: Nico Schottelius To: Mikulas Patocka Cc: Greg Kroah-Hartman , Masahiro Yamada , Nico Schottelius , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] scripts/setlocalversion: fix a bug when LOCALVERSION is empty In-reply-to: Date: Mon, 12 Jul 2021 23:17:35 +0200 Message-ID: <87tukzgrkg.fsf@ungleich.ch> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sorry to say, but I am not convinced by the patch. While yes, we might have changed the behaviour slightly, reading something on the line of if [ -z ... ] is significantly more simple, elegant and easier to maintain, than a rather atypical special case for setting a variable to empty, using if [ "${LOCALVERSION+set}" != "set" ] .. *and* because it is so atypical, adding a long comment for it, too. Additonally, -z should be correct if the variable *is* truly empty. I assume it actually isn't and contains whitespace, which is not the same as being set and empty. Instead of re-adding complexity, could you consider changing the build flow so that LOCALVERSION is either unset or empty? Nico Executed in bash: % touch empty % a=$(cat empty) % [ -z "$a" ] && echo "really empty" really empty Mikulas Patocka writes: > On Mon, 12 Jul 2021, Greg Kroah-Hartman wrote: > >> On Mon, Jul 12, 2021 at 03:06:48PM -0400, Mikulas Patocka wrote: >> > >> > >> > On Mon, 12 Jul 2021, Greg Kroah-Hartman wrote: >> > >> > > On Mon, Jul 12, 2021 at 10:00:59AM -0400, Mikulas Patocka wrote: >> > > > The patch 042da426f8ebde012be9429ff705232af7ad7469 >> > > > ("scripts/setlocalversion: simplify the short version part") reduces the >> > > > indentation. Unfortunatelly, it also changes behavior in a subtle way - if >> > > > the user has empty "LOCALVERSION" variable, the plus sign is appended to >> > > > the kernel version. It wasn't appended before. >> > > > >> > > > This patch reverts to the old behavior - we append the plus sign only if >> > > > the LOCALVERSION variable is not set. >> > > > >> > > > Signed-off-by: Mikulas Patocka >> > > > Fixes: 042da426f8eb ("scripts/setlocalversion: simplify the short version part") >> > > > >> > > > --- >> > > > scripts/setlocalversion | 2 +- >> > > > 1 file changed, 1 insertion(+), 1 deletion(-) >> > > > >> > > > Index: linux-2.6/scripts/setlocalversion >> > > > =================================================================== >> > > > --- linux-2.6.orig/scripts/setlocalversion 2021-07-12 15:29:07.000000000 +0200 >> > > > +++ linux-2.6/scripts/setlocalversion 2021-07-12 15:50:29.000000000 +0200 >> > > > @@ -131,7 +131,7 @@ res="${res}${CONFIG_LOCALVERSION}${LOCAL >> > > > if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then >> > > > # full scm version string >> > > > res="$res$(scm_version)" >> > > > -elif [ -z "${LOCALVERSION}" ]; then >> > > > +elif [ "${LOCALVERSION+set}" != "set" ]; then >> > > >> > > That's really subtle, can you add a comment here that this handles an >> > > empty file? >> > > >> > > thanks, >> > > >> > > greg k-h >> > >> > OK. >> > >> > >> > From: Mikulas Patocka >> > >> >> I can't take a patch like this :( >> >> > The patch 042da426f8ebde012be9429ff705232af7ad7469 >> > ("scripts/setlocalversion: simplify the short version part") reduces >> >> Properly quote commits, the documentation says you do not need to use >> the full sha1. > > > > From: Mikulas Patocka > > The commit 042da426f8eb ("scripts/setlocalversion: simplify the short > version part") reduces indentation. Unfortunately, it also changes behavior > in a subtle way - if the user has empty "LOCALVERSION" variable, the plus > sign is appended to the kernel version. It wasn't appended before. > > This patch reverts to the old behavior - we append the plus sign only if > the LOCALVERSION variable is not set. > > Signed-off-by: Mikulas Patocka > Fixes: 042da426f8eb ("scripts/setlocalversion: simplify the short version part") > > --- > scripts/setlocalversion | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > Index: linux-2.6/scripts/setlocalversion > =================================================================== > --- linux-2.6.orig/scripts/setlocalversion 2021-07-12 15:29:07.000000000 +0200 > +++ linux-2.6/scripts/setlocalversion 2021-07-12 21:00:59.000000000 +0200 > @@ -131,11 +131,14 @@ res="${res}${CONFIG_LOCALVERSION}${LOCAL > if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then > # full scm version string > res="$res$(scm_version)" > -elif [ -z "${LOCALVERSION}" ]; then > - # append a plus sign if the repository is not in a clean > - # annotated or signed tagged state (as git describe only > - # looks at signed or annotated tags - git tag -a/-s) and > - # LOCALVERSION= is not specified > +elif [ "${LOCALVERSION+set}" != "set" ]; then > + # If the variable LOCALVERSION is not set, append a plus > + # sign if the repository is not in a clean annotated or > + # signed tagged state (as git describe only looks at signed > + # or annotated tags - git tag -a/-s). > + # > + # If the variable LOCALVERSION is set (including being set > + # to an empty string), we don't want to append a plus sign. > scm=$(scm_version --short) > res="$res${scm:++}" > fi -- Sustainable and modern Infrastructures by ungleich.ch