🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #669

Re: [PATCH] describe: use Q_() for pluralization of commit and tag counts

#669
From: Junio C Hamano
Date: Fri, 16 Oct 2026 15:51
83 lines
12562 bytes
"Raj Ojha via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Raj Ojha <rajojha047@gmail.com>
>
> In `describe_commit()`, debug messages print the number of commits
> traversed and the number of candidate tags found using basic `_()`
> localization format strings:
>
>     _("traversed %lu commits\n")
>     _("found %i tags; gave up search at %s\n")
>
> Because these messages display an integer count of items, using `_()`
> fails to account for languages whose pluralization rules differ from
> English (such as languages with multiple plural forms).
>
> Replace these calls with `Q_()` to allow gettext (`ngettext()`) to choose
> the grammatically appropriate singular or plural string depending on the
> integer count.
>
> Signed-off-by: Raj Ojha <rajojha047@gmail.com>
> ---

Is this convergent evolution or something?  The similarity to
https://lore.kernel.org/git/20261013204351.428800-1-antekborowski11@gmail.com/
is striking.

It's not like anybody who sent a change on a piece of code
automatically owns the area to be improved, but we would love to see
more collaboration and a better use of the lore archive to find
similar effort being made before people send patches.

  https://lore.kernel.org/git/?q=describe+Q_


>     describe: use Q_() for pluralization of commit and tag counts
>     
>     In describe_commit(), debug messages print the number of commits
>     traversed and the number of candidate tags found using basic _()
>     localization format strings:
>     
>     _("traversed %lu commits\n")
>     _("found %i tags; gave up search at %s\n")
>     
>     
>     Because these messages display an integer count of items, using _()
>     fails to account for languages whose pluralization rules differ from
>     English (such as languages with multiple plural forms).
>     
>     Replace these calls with Q_() to allow gettext (ngettext()) to choose
>     the grammatically appropriate singular or plural string depending on the
>     integer count.

You do not want to repeat your log message below the three-dash
line.  It wastes everybody's time.

> diff --git a/builtin/describe.c b/builtin/describe.c
> index c0abc931a5..1a7317c811 100644
> --- a/builtin/describe.c
> +++ b/builtin/describe.c
> @@ -481,10 +481,16 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
>  				label_width, _(prio_names[t->name->prio]),
>  				t->depth, t->name->path);
>  		}
> -		fprintf(stderr, _("traversed %lu commits\n"), seen_commits);
> +		fprintf(stderr,
> +			Q_("traversed %lu commit\n",
> +			   "traversed %lu commits\n",
> +			   seen_commits),
> +			seen_commits);
>  		if (gave_up_on) {
>  			fprintf(stderr,
> -				_("found %i tags; gave up search at %s\n"),
> +				Q_("found %i tag; gave up search at %s\n",
> +				   "found %i tags; gave up search at %s\n",
> +				   max_candidates),
>  				max_candidates,
>  				oid_to_hex(&gave_up_on->object.oid));
>  		}

Both the log message and patch text look cleanly done.

Thanks.
Technical Details
Message-ID: <xmqqzewdhcel.fsf@gitster.g>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72236-linux-kernel-git=dewy.ru
References: <pull.2257.git.1792058069306.gitgitgadget@gmail.com>

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-72236-linux-kernel-git=dewy.ru
From: gitster@pobox.com (Junio C Hamano)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] describe: use Q_() for pluralization of commit and tag
 counts
Date: Fri, 16 Oct 2026 08:51:14 -0700
Organization: Usenet Network
Message-ID: <xmqqzewdhcel.fsf@gitster.g>
References: <pull.2257.git.1792058069306.gitgitgadget@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: usenet.network;
	logging-data="2806899"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XoK3dMppIAvA+AioxV5ZkZnKMvE= sha256:e6KcGxuGebOLh35bN7NzuXk0lod1vKsv96Fq36qsHu0=
	sha1:9Eaa4i8tkIYiCXW2F1VaWZy77w0= sha256:SI+0rzg6SjRkTlf5/FBfrq6C5KslGvzXU/qbzGa8TQ8=
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 40D38110575; Fri, 16 Oct 2026 18:55:12 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -0.75
X-Spam-Status: No, score=-0.75 tagged_above=-9999 required=6.31
	tests=[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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=pobox.com header.b=L41aj0Fd; dkim=pass (2048-bit key)
	header.d=messagingengine.com header.b=byLFS2OT
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 zDnZAqt0NGmC;
	Fri, 16 Oct 2026 18:55:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-72236-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=pobox.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 4C6C5110573; Fri, 16 Oct 2026 18:54:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by tor.lore.kernel.org (Postfix) with ESMTP id DB72544AB3; Fri, 16 Oct 2026 15:51:31 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BBCD4DDB48;
	Fri, 16 Oct 2026 15:51:20 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b="L41aj0Fd";
	dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="byLFS2OT"
X-Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C2D14DAF90
	for <git@vger.kernel.org>; Fri, 16 Oct 2026 15:51:17 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792165878; cv=none; b=AuxdMh/orJmL0zqV4IGrMkcYf1Kx20L/OZ79gwG2y6IfxYpd2zUO6W7Otnr7guJAtQaDG9KsMnz/9SbOZKNvEKi6969Vs2VsXZEQYesI9cPKNB2J5GIk0E2MrFWKp4kgYz2XER64fgAz4+VlKbBcVNLsf/3DZmefkqxWYaPm4zQ=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792165878; c=relaxed/simple;
	bh=JuxLaPtGJMxPWmN4uGQH9RgMf6+q/20Z7z6FkTWzA6k=;
	h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID:
	 MIME-Version:Content-Type; b=qjHStXjnDH6603GRVuwe8z2hqibhiohPb0LZlhAXjvYP4wTAMvQWYCchy61YsUQnjfSbvGbZ7l1fqwGkyWYXv8l6RXpuem6fIsTmA6Lyc2ccmT3X2JcdavQGiNdYMrxzMwvLWrtO1iw8+9/H3Og9ywUt2Op6BHMdUhomtxQnpwA=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com; spf=pass smtp.mailfrom=pobox.com; dkim=pass (2048-bit key) header.d=pobox.com header.i=@pobox.com header.b=L41aj0Fd; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=byLFS2OT; arc=none smtp.client-ip=103.168.172.153
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=pobox.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pobox.com
X-Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43])
	by mailfhigh.phl.internal (Postfix) with ESMTP id 4FD821400131
	for <git@vger.kernel.org>; Fri, 16 Oct 2026 11:51:16 -0400 (EDT)
X-Received: from phl-frontend-02 ([10.202.2.161])
  by phl-compute-03.internal (MEProxy); Fri, 16 Oct 2026 11:51:16 -0400
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pobox.com; h=cc
	:cc:content-type:content-type:date:date:from:from:in-reply-to
	:in-reply-to:message-id:mime-version:references:reply-to:subject
	:subject:to:to; s=fm1; t=1792165876; x=1792252276; bh=V53hHwuTqk
	SZ+N9QhFeqiJsd5yifyHpjkkQ/WPMsEWY=; b=L41aj0FdDoTY9rqbqpyExoqiiP
	bGQ6YN7cZRmMhFq/BaNckKF0ZqLHBCtW83O1UFentkc4aWE+qLkC9uHym9GNG/5F
	9+k3h9/Fcey/gnt3qQn/7GZp/t7kqf/reRMpXkNYZa96mzscD/I0fdLvlcOS/DOV
	lg7ubqUT++co3ZJZxpKgEt/NVTZD/VInCoFOWw9UG4ue+y1doqFjJCiIvq3/X5gY
	nVQBM1moubICB9tpD/0SYykuA5hE5TUSIPt/PMBj5InKdb6i6gC0CanipfPY+jd+
	kuwNmamMgENDQzGn42Jz+djHc4Kkt2Wq0xwQGwOmdu1ySXfenb+00cnw8KqA==
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc:cc:content-type:content-type:date:date
	:feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
	:message-id:mime-version:references:reply-to:subject:subject:to
	:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=
	1792165876; x=1792252276; bh=V53hHwuTqkSZ+N9QhFeqiJsd5yifyHpjkkQ
	/WPMsEWY=; b=byLFS2OTs1bd8ta2F6siyDM/xW7VjZaeZD88dkh6175H5SNFURE
	55Hw9hfezGD1kgmCqnO4Lk+f7uWzIjG9UW1gjQkkgQdEmOCuGe84JpQcPiLBX0jG
	XY/dy64AbUNzLr5PWlVleZ/zkeQSIdSIEG2FESaKGSGAcFdwEGURHVkKDoiPF6Gu
	H7WU1Ked+WnKooSlstwpC7ixZQGeccu6EOUDsRLklN88033fCZqGel9CixyGuAzb
	nFK2bD8vN2s5f/r2PPUYleTkO3Tl46tZLJaaIOe+KmrC7+gz+UBpcWrW6yONnUMp
	EsdrOGhm/eXwVMwsW8ZemVomrS/gSg/ioyw==
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06;
	repo=github.com/dkim2wg/interop; date=2026-10-08; sw=lmtpprox;
	action=sign d=pobox.com a=rsa-sha256;
X-DKIM2-Signature: i=1; m=1; t=1792165876; d=pobox.com;
	mf=PGdpdHN0ZXJAcG9ib3guY29tPg==;
	rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+;
	s=fm1:rsa-sha256:k+unjn40YgZz2IFxU6qkFiIA3fCC+h8J9lGzvC3l0HVSwko
	m3Z5+gWzt77X7G0R6Cv6yGTWBoWDmWwlPAzw12dZcIfEhURqASCL/VFwyRx3GO+o
	G5al/lZY9HnS+6kZwf8DuBSrXkbm/FPAZ4Ck9P4gEuznZpH1LxVUvmmv3MA4yuJl
	488MTnNwdw3GG3oF3FD6Gi2j8E9Xe8YVz5upvHXbuUu1RbMr0LcwliI6ofQXEAxW
	VR3b08cflpcqFqDhbFAmG/Zge5308f8sglIbVCx+A1TgVxSsoVojlwGp8374vjRQ
	I11BRW6mZvtvrgFAWHDjk24QiphmIoxGjC3K1iQ==;
X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-06;
	repo=github.com/dkim2wg/interop; date=2026-10-08; sw=lmtpprox;
	action=mi-m=1; hc=12;
	hn=cc,content-type,date,feedback-id,from,in-reply-to,message-id,
	mime-version,references,subject,to,user-agent;
X-Message-Instance: m=1; h=sha256:bX/znUne7Nz/fVa7vJr/jRIwBVwPcnX27i5ObL3V4BU=:JuxLaPtGJMxPWmN4uGQH9RgMf6+q/20Z7z6FkTWzA6k=;
X-ME-Sender: <xms:9EfSalFqEMEWWs-4jkah0hA-RbFfBFaYTNCFSDkbscyDcA3zrlDlDA>
    <xme:9EfSahXLXJe8KOiYwNZigZEjr6Y07zMQfHUYA28T9cGPjlmoaBd2VxQmyOBi4hoWo
    mZKxkwARFRh2fR5y7gsNKuRR9WJl_1o-93xF1Ot8YEg_xnroIN-0VA>
X-ME-Received: <xmr:9EfSasJjPazhF9I6Eaxmv3NJFZFn615Vne21z8sLGgb6iwlek-J9OWomkLh7AfboEAadymGBv1QHue1hzQjwloO5xL6AfW1DwHUi>
X-ME-Proxy-Cause: dmFkZTGcfaZDuf7wKBzmcw7BCuKnmrpnOTwzW/5EyO74noJiVlIEnPIgYCfVH4sLYoRNH6
    8JnK+Pyk5MvmLOG8QwoQs4kkrnXIqDbY/HVimRu/x2tZQwLQCGzdHeikxsGMIgNRGRhNX7
    PcCVmKrwY8uK9VOBVbEvAhkebYyyt0rsMnSHLzsvfv4FAdIB57uj24OpeJnlPDi8WA/cXI
    TLBfdl1jxPIaMvsUBQKQkpygx7gp3XpwwCO0FpuL8IB6res2wNsE/pvx5M3tz6WEv2fIkg
    ER+PBOKZMZ4OBpvUtzQOUY6cD4HRh5fQUAqLuLk1dCiFze0pjuEAR/dtKK7RqicS2wGnQu
    anvJPbHI/9jkgxcfCSB2t3uCbqRnZL3n5N5qF6NwCOoMsy6fq5XQD7mDgJ3zSgoZjnTxkX
    c+UW6n87HQ4eLvUkRWh7h241nApuyATKy+iQ0C+MKPEphmFOS5LVvR4KbiekeJYOWgeBwt
    7Z+hI0YfEVgSczMs6rFwKs6rwyHktm0ahaYAFsGsQ5jW7ook/KwQeIxPkInSHlC/hagNre
    fuAG5F8YsQa1+ty5l4xMsjMTa6VQBqjnnF1zXZ1qHpNCINDoH+tWySAZKaxXWa6tnEQvRR
    /uZS1iS6xLLYtMBVtfPJMfVoXuKmPasNu222T48cXzPdfKCZiLMClkyTMCfA
X-ME-Proxy: <xmx:9EfSap_Tu4kIEJPqBDhDT2Ik4AFKB5UV462Ww_9oEGE0D91CHD-uOw>
    <xmx:9EfSanIq7woYQmB81OwwJBSo3dkxLGNSHTlZcoS7yMj_4GgE04noRA>
    <xmx:9EfSamnMpdPwWGFdKbz2N3j3jh6bRNH8OUr6rV4H7ckVUZfnvqlc5Q>
    <xmx:9EfSajNy9RkgMJhPkYtYRAremFdJ7TrlHtOuW21viGD008r3akLaRA>
    <xmx:9EfSanoQGLOGNCRxwzkooavk-CGa2PzUfcop2cyctZoqJAWXnjMPJ1PA>
X-Feedback-ID: if26b431b:Fastmail
X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri,
 16 Oct 2026 11:51:15 -0400 (EDT)
X-Cc: git@vger.kernel.org,  Raj Ojha <rajojha047@gmail.com>
X-In-Reply-To: <pull.2257.git.1792058069306.gitgitgadget@gmail.com> (Raj Ojha
	via GitGitGadget's message of "Thu, 15 Oct 2026 09:54:29 +0000")
X-User-Agent: Gnus/5.13 (Gnus v5.13)
X-Precedence: bulk
X-Mailing-List: git@vger.kernel.org
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>