Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp105680pxk; Fri, 11 Sep 2020 01:30:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLIURMcRhIOxgoZOTMYRX8NsIG0XcSReo0/Dk03xp2N2cHNuc4Yht5g18ZkysL9vTz/yjS X-Received: by 2002:aa7:c256:: with SMTP id y22mr833527edo.16.1599813028644; Fri, 11 Sep 2020 01:30:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599813028; cv=none; d=google.com; s=arc-20160816; b=z1NkwsnMMfV7d+kvMWzHnIua+8oLizZFwQiPKz++35k6165D8EOSXiwH9si0bW+uxt VgkSpOImVnRjQEpie3yOVJKu63TS3hKr1MMkBm1jDOoSYr6e1tf5Yq2238guXnLwuoss +gHosU041vZnHKWFKf/yvUPljTy4m7wFawK2LzhspmsfFGmeix9fefKNyUzpbyP3E53P kFVwNno3auyKhXJs6NbAzREsPC3lZnBZ7dsDPmEvpikUaWptlrONSYgtz0KyxDzwj/W7 e91AH7lGu2ewjvIeK/kawNMBGH3TvdyDmisNmvvuF0ollMhv+GJPxIN35Is7Pc+7Qny5 XkQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=nqgDSp1th5G/M0PdFYX7mO5hM3ICiXr7qIaeDpTGTcU=; b=wVAtwKYeHBTSGO9QH529HNJ3pFyYty+RIJautGbYb8Si4IEObPDEHIIR1aem3uE3qr qMxqBTpYpTnPMgd/qMfOHTXAXiU4EtqybCc4yJwkJYxqQ/rxTwjJp7FtnrC7pSu+NLRp WOjPkm6DF2Idh4Gd4gqGyW3aJ2dBpgkBfTNCC4zjmjptOdOYqboQOitVyXbACyLzGy0S 4fzswM8sa1m+wfz9ZesHCZ9nbciC8nJBBzF/iEFfpw0xjV71xiCO0WlG8upIBx9wAGlP of0+/YOe+i8bGjEEYz60F3J1i+FN8l3oay8eBLhb4dnvW3eeyq09Azs0BACxN28CHkg2 1ooQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=bLp4ORPp; 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 g20si795628edv.420.2020.09.11.01.30.05; Fri, 11 Sep 2020 01:30:28 -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; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=bLp4ORPp; 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 S1725771AbgIKI2c (ORCPT + 99 others); Fri, 11 Sep 2020 04:28:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725764AbgIKI2W (ORCPT ); Fri, 11 Sep 2020 04:28:22 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E445C061573 for ; Fri, 11 Sep 2020 01:28:20 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id q13so12627674ejo.9 for ; Fri, 11 Sep 2020 01:28:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=nqgDSp1th5G/M0PdFYX7mO5hM3ICiXr7qIaeDpTGTcU=; b=bLp4ORPpJWoJtKrU+PnODJE/eis6yKpsPkzVKH0XHf5eamhhp8RlA6XpgfAoeCardL vSLYmlyzYTJgoJ0DeDlSn07sKUvKDJlETmJZC4TQQacwtvHXpF/Fe8uiZIzgFLwOwJVe LPKLtwG73oVlviO1tBSrM62bZtJgw3TvG8ftE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nqgDSp1th5G/M0PdFYX7mO5hM3ICiXr7qIaeDpTGTcU=; b=NF2gS5M6Sxw6O8vREo3ccYI2wB/fXM/sjTH3T+C5Ng+T+TonsJf2Bo4Syd9VeHvRg6 V0SCFoJId+IDutzhCs3CHFnRmA1kKf/znIoA5V/99KI1GGVNUU6dQ6teGdtDbk2PHZyv jDxAcKzgibdEeURHyYMfHCmootBe8OpnnzKOvMAuyoIbOTPk7KHAJhagxiKQb8USHU8B zZx/zpSl+IW0/HcC8tfYNS0EO/yBrbaz9tGtiNMjdGbhfRNmlwA/LDe/ebr12X57q2bs DwW++TnTVpXbXCPFkTP8diexNg0o17qVRAif9EvYXYw6SwWPTjDbmDUe+1ihNYROR+Re vEYA== X-Gm-Message-State: AOAM533kWG3akXtvhILprfo7nA4kj8TvVGNrLtjAmNIqyNwE4lFTQqJU pArcwIZIhsxBUIrLRiWtd3GvijppB9GphpMldrI= X-Received: by 2002:a17:906:692:: with SMTP id u18mr929591ejb.43.1599812898711; Fri, 11 Sep 2020 01:28:18 -0700 (PDT) Received: from [192.168.1.149] (5.186.115.188.cgn.fibianet.dk. [5.186.115.188]) by smtp.gmail.com with ESMTPSA id z10sm1053225eje.122.2020.09.11.01.28.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Sep 2020 01:28:18 -0700 (PDT) Subject: Re: [PATCH] scripts/setlocalversion: make git describe output more reliable To: Brian Norris , Masahiro Yamada Cc: Randy Dunlap , Guenter Roeck , Bhaskar Chowdhury , Linux Kernel Mailing List References: <20200910112701.13853-1-linux@rasmusvillemoes.dk> From: Rasmus Villemoes Message-ID: Date: Fri, 11 Sep 2020 10:28:16 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/09/2020 21.05, Brian Norris wrote: > On Thu, Sep 10, 2020 at 7:35 AM Masahiro Yamada wrote: >> On Thu, Sep 10, 2020 at 8:57 PM Rasmus Villemoes >> wrote: >>> So in order to avoid `uname -a` output relying on such random details >>> of the build environment which are rather hard to ensure are >>> consistent between developers and buildbots, use an explicit >>> --abbrev=15 option (and for consistency, also use rev-parse --short=15 >>> for the unlikely case of no signed tags being usable). > > For the patch: > > Reviewed-by: Brian Norris > >> I agree that any randomness should be avoided. >> >> My question is, do we need 15-digits? > ... >> So, I think the conflict happens >> only when we have two commits that start with the same 7-digits >> in the _same_ release. Is this correct? No. > For git-describe (the case where we have a tag to base off): > "use digits, or as many digits as needed to form a unique object name" Yes, the abbreviated hash that `git describe` produces is unique among all objects (and objects are more than just commits) in the current repo, so what matters for probability-of-collision is the total number of objects - linus.git itself probably grows ~60000 objects per release. As for "do we need 15 digits", well, in theory the next time I merge the next rt-stable tag into our kernel I could end up with a commit that matches some existing object in the first 33 hex chars at which point I should have chosen 34 - but of course that's so unlikely that it's irrelevant. But the upshot of that is that there really is no objective answer to "how many digits do we need", so it becomes a tradeoff between "low enough probability that anyone anywhere in the next few years would have needed more than X when building their own kernel" and readability of `uname -r` etc. So I decided somewhat arbitrarily that each time one rolls a new release, there should be less than 1e-9 probability that HEAD collides with some other object when abbreviated to X hexchars. X=12 doesn't pass that criteria even when the repo has only 10M objects (and, current linus.git already has objects that need 12 to be unique, so such collisions do happen in practice, though of course very rarely). 13 and 14 are just weird numbers, so I ended with 15, which also allows many many more objects in the repo before the probability crosses that 1e-9 threshold. Rasmus Side note 1: Note that there really isn't any such thing as "last tag/previous tag" in a DAG; I think what git does is a best-effort search for the eligible tag that minimizes #({objects reachable from commit-to-be-described} - {objects reachable from tag}), where eligible tag means at least reachable from commit-to-be-described (so that set difference is a proper one), but there can be additional constraints (e.g. --match=...). Side note 2: Linus or Greg releases are actually not interesting here (see the logic in setlocalversion that stops early if we're exactly at an annotated tag) - the whole raison d'etre for setlocalversion is that people do maintain and build non-mainline kernels, and it's extremely useful for `uname -a` to accurately tell just which commit is running on the target.