From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id ACrJB97BwGWSDQAAqHPOHw:P1 (envelope-from ) for ; Mon, 05 Feb 2024 12:09:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id ACrJB97BwGWSDQAAqHPOHw (envelope-from ) for ; Mon, 05 Feb 2024 12:09:18 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1707131357; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=h7vGUvZSLdNJHpyCzRIQUi7YESkAmgSj45zc8/a5c7c=; b=pKLL/i2a8AUErnbQMZYL29Bb4Z+WTHRq0avJsXdLmkd7FqzIE4tAFGWx0O/Nl3ANLtUg7c 6q56LO/CyqjKo2UUks0yUPEc1cIRajCScy1jAcPrtS5t2khR0K+rxnB+gTkNzP8ZZ5Ltrq GQQWvOf3w7eYBmhNlkbKf25jp7xsE551RmackgCID/xutEy929PDgs/6vWm67/N51qJvCy jlkj8OFBUmCBATGOeBAKdOfZ/ywLS5ZvYaSxS4m+akQiFvdwKWumQUBddsOtNhroDcT5OG 4BsOiMhDeogWjRQ9NCe9KdggR0KbwTSoDOcZkx01yYLrbXxZr3A/9ZkyV2+Dtw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-devel-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-devel-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1707131357; a=rsa-sha256; cv=none; b=LjEFUvnSUhU/G59Dd2hisgdVRlOF6Tfv9G9nToHLnBjyBpqtEfyKbK1+sUOOCPBPEqM78Y SwWS0B4csUsHxsU7jbGqpLmHqDVh0aW386Rp5eyrFFyXvUCWGqisFAxeFiqnpVIih/LAQ2 sutK79f+Pd0eeILEod8siqiMtX3cAJyk4ErUNEv7K/YLC7NXGWtvlRfojpJq5S0LJZ2I8t ZTHB54RpfLakYaN2pmQ+FnoQeQI+JFyxTRCTkEa36Qpr7led7D4+fYxmXF0+Qw2jhj5FWU y9hTYvCG+N/B/XVwIuzy/gkcwzYNyrWNNwjE1N5aoT36GRppEO6oCV9mWctIsw== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3C9273620B for ; Mon, 5 Feb 2024 12:09:16 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWwq6-0006Vd-6z; Mon, 05 Feb 2024 06:08:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWwq5-0006VV-JD for guix-devel@gnu.org; Mon, 05 Feb 2024 06:08:37 -0500 Received: from ns13.heimat.it ([46.4.214.66]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWwq0-0004Cl-1n for guix-devel@gnu.org; Mon, 05 Feb 2024 06:08:37 -0500 Received: from localhost (ip6-localhost [127.0.0.1]) by ns13.heimat.it (Postfix) with ESMTP id 9FAA130081A for ; Mon, 5 Feb 2024 11:08:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at ns13.heimat.it Received: from ns13.heimat.it ([127.0.0.1]) by localhost (ns13.heimat.it [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fhi_6UbmYYqs for ; Mon, 5 Feb 2024 11:08:26 +0000 (UTC) Received: from bourrache.mug.xelera.it (unknown [93.56.171.217]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ns13.heimat.it (Postfix) with ESMTPSA id B2CBC3007E0 for ; Mon, 5 Feb 2024 11:08:26 +0000 (UTC) Received: from roquette.mug.biscuolo.net (roquette [10.38.2.14]) by bourrache.mug.xelera.it (Postfix) with SMTP id 246162E34F3B for ; Mon, 5 Feb 2024 12:08:26 +0100 (CET) Received: (nullmailer pid 22273 invoked by uid 1000); Mon, 05 Feb 2024 11:08:25 -0000 From: Giovanni Biscuolo To: guix-devel@gnu.org Subject: consider "git describe"... harmful? (if misused) In-Reply-To: <87le81bd8d.fsf@xelera.eu> Organization: Xelera.eu References: <87pm6k5vwn.fsf@gnu.org> <87le81bd8d.fsf@xelera.eu> Date: Mon, 05 Feb 2024 12:08:17 +0100 Message-ID: <87cytbb23i.fsf@xelera.eu> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" Received-SPF: pass client-ip=46.4.214.66; envelope-from=g@xelera.eu; helo=ns13.heimat.it X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: guix-devel-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -8.77 X-Spam-Score: -8.77 X-Migadu-Queue-Id: 3C9273620B X-Migadu-Scanner: mx12.migadu.com X-TUID: oKxxGCexOYl3 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello developers, Ipse dixit: a tag is a tag is a tag. Sorry to stress on this but AFAIU "git describe" and it's variants is (mis)used by some (many?) to obtain the last revision number of packages got from a git tag on a repo, even in few upstream build config/scripts (patched in Guix); here are just a few examples I've observed from messages in this mailing list and our package definitions: =2D https://yhetil.org/guix/7a759ffb-fca8-478d-a4aa-08e6b674da75@archlinux.= org: `git describe --tags`, which is often used for --version output (especially in Go projects) =2D https://yhetil.org/guix/87ediha5p0.wl-hako@ultrarare.space: I usually obtain the revision number from the output of 'git describe --tags', I think it's fine to use it when available. =2D https://yhetil.org/guix/c93c18e5-8e01-45a0-b79f-05d72f6f8230@archlinux.= org The output of `git describe --always --tags --dirty` was also embedded. Some code/comments I got running "find . -type f -exec grep --color=3Dauto =2DnH --null -e "git describe" \{\} +" in "/gnu/packages", in Emacs: =2D ./audio.scm:751: ;; Ardour expects this file to exist at build time. T= he revision is the output of git describe HEAD | sed 's/^[A-Za-z]*+//' =2D ./build-tools.scm:589: (substitute* "src/tup/link.sh" (("`git describe`") ,version)) =20 =2D ./linux.scm:7263: ;; the checkout lacks a .git directory, breaking =E2= =80=98git describe=E2=80=99. =20=20 =2D ./axoloti.scm:500: ;; TODO: this is the output of: git describe --long --tags --dirty --always IMHO "git describe" should never be used to obtain the last revision for the reasons I explained in my previous message (see a quote below): IF you get it right is ONLY by chance (probably it's most of the times), not by **design**; executive summary: 1. "git describe [--tag]" have a bug and doesn't traverse the graph in topological order; for the Guix git repo this means that now the last "git describe" tell us something like "v1.3.0-53609-gc70c513317" (the number of commits and the commit hash may vary depending on last "git pull"), not something like... 2. is NOT guaranteed that the last tag reported by "git describe [--tag]" (even if the above mentioned bug is resolved) is the one corresponding to a released revision of the software, since tags (even annotated one) can be added by repo committers for any reason they find useful; i.e. the last tag commited gor the Guix repo is base-for-issue-62196. If and ONLY IF committers use a recognised pattern for the tag - i.e. v - we can get the last (tagged) revision from git (see below for alternative to " Giovanni Biscuolo writes: [...] > The upstream bug report (and a reproducer) is this one: > =C2=ABSubject: [BUG] `git describe` doesn't traverse the graph in topolog= ical > order=C2=BB > https://lore.kernel.org/git/ZNffWAgldUZdpQcr@farprobe/ > > Another user also reported the issue and a reproducer: > https://public-inbox.org/git/PH0PR08MB773203CE3206B8DEFB172B2F94839@PH0PR= 08MB7732.namprd08.prod.outlook.com/ > > The "executive summary" is that "git describe" gets the count of "fewest > commits different from the input commit-ish" wrong (see anso previous > messages in this thread for details). > > Anyway, even if this bug was solved, I'd warmly suggest NOT to base the > check for the latest stable Guix commit (usually tagged as v[0-9]*) on > the result of "git describe". > > Today, if "guix describe" I mean "git describe", sorry! > had no bugs, the correct result would be: > "base-for-issue-62196"... AFAIU :-) > > This is a reproducer: > > --8<---------------cut here---------------start------------->8--- > > $ git describe $(git rev-list --tags --max-count=3D1) > base-for-issue-62196 > > --8<---------------cut here---------------end--------------->8--- > > To get the value corresponding to the latest tagged version, we should > testrict the list of tags to the ones matching the "v[0-9]*" regexp: > > --8<---------------cut here---------------start------------->8--- > > $ git describe $(git rev-list --tags=3D"v[0-9]*" --max-count=3D1) > v1.4.0 > > --8<---------------cut here---------------end--------------->8--- More efficient alternative: =2D-8<---------------cut here---------------start------------->8--- $ git tag --list 'v*' --sort=3D-creatordate | head -1 v1.4.0 =2D-8<---------------cut here---------------end--------------->8--- [...] Should we add some notes (a footnote?) in our Guix manual? WDYT? =2D-=20 Giovanni Biscuolo Xelera IT Infrastructures --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJABAEBCgAqFiEERcxjuFJYydVfNLI5030Op87MORIFAmXAwaEMHGdAeGVsZXJh LmV1AAoJENN9DqfOzDkS+lUP/iKhnvWqBUMHVyX7O+ql1YJneOC4qALBl1sj1PxG 6mGvo5Fv++4wILYfjPv6vmr9Q0zo+9VslfASPOMZgUGt4SBHZAtn+a4uaaXUumW8 rDqGsOx8+ZmVkEmy8KSFTqX4XGjnmR38Ig6cP+1L+f7kgfVFnKq39Ci+nUz0kZPq +jJAlvHBZ4A/skWWow76Zg8QDd9b8dwX4zcoX4axkYxfYLJgdvsP6lSgk0vCgjYP /Tir84kCCRifL/MrT2dl8wpk10f3cGvXxLM2L0HxaJlAUzQIq+LCoyRdJcrBNXBg EnTjDol2u36QWPkgc2PFQIwTqQroZASkFoGrb2ABGxf3WkC8lQE1WbCpI8PQnbJJ ysqkZ4CyQidVyW/Gfcu47fvL1P2/mHuwApw8YzdRORLoa0okhBZzHUM5zgM3dAde CJR+CjHcuap15yJWgec2CKD2xLjyMRFKljbrhHp29seqO3bYebzPN/PtlHPb4AT7 xbWS+huOufKH868YrXp/vCdmV/TZEv3qDi4KrbAjp+S3W+90ZkxIsEqxxGWYAXbi /OjVDJeVQzq2iwG+uplitp+7gA5CbOaB5AFO9b8G5yZ+tMqKU71raIekxcVFWDWM 88hxYh4keg4HcrI8nTazy9DE9YY9zgbmXFVPmumpVbMi5XV/qVslcLicHhVfsM1s 6N3j =Binw -----END PGP SIGNATURE----- --=-=-=--