Article View: linux.kernel.git
Article #2901Re: [PATCH v3 1/2] submodule: use the submodule repository to abbreviate commits
From: Srujith Poojary
Date: Wed, 11 Nov 2026 04:19
Date: Wed, 11 Nov 2026 04:19
72 lines
14812 bytes
14812 bytes
On Wed, Nov 11, 2026 at 1:56 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> "Srujith A Poojary via GitGitGadget" <gitgitgadget@gmail.com>
> writes:
>
> > diff --git a/submodule.c b/submodule.c
> > index 6fcb606f7e..1302c11ddf 100644
> > --- a/submodule.c
> > +++ b/submodule.c
> > @@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,
> > struct commit **left, struct commit **right,
> > struct commit_list **merge_bases)
> > {
> > + struct repository *repo = sub ? sub : o->repo;
>
> Let's step back a bit. Use of any repository other than 'sub' is
> wrong as a way to correctly find suitable abbreviation of object
> names in the 'sub' repository. Now, the variable sub is NULL when
> the submodule is not initialized, in which case we won't know how
> many hexdigits we need to abbreviate "one" and "two" to, because
> there is no repository that has any object from that submodule to
> begin with.
>
> > @@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,
> >
> > output_header:
> > strbuf_addf(&sb, "Submodule %s ", path);
> > - strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);
> > + strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);
> > strbuf_addstr(&sb, (fast_backward || fast_forward) ? ".." : "...");
> > - strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);
> > + strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);
>
> And that means the above patch is an utterly wrong rewrite, isn't
> it?
>
> Because using o->repo is just as wrong as using the_repository,
> replacing strbuf_add_unique_abbrev(), which uses the_repository,
> with a call to strbuf_repo_add_unique_abbrev() and using o->repo
> does not fix anything.
>
> So when (sub == NULL), the code probably should just grab the first
> DEFAULT_ABBREV hexdigits of one and two and be done with it.
> Guaranteeing uniqueness of the abbreviations within o->repo does not
> help anybody anyway, right?
>
> On the other hand, when (sub != NULL), the rewrite in this patch is
> absolutely the right thing to do. Thanks for working on it.
>
>
>
>
Hi Junio,
Thanks for stepping back and explaining the root issue with submodule.c.
You're right—when sub == NULL, o->repo doesn't hold object information
for the submodule anyway, so querying o->repo for unique abbreviations
is incorrect.
In the next iteration, I will update show_submodule_header() to handle
sub == NULL by using the standard DEFAULT_ABBREV digits directly
without a repository abbreviation lookup, and keep the sub != NULL
logic using the sub repository.
Thanks,
Srujith
Technical Details
Message-ID:
<CABh_KWjYc15OJjdZQPFPhLO0VRFhY4VJEgYxVaJoGRK284wiUQ@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75143-linux-kernel-git=dewy.ruReferences:
<pull.2305.git.1794251100.gitgitgadget@gmail.com> <pull.2305.v3.git.1794335969.gitgitgadget@gmail.com> <01c3cc25738c43d61aff153805e02db872ff21de.1794335969.git.gitgitgadget@gmail.com> <xmqq7bikqvpm.fsf@gitster.g>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-75143-linux-kernel-git=dewy.ru
From: poojarysrujith@gmail.com (Srujith Poojary)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH v3 1/2] submodule: use the submodule repository to
abbreviate commits
Date: Wed, 11 Nov 2026 09:49:13 +0530
Organization: Usenet Network
Message-ID: <CABh_KWjYc15OJjdZQPFPhLO0VRFhY4VJEgYxVaJoGRK284wiUQ@mail.gmail.com>
References: <pull.2305.git.1794251100.gitgitgadget@gmail.com>
<pull.2305.v3.git.1794335969.gitgitgadget@gmail.com> <01c3cc25738c43d61aff153805e02db872ff21de.1794335969.git.gitgitgadget@gmail.com>
<xmqq7bikqvpm.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="773734"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:8sBB+zvNvFRW5kxxOqfA066iJkc= sha256:90GUWYgRRwKTlocOjAS98tqkZ5HawN55UM2HS4gIlwk=
sha1:H/0bBk4AGJiEMhARqWOZuC/BDDc= sha256:oRWqq35e3wYlqpR0vhN3VrJqPbypQjd3hUoes2F+v2Y=
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 01502113E20; Wed, 11 Nov 2026 07:25:06 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 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, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, 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=gmail.com
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 ErmqPvoFM0ib;
Wed, 11 Nov 2026 07:25:03 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-75143-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id E181F113DD8; Wed, 11 Nov 2026 07:24:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id BAC59E1A62; Wed, 11 Nov 2026 04:19:44 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794370767;
b=Ymd4zEmxSn3PsMXRx3srMZfxDhmetggFX2l81umUSjRfVBDU0iwriQjJ6Tw/JlUqkThP
8KrdqQFLcekoMrvbF/C1tlUQFqBGILPEgSsbBskiERrMpocaICYtW2KefpQbl0Uifvx0p
hI26LR3ZRKJuMZtQtuEQ17FLVbSoRxMCywudCJZyRsUbGliBnMsBeggLj1if4BaiqW84e
QVLvaV1ysRQqVRvOwWBhrjz46ldr5QHhiu6GEhvVipC3tNirFoi7uNogsQmi4PpIcUaj3
izDvkR6UohW+TuDWJjQHm9iMhFgSo03yU7jE7xEuAd5GiSWvoO70ygssLgH0G7fp9uA==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794370767;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
References:In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:
Cc:Content-Type:Content-Transfer-Encoding;
bh=/+KBQili/EFKsCTg2/JHY6rLA7fYyQOXJ56W3hSPG1w=;
b=rqYii1MbsjD2I7XG0XOMq/2/w/JkDoQZ8BG3NQFEuIrgN8TfTuXRLblj/ZMEtuqCwVn8
nC3pcY4y8k1aHKv8E6HFShnUMI9v2Ly12GIOztcy8/fH2Y73S2ky7f1MTTCmGsZksPilH
WFdhWLlNA3V8PS4/8zf3/LrWBWEJLUXKcTCbIrMdIWf+1X3PShnWmXqE0zAnu9vRGxhjg
PykHgyAM55+RSlWnIFH//xMj/+7+x9cBlCXlDTp9LwIVK1L2xdz263Wpef9eq6vOJzjlC
q4t0RZOnZUTmvK4AjhhFGIgl+pColK3HCtoY2456JwRjnK33LVHTkuLmm4q+2rwVdww==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="GdmnYr/E";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 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 59A17606A333;
Wed, 11 Nov 2026 04:19:27 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=GdmnYr/E
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.219.48
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794370766;
b=e8VNMEmDy0qSLiuKOuE+fWHH5MtD6Kcp/pZzOaTrNzn5o1J0tZtBfhpBV7xLhxrdxO02
vytCZxQIy0+p69wSVb17vqcL7cb7ftrI9Wtlm2wIKx9Yy7U1QUzdCw3tDcEEJPv2WZAP2
bKogQ7H5334C0PEzxyFwS1oopQwVl3cRc/BheJB1DVRBxHTO87XzaEh2C926Dj6HRzS39
VD9h3CmRsjGxo19ymQdIzQ1xgPVhhtPuF4W/8nrS44fbJfDaiPoDmj2tKvZ5AvkHOytfE
hzuxxwKrvF15z8TDVDjgI7HnIuvPewelGk9HO6mzJVlR9ZYBc6gzAOnJbcpVKKiI8uw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794370766;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
Message-ID:Subject:To:Cc:Content-Type:Content-Transfer-Encoding;
bh=/+KBQili/EFKsCTg2/JHY6rLA7fYyQOXJ56W3hSPG1w=;
b=LMmLLqAmTFVqAKje80U3RRXfkDIYFgDwqqtYAMy/mFZQOXz5TUMECBR8E51u+vYHhfbF
w3wV5G1TxpOTejTAShnCxRFzhXymmM908r3ywgbn2RpjDYzFkhy26oSdqLIo8NeKSgId0
ZuGBu4NZlV6jkBaQbw4DJryrZE/tNI28p8bjVfZgQwfG4Hq5AhFX3UEgf6KSCzfBoFEzc
VJfAe5nZVv33+fdmwTTP8tQJAbYg0qQsWpGVsQjBczdkr+VV58Irm1LY70lOIAf+dlDRU
HlKqK43HTt8g9TiWaCEtKeMcEqV+A8neMQEtyFm6i0nKp3y5VmmDmw79uRnPjci9ZBQ==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="GdmnYr/E";
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.219.48
X-Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A97360A2605
for <git@vger.kernel.org>; Wed, 11 Nov 2026 04:19:26 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2A97360A2605
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-91eed03da8bso25392446d6.2
for <git@vger.kernel.org>; Tue, 10 Nov 2026 20:19:26 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1794370765; cv=none;
d=google.com; s=arc-20260327;
b=qZ19VEFnRRniU03Gumx4s4NmUJSMO/cZlf2TS3FPPbxKYv8+SWW0nrr4R4vGsHGCne
kezoz3hhqESZzfPactFDcOl7FdCOrS/CODrsDRsAOBkxwrinKc5ugM8EWj/MsSr7irfb
mj+T8B5KU/2UWXa4jMoeebs6rwUYGoUg77CI7DbSNiNOnLXUW8h2KHuTnIGuQE/2usRP
zbHuP9cugammZR92eX+B1XsJ8KksH/H3hCPvXfu2CAv2lmqwY0SKYT8Pa1TraSxcQ6Ca
tMagMQx0pssLka52P1CulMUUEjvtbtQkZ4EpCfdeX9/kv4L1hUK2rUWmFTR9J6dd0eLx
9HEA==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:cc:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=/+KBQili/EFKsCTg2/JHY6rLA7fYyQOXJ56W3hSPG1w=;
fh=vc8A9nqbIdemrkHFbmq41xkwsE51BD5MLr4/N3TcE5Q=;
b=XKGdQmfuoM/AVA/CvA1inCFYdbDFRMM9D9pjvuuFb4fomERwckUMSYnqtmPC0E8kaQ
tcSXx8Lm6aOpj5NSTFDMSP68zYP8FGNE/9g9fSbdDrCOdOhN6XkgoMt82u6YzHiDIs8m
ZADPZnZLYmv0WyI+0DBtczv/8ShOH44XZaO/tLCGr2mCs+4yuKlqRcevfHq8o9yFQqug
+oCH597PGFAGD49JhxP8ugKQs1yolXBf9emOJasdOrNxK/USWZhTGBKP+c2QhUvjNQ7T
4YEt3Kd92EraTwdxm55aFiauKRXsplSZKrF+3QpT5/ROeE4PyiJu8mlxkS2AklFKo5H9
/Juw==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794370765; x=1794975565; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:from:to:cc:subject
:date:message-id:reply-to:content-type;
bh=/+KBQili/EFKsCTg2/JHY6rLA7fYyQOXJ56W3hSPG1w=;
b=GdmnYr/ErLJ/QpriNYmm5Av+xZEqlmoeBVzW0qyiF984cVSxkM8FXvV9NtWRlIDoGX
vVsgkY3qtMUkrpxDApNxGrGYzFQdeEG24WyPSx6oh9UCVMvBh3s+fKkXRORpn07tPuZu
/COhoVcGnuRYqaEIqjieVqISTVdaKTIuleUtivnl0Ke5AFB4L1H1RveOVQ9V1mzkpdAU
n0++7oElruxLFmuBjoOsBwYEGRj4xcICihgUDVx+0kwo7KNAzPkCTUYsq+3iob+tt7yG
IFiHw+9/zyzSnjQxKN0+zTF7jcKyqbUwdR7f4kpFcXLGqlZ27Q5rxu8QwatN2zuSfx/D
v6SA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794370765; x=1794975565;
h=content-transfer-encoding:content-type:cc:to:subject:message-id
:date:from:in-reply-to:references:mime-version:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=/+KBQili/EFKsCTg2/JHY6rLA7fYyQOXJ56W3hSPG1w=;
b=MyoR7CT5P3qEaKlC/NGw8zfOZemfTbQelgAhmd/bgj0U9I9DA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iCqqU7v5nNCAUni3juFGL6/n3i3o09FWY/Sw==
X-Received: by 2002:a05:6214:19c2:b0:917:91bb:c63d with SMTP id
6a1803df08f44-91f0415d811mr21857076d6.38.1794370765130; Tue, 10 Nov 2026
20:19:25 -0800 (PST)
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-In-Reply-To: <xmqq7bikqvpm.fsf@gitster.g>
X-Gm-Features: AclHuK8w4hQRkpQVrs_IDumu1kz_-sFa6wG3In3cPuKMErb-obrGUTke-e9CP68
X-Cc: Srujith A Poojary via GitGitGadget <gitgitgadget@gmail.com>, git@vger.kernel.org