🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #2063

Re: [PATCH] describe: count the distance correctly when commit dates are skewed

#2063
From: Tuomas Ahola
Date: Sun, 01 Nov 2026 09:46
79 lines
12586 bytes
Junio C Hamano <gitster@pobox.com> wrote:

> Tuomas Ahola <taahol@utu.fi> writes:
> 
> > Linus Torvalds <torvalds@kernel.org> wrote:
> >
> >> ---
> >> +test_expect_success 'setup: describe a tag dated before its parent' '
> >> +	git init skew &&
> >> +	(
> >> +		cd skew &&
> >> +		git config core.commitGraph true &&
> >> +		test_commit --date "2020-01-01 18:00" base &&
> >> +		test_commit --date "2020-01-01 18:01" o &&
> >> +		test_commit --annotate --date "2020-01-01 17:01" T &&
> >> +		git checkout -b side o &&
> >> +		test_commit --date "2020-01-01 18:02" B &&
> >> +		git checkout main &&
> >> +		GIT_COMMITTER_DATE="2020-01-01 18:03" git merge --no-ff -m x side &&
> >> +		git commit-graph write --reachable
> >> +	)
> >> +'
> >
> > Just a clueless rewrite of the above.  I had quite fun writing it, so why not
> > to share... it works and might even offer some not-completely-bogus food for
> > thought.
> >
> > 	git init skew &&
> > 	(
> > 		cd skew &&
> > 		test_config core.commitGraph true &&
> 
> Doesn't this barf when it tries to register a clean-up action from
> inside a subshell?
> 

Hmm, only in Bash---something I forgot to test.  This of course fails properly:

	$ make -C t/ SHELL=bash t6120-describe.sh 

> > 		test_commit base &&
> > 		test_commit o &&
> > 		test_tick=$(($test_tick - 3600)) &&
> > 		test_commit --annotate T &&
> > 		test_tick=$(($test_tick + 3600)) &&
> > 		git checkout o &&
> > 		test_commit B &&
> 
> Quite honestly, I do not see much value in this rewrite.

Well, I did prepend the code with a "caveat lector", quite aware that the
rewrite was somewhat pointless---if it had contained any good parts, that
would've been by sheer luck and happenstance.

That said, I actually tried my best, and I am quite happy that you gave that
clueless waste of time a serious review.  Thanks!

>                                                    [...]  Explicit
> dates and times from six years ago will eventually become distant
> history, but at least they made it clear, even in the source code,
> which event was recorded with what exact timestamp.  In the
> original, it was much easier to tell which commit had a newer or
> older timestamp than in the rewritten version.  Can you tell if the
> annotated commit 'T' has a timestamp older by 3600, 3599, or 3601
> seconds than the next commit 'B', just by looking at the sequence
> above and without inspecting how 'test_commit --annotate' is
> implemented?
> 
> Unless the focus of the test in question is "I do not really care
> what time they record as long as they are reasonable and
> reproducible from one run to the next", relying on $test_tick is
> probably counterproductive.  The test for this fix, where the issue
> is entirely about the relative ordering of timestamps on the
> involved commits, is a prime example of where using explicit --date
> options would make things much easier to understand.
> 

Okay, I'll be wiser next time.
Technical Details
Message-ID: <20261101094653.NKAEk%taahol@utu.fi>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74062-linux-kernel-git=dewy.ru
References: <20261031065525.19883-2-torvalds@kernel.org> <20261031123149.yxap3%taahol@utu.fi> <xmqqa4nt2wch.fsf@gitster.g>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74062-linux-kernel-git=dewy.ru
From: taahol@utu.fi (Tuomas Ahola)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] describe: count the distance correctly when commit
 dates are skewed
Date: Sun, 1 Nov 2026 11:46:53 +0200
Organization: Usenet Network
Message-ID: <20261101094653.NKAEk%taahol@utu.fi>
References: <20261031065525.19883-2-torvalds@kernel.org>
 <20261031123149.yxap3%taahol@utu.fi> <xmqqa4nt2wch.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
	logging-data="2662020"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:R8LExztdBeDXZyqjRKNyCyjrBas= sha256:cbCpfRHy71nP8A4dH+lz1b31I+l0ppFYoCwTN10fVpM=
	sha1:UtBAV06t8LkA/XQHD8IlRd6hIr4= sha256:3c3/rzyh/mmxbHZpCOFqFPn28LqooT3z1AEAWDjeb9w=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id E8ABC11230F; Sun,  1 Nov 2026 12:47:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.948
X-Spam-Status: No, score=-1.948 tagged_above=-9999 required=6.31
	tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	UNPARSEABLE_RELAY=0.001, URIBL_BLOCKED=0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=utu.fi
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id sP-9rpPInzko;
	Sun,  1 Nov 2026 12:47:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-74062-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=utu.fi
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 5CEC21122EE; Sun,  1 Nov 2026 12:47:20 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 8A10F26100; Sun,  1 Nov 2026 09:47:16 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail;
	t=1793526434;
	b=T0Tixoww9Q+4ZoKxs8RH2e+5vJ8UB+OZ5KtXHwELkTLuOa6XnV+lpde76IlcBm5fN5SB
	 tNEg8yOLc9TKsgnomvOrN1lXQ66B+uBTDpGe6QVshrIl/nvQQ9936j8L8G4K8gg4z/Wmj
	 MN6CZBAF/iB4ELQs+xzIMaR68KsigPQcoszvgWlxt/GI2UVsuMVj26GOhFryJx8z+V2B1
	 guOfM90tDthyXCQwPsz1KTdFQkpTOTltj+W6PcK4y3QHo9W0dr/KNA+u1m1LiPt3XWeXC
	 /8YwYwmlgtRdMhmlVQ3hqvtE9MN4xrGkXcjQNJm/w+UKjm1IxJFU42qFRYVLBqbxORQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793526434;
	h=X-Original-To:Received:DMARC-Filter:Received:Received:Received:
	 Received:Date:From:To:CC:Subject:Message-ID:In-Reply-To:References:
	 User-Agent:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 X-ClientProxiedBy:X-FEAS-BEC-Info:X-FEAS-Client-IP:
	 X-FE-Last-Public-Client-IP:X-FE-Policy-ID:X-FE-Hostname:
	 DKIM-Signature;
	bh=QWKz4E8sZ9/UH83FCDsXI2bKepPdksL6xQN0JUEcjkE=;
	b=Y7v9J9esJ1TpEhhrSwsGw46Bmz7hQ1L8eXVXhVWm6rUedcB5mXLiJxEMbD3N/xtgXiV7
	 7eZj9reagLQFR8jRPNZXHW1f96a4apYVpZWFCar3hQ5i6vjK9w8GoNQn1kqcdXSnMIriB
	 VbIjy5Tq2OAryjzZV1ELL/JNXLNbuOguPwurd/uKDCzbPVT/TLEqbrG7vt0+3Iy3L7CKs
	 BF2/DYdOpY+g2dXfwktet8Dy8UgQEFV32fhAfIIx69OfzcAsw16PocbTb3Yn9lp938EQA
	 SgaYgkfgPVK6UWTf/VzACBVKstAvQylb7/34Aqlh4CTDgt5A8c9wQGVtHL2kNP0h83Q==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=utu.fi header.i=@utu.fi header.a=rsa-sha256 header.s=out-utu-v3 header.b=AzMp0Jmc;
	dmarc=pass header.from=utu.fi;
	spf=pass smtp.mailfrom=utu.fi;
	arc=fail smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id EDF81606A32D;
	Sun,  1 Nov 2026 09:47:13 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key, unprotected) header.d=utu.fi header.i=@utu.fi header.a=rsa-sha256 header.s=out-utu-v3 header.b=AzMp0Jmc
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=130.232.247.4
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793526432;
	b=02bpa0Cxqn0+6X/1Le58ccVplbV90ShYr8MLuoWAoyN3c7/ZGQfVcF8+w8934QeiYJPz
	 yy+TfGGvF75+CAGHUwf80uBVMQSYauUpdRP95HLopGeFj0Uzh9hHIzmBl7KmwWUvWa/Ko
	 x2Du0UaucnKxwHtoOgB8IJ232J64IdwjvLULRgcNsYw20G6cliIjXjXja/746gRbjgj6/
	 6RPCnUDtgSPGJ1JP2iRe8Z7TsgWv+4spROGSFLii9witgPzSWDuj9l+H4KnoUl77SsBKO
	 zEScdvnCHxNmCQN6b9En/7omBoQnmyspe8U1u3WnVSNGQCwqfgUozvPENgXxTkcLz7A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793526432;
	h=DMARC-Filter:Received:Received:Received:Received:Date:From:To:CC:
	 Subject:Message-ID:In-Reply-To:References:User-Agent:MIME-Version:
	 Content-Type:X-Originating-IP:X-ClientProxiedBy:X-FEAS-BEC-Info:
	 X-FEAS-Client-IP:X-FE-Last-Public-Client-IP:X-FE-Policy-ID:
	 X-FE-Hostname:DKIM-Signature;
	bh=QWKz4E8sZ9/UH83FCDsXI2bKepPdksL6xQN0JUEcjkE=;
	b=MI7AQqF3MbMZC5/q36pkuftsf7SjfuyygcZSMUkFmwCSop6iL6BEkZUuJZQVCU62TQwY
	 OTGlaAxnBGUk0LVNzjFE2idSwQew7wveQz6bMlPCkD6yQSx6816EGmR9qF0mVaN+saj1P
	 GpLTF50WNPhROo8w9seaUdir6875qzp2cZKlZmA/tXbzydfQvMnO2MRnuZyplzFRWWvw/
	 hevLvF1GYnjoK/BZlawPODmfYVjpC44nXUQgOGWRByzZlqYvy0kURgQYMRTT3rsI0S+Tm
	 CMKiiEZviSItX2dD7cqAlGVFDK3krPj+lU7OnYHJ7+IAwTjtilbBFWpBkbYphI60n/A==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=utu.fi;
	spf=pass smtp.mailfrom=utu.fi;
	dkim=pass header.d=utu.fi header.i=@utu.fi header.a=rsa-sha256 header.s=out-utu-v3 header.b=AzMp0Jmc;
	arc=none smtp.remote-ip=130.232.247.4
X-Received: from fortymile.utu.fi (fortymile.utu.fi [130.232.247.4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 127AA606A325
	for <git@vger.kernel.org>; Sun,  1 Nov 2026 09:47:09 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 127AA606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=utu.fi
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=utu.fi
X-Received: from smtp-04.utu.fi (smtp-04.utu.fi [130.232.207.47])
	by fortymile.utu.fi  with ESMTPS id 6A19ksCC018582-6A19ksCE018582
	(version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO);
	Sun, 1 Nov 2026 11:46:54 +0200
X-Received: from ex19-06.utu.fi ([130.232.247.46])
	by smtp-04.utu.fi with esmtps  (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
	(Exim 4.95)
	(envelope-from <taahol@utu.fi>)
	id 1xNS9O-00FiaD-7m;
	Sun, 01 Nov 2026 11:46:54 +0200
X-Received: from localhost (86.50.95.90) by ex19-06.utu.fi (130.232.247.46) with
 Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Sun, 1 Nov
 2026 11:46:53 +0200
X-Received: from localhost (localhost [local])
	by localhost (OpenSMTPD) with ESMTPA id cc3df952;
	Sun, 1 Nov 2026 09:46:53 +0000 (UTC)
X-CC: Linus Torvalds <torvalds@kernel.org>, <git@vger.kernel.org>, Linus
 Torvalds <torvalds@linux-foundation.org>
X-In-Reply-To: <xmqqa4nt2wch.fsf@gitster.g>
X-User-Agent: s-nail v14.9.22
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-ClientProxiedBy: ex19-16.utu.fi (130.232.247.56) To ex19-06.utu.fi
 (130.232.247.46)
X-FEAS-BEC-Info: WlpIGw0aAQkEARIJHAEHBlJSCRoLAAEeDUhZUEhYSFhIWkhZXkguLT4lWFxYWFhYWFBeUVxfSFhISFlbSBwJCQAHBCgdHB1GDgFIWUhaUUgcBxoeCQQMGygEAQYdEEUO
 Bx0GDAkcAQcGRgcaD0hYSFpIWVxIWVtYRlpbWkZaWF9GXF9IUEhYSFhIXEhYSFhIWEhZUUgPARwoHg8NGkYDDRoGDQRGBxoPSFhIWV9IDwEcGxwNGigYBwoHEEYLBwVI
 WEhZUUgcBxoeCQQMGygDDRoGDQRGBxoPSFhIWlFIHAcaHgkEDBsoBAEGHRBFDgcdBgwJHAEHBkYHGg9IWA==
X-FEAS-Client-IP: 130.232.207.47
X-FE-Last-Public-Client-IP: 130.232.207.47
X-FE-Policy-ID: 3:5:2:SYSTEM
X-FE-Hostname: fortymile.utu.fi
X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; d=utu.fi; s=out-utu-v3; c=relaxed/relaxed;
 h=date:from:to:cc:subject:message-id:references:mime-version:content-type;
 bh=QWKz4E8sZ9/UH83FCDsXI2bKepPdksL6xQN0JUEcjkE=;
 b=AzMp0Jmc66qm+rjCy1GvFA0L0gsYJsp1noD0HneOTNuEQDZxXZBYeBolrtY7tBwCqzNyeKmqqz8w
	JGQTdUPJIA1CTJcdcpK6+ojcJW6NwfLjfgcuRpDzqs5GSfVWWrbA9Gn0vCZ8F/XHVCGeJB3958qf
	6m0ngbSjptB7/5m0891xjfuV+Tqikn2vHoTK9dffzyNNBKZc5rOPFZl/OdJkpKV8MWVN8CKITn6Q
	F3+kh3gIUdMEH2jYqWDNcMz+ZzzSznL2w0NLlBwoUqFp9yoKA+ogwFMQvV1jbHaYvMfLNUyTvb5k
	peL1QeHvbFBmk4GnP+B8lPpcOdT+cvVIxzYDNw==