Article View: linux.kernel.git
Article #1803[Outreachy PATCH v2] range-diff: use diffopt->repo instead of the_repository
From: Okhuomon Ajayi
Date: Thu, 29 Oct 2026 08:47
Date: Thu, 29 Oct 2026 08:47
89 lines
14182 bytes
14182 bytes
output_pair_header() and patch_diff() receive a diffopt whose repo
field names the repository to work on, yet they abbreviate object
names and look up commits in the_repository. get_filespec(), called
from patch_diff(), also uses the_hash_algo, which is the hash
algorithm of the_repository. If a caller set up diffopt for another
repository, these functions would still read from the global one.
Use diffopt->repo in output_pair_header(), and add a hash algorithm
parameter to get_filespec() so that patch_diff() can pass
diffopt->repo->hash_algo.
Keep USE_THE_REPOSITORY_VARIABLE because read_patches(), output() and
is_range_diff_range() still use the_repository.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
Changes since v1:
- Reworded the commit message as suggested by Pablo. No code was
changed.
Thanks, Pablo, for the review.
range-diff.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/range-diff.c b/range-diff.c
index 8e2dd2eb19..3f56a4f71a 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -418,7 +418,7 @@ static void output_pair_header(struct diff_options *diffopt,
if (!dashes->len)
strbuf_addchars(dashes, '-',
- strlen(repo_find_unique_abbrev(the_repository, oid, abbrev)));
+ strlen(repo_find_unique_abbrev(diffopt->repo, oid, abbrev)));
if (!b_util) {
color = color_old;
@@ -440,7 +440,7 @@ static void output_pair_header(struct diff_options *diffopt,
strbuf_addf(buf, "%*s: %s ", patch_no_width, "-", dashes->buf);
else
strbuf_addf(buf, "%*d: %s ", patch_no_width, a_util->i + 1,
- repo_find_unique_abbrev(the_repository, &a_util->oid, abbrev));
+ repo_find_unique_abbrev(diffopt->repo, &a_util->oid, abbrev));
if (status == '!')
strbuf_addf(buf, "%s%s", color_reset, color);
@@ -452,9 +452,9 @@ static void output_pair_header(struct diff_options *diffopt,
strbuf_addf(buf, " %*s: %s", patch_no_width, "-", dashes->buf);
else
strbuf_addf(buf, " %*d: %s", patch_no_width, b_util->i + 1,
- repo_find_unique_abbrev(the_repository, &b_util->oid, abbrev));
+ repo_find_unique_abbrev(diffopt->repo, &b_util->oid, abbrev));
- commit = lookup_commit_reference(the_repository, oid);
+ commit = lookup_commit_reference(diffopt->repo, oid);
if (commit) {
if (status == '!')
strbuf_addf(buf, "%s%s", color_reset, color);
@@ -474,11 +474,12 @@ static struct userdiff_driver section_headers = {
},
};
-static struct diff_filespec *get_filespec(const char *name, const char *p)
+static struct diff_filespec *get_filespec(const struct git_hash_algo *algop,
+ const char *name, const char *p)
{
struct diff_filespec *spec = alloc_filespec(name);
- fill_filespec(spec, null_oid(the_hash_algo), 0, 0100644);
+ fill_filespec(spec, null_oid(algop), 0, 0100644);
spec->data = (char *)p;
spec->size = strlen(p);
spec->should_munmap = 0;
@@ -492,7 +493,8 @@ static void patch_diff(const char *a, const char *b,
struct diff_options *diffopt)
{
diff_queue(&diff_queued_diff,
- get_filespec("a", a), get_filespec("b", b));
+ get_filespec(diffopt->repo->hash_algo, "a", a),
+ get_filespec(diffopt->repo->hash_algo, "b", b));
diffcore_std(diffopt);
diff_flush(diffopt);
base-commit: 8d1b215c01512b9658d4525c54ff9b9245f9a7e8
--
2.56.0
Technical Details
Message-ID:
<20261029084720.93221-1-okhuomonajayi54@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-73731-linux-kernel-git=dewy.ruReferences:
<DMGX0XEZIMHC.2P0KB28XC83HV@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-73731-linux-kernel-git=dewy.ru
From: okhuomonajayi54@gmail.com (Okhuomon Ajayi)
Newsgroups: linux.kernel.git
Subject: [Outreachy PATCH v2] range-diff: use diffopt->repo instead of the_repository
Date: Thu, 29 Oct 2026 09:47:20 +0100
Organization: Usenet Network
Message-ID: <20261029084720.93221-1-okhuomonajayi54@gmail.com>
References: <DMGX0XEZIMHC.2P0KB28XC83HV@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="1968105"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:gvo0I4mYPsUoKKrzMsftNjWPfeg= sha256:5K13+2nQBY8/LO6SrCTOCVLbVOcEaC9j90VYYM46JTM=
sha1:wHoogLUN1RFDz42q1sQEfkMvITs= sha256:J8LY+l57PCReplDrUu8aPa3QzlFGcNVKjfnhptU+GtI=
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 5B115125C5F; Thu, 29 Oct 2026 11:47:48 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: 0.41
X-Spam-Status: No, score=0.41 tagged_above=-9999 required=6.31
tests=[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.25, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_SBL_CSS=3.558, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=no 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 4i9k8M9dBx-v;
Thu, 29 Oct 2026 11:47:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=git+bounces-73731-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 1571E125C5C; Thu, 29 Oct 2026 11:47:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id E5C46600D81; Thu, 29 Oct 2026 08:47:34 +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=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1793263654;
b=V+Qi0oOl0hZPTdZF5Y25ZF474/L5kzd/a3ngobgYmJP1ClbCD34r9e1t7EsGTUvSmpxm
aYY4Ly4Bh8cxbW/gyTzDCD29uR+muAK9TsRzS0rYkeaUZtgCXOFlcqbPjdQE5IuPk5gwW
W55k5hOfkIFrruGKVPfMM0UtGoJBxRAEpJNIKp8u4zPbNL55Ts2wkcf+R46VVy9npVGAc
jub8byziN5EGc5s/hzs3R4he3jSxx9CM2ckA50rrr04di8qAck77jgxElJv7Ah+lxcfes
bpWkS9SCVKZvySx/Hp6x98ke2w1PeIHkKtrwlHgpO2gfxFhNQD7q00A9Ev7uOsy5NTg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793263654;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=UvVIj/GEso0iryFfXYFozMmzig3zR4VR+dAnmELJhfI=;
b=MnoV7jc9MsKZcb6/zYwW4Iks0Q53W7nIwRZ618V6ULm5QsZSPBfWrTRAP6iLwxyRHNFz
Qb/QQYGS+b5c4NA+RXAmiv9kU2roZPkFhq/6gd2SRkbYQXpeBUQtfXN5ttRDJ9HYp2mso
6INEk8ch3hxQU+Fhd2WjDhK/0rlX1u95ZdGOd74zt6y7LncEiEgr//StLKCeb19qt33UZ
g6Sshgz+AZEDw1Uv272o9kly9kUfI0QSjY+ARKiNP3Mdkl2kOIT5sgyMVMDjJA48zHKjm
1TTxOsFRVvXadMDf5qK0iMg3WWTPyUydyHXpsDk2MuDf+SFIXVAIKQ97sxvl6BepxqA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=03NvegJi;
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 4F3FC606A324;
Thu, 29 Oct 2026 08:47:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=03NvegJi
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.48
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1793263653;
b=ORRcWot8YEHpWMbB7AylFGGKQO40zy9rZOk6QIouclL0kvEz52QsdyfRx7hvhN/7g22Z
2dShRjQaPSh98ypDc1VxR1c5rkYYJgAzdt5QPDBtxag+uyEo1T1hPVhysBeVAzUVW0BCm
GRdaeMh0ga98ZtM9rhOlsg0qnouAB7FFLpNuIGz/X7Cx3dv2AT2YaWgoI3ETiaK+oAsm0
ZKx5RelknLy9x8BcC30Sfl2bUmNvmBkUIYUS1iDwaZtT5qtlHSGxbL01PcjUoG/1PPAqq
5N614pIbjs6npdq33OxsNcaJ4ksk/OKA0iWoNK63nPFRMnxRlz1JKg1VywUZH++F4gA==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1793263653;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=UvVIj/GEso0iryFfXYFozMmzig3zR4VR+dAnmELJhfI=;
b=IQH0oe1xGAdMPbmEOP36qHu1bPLF8rGFgnvCVhj5uIF2OEfGzIWL9lV8uQWxsyiCTe0C
CAqS3QwEih5Wn/599VReFMUD+xuxCmGUJo58zdQUXyK6/jR4QPgdekPAcuoVmzliC9Si2
+nlpA6vDf208zqru9GRkhlUkfVM5po+T/z9wAK0pmzxzGyYGImW2MThghCIY0tb8suu+R
/doWzwhLBC+KegMnb7H1ZzAQiU2wtfCsoTVNY8t35S1B1d/24MUWTnL0iyrK10Pekex4m
92Nk95H5E/+jZil9g2J7DI+4szapNuvGqN2wO8KGhviDNKpalOZwS4pf85UvB3QmESQ==
X-ARC-Authentication-Results: i=1; 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=03NvegJi;
arc=none smtp.remote-ip=209.85.128.48
X-Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.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 1840C606A32D
for <git@vger.kernel.org>; Thu, 29 Oct 2026 08:47:32 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1840C606A32D
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-wm1-f48.google.com with SMTP id 5b1f17b1804b1-4a2153c8525so13667295e9.3
for <git@vger.kernel.org>; Thu, 29 Oct 2026 01:47:32 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793263651; x=1793868451; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=UvVIj/GEso0iryFfXYFozMmzig3zR4VR+dAnmELJhfI=;
b=03NvegJiGbgeogEnA1H80d3VaaMUBP1ulob1I7sbrLWj7rrCfHSbwSBd/I/5LZj6vi
BWewuqfei/BPiSOdG/w9c6hI7oSzfH/lp+NLauXqi5Xv+cMqvnXRMDHGgNh/r6YwQHth
YvqjjrcaGskXQWYk/cMS2hJzUEIMdubeHjQ0kfaEIN1+zcvQz/35tFgJnT1070ILphYb
CzXhSvQQbIr5SSy6DWrhE0YUn8gU0MBko9c/H7Lwm7qYySm8yE1Ll1Di7J81xk/oiml3
ChilscHXOYkt/xOfeghItdora51lEBHiE3VmGPUR5pNePVrwHB7AiQ1M84MaAD8+ESS1
/vMA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793263651; x=1793868451;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=UvVIj/GEso0iryFfXYFozMmzig3zR4VR+dAnmELJhfI=;
b=mtS6j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lwRXEoB0VnfWxkajt
QBKDShWWEu4glFM3iKFN3cly1j1cAXptKNg5DB5iemzga6g7XKyhae3ekQolnZTtgh38sDSZ8d1
zXawcwJMMOdEhrtVFwMoee+jy9dgTYks/SxNGjrXjCspcPYrAfnqcTryjfXJcHIoPPuJ46H+0Rv
v9fREOF4MqPsHx4/cEC9PT2Z3/bv4z68pJ723i8+sJzv9yhEKQupQ=
X-Received: by 2002:a05:600c:524c:b0:4a4:7a8d:c736 with SMTP id 5b1f17b1804b1-4a9661ab662mr111401355e9.9.1793263651284;
Thu, 29 Oct 2026 01:47:31 -0700 (PDT)
X-Received: from localhost.localdomain ([102.88.166.203])
by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4aa7f41895fsm44007955e9.5.2026.10.29.01.47.29
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Thu, 29 Oct 2026 01:47:30 -0700 (PDT)
X-Cc: pabloosabaterr@gmail.com,
christian.couder@gmail.com,
usmanakinyemi202@gmail.com,
siddharthasthana31@gmail.com,
kaartic.sivaraam@gmail.com,
Okhuomon Ajayi <okhuomonajayi54@gmail.com>
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <DMGX0XEZIMHC.2P0KB28XC83HV@gmail.com>
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