From: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, usmanakinyemi202@gmail.com,
siddharthasthana31@gmail.com, kaartic.sivaraam@gmail.com,
Okhuomon Ajayi <okhuomonajayi54@gmail.com>
Subject: [Outreachy PATCH] range-diff: use the repository from the diff options
Date: Wed, 28 Oct 2026 22:51:37 +0100 [thread overview]
Message-ID: <20261028215137.15262-1-okhuomonajayi54@gmail.com> (raw)
output_pair_header() and patch_diff() already receive the diff
options, but use the_repository and the_hash_algo. Use the
repository from diffopt instead, and pass only the hash algorithm
to get_filespec(), as that is all it needs.
read_patches(), output() and is_range_diff_range() still use
the_repository, so USE_THE_REPOSITORY_VARIABLE stays.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
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
next reply other threads:[~2026-10-28 21:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-28 21:51 Okhuomon Ajayi [this message]
2026-10-29 1:02 ` [Outreachy PATCH] range-diff: use the repository from the diff options Pablo Sabater
2026-10-29 8:47 ` [Outreachy PATCH v2] range-diff: use diffopt->repo instead of the_repository Okhuomon Ajayi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261028215137.15262-1-okhuomonajayi54@gmail.com \
--to=okhuomonajayi54@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=kaartic.sivaraam@gmail.com \
--cc=siddharthasthana31@gmail.com \
--cc=usmanakinyemi202@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox