# [Outreachy PATCH] combine-diff: use the repository from diff options

1 messages from 2026-10-26 to 2026-10-26. Participants: Okhuomon Ajayi.
Thread: https://gitlist.dev/t/66663

## Okhuomon Ajayi, 2026-10-26 11:13

Subject: [Outreachy PATCH] combine-diff: use the repository from diff options
Message-ID: <20261026111303.92117-1-okhuomonajayi54@gmail.com>
URL: https://gitlist.dev/e/20261026111303.92117-1-okhuomonajayi54%40gmail.com

```
show_combined_header() and show_patch_diff() already have the
repository through opt->repo, but still used the_repository for
the hash algorithm, abbreviating object names and resolving
gitlinks. Use opt->repo instead.

The file still needs USE_THE_REPOSITORY_VARIABLE for
DEFAULT_ABBREV, which refers to the global default_abbrev.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 combine-diff.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/combine-diff.c b/combine-diff.c
index 717d537688..9e7b05e6f8 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -927,7 +927,8 @@ static void show_combined_header(struct combine_diff_path *elem,
 				 int show_file_header)
 {
 	struct diff_options *opt = &rev->diffopt;
-	int abbrev = opt->flags.full_index ? the_hash_algo->hexsz : DEFAULT_ABBREV;
+	int abbrev = opt->flags.full_index ? opt->repo->hash_algo->hexsz
+					   : DEFAULT_ABBREV;
 	const char *a_prefix = opt->a_prefix ? opt->a_prefix : "a/";
 	const char *b_prefix = opt->b_prefix ? opt->b_prefix : "b/";
 	const char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);
@@ -945,11 +946,11 @@ static void show_combined_header(struct combine_diff_path *elem,
 			 "", elem->path, line_prefix, c_meta, c_reset);
 	printf("%s%sindex ", line_prefix, c_meta);
 	for (i = 0; i < num_parent; i++) {
-		abb = repo_find_unique_abbrev(the_repository,
+		abb = repo_find_unique_abbrev(opt->repo,
 					      &elem->parent[i].oid, abbrev);
 		printf("%s%s", i ? "," : "", abb);
 	}
-	abb = repo_find_unique_abbrev(the_repository, &elem->oid, abbrev);
+	abb = repo_find_unique_abbrev(opt->repo, &elem->oid, abbrev);
 	printf("..%s%s\n", abb, c_reset);
 
 	if (mode_differs) {
@@ -1058,7 +1059,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 			elem->mode = canon_mode(st.st_mode);
 		} else if (S_ISDIR(st.st_mode)) {
 			struct object_id oid;
-			if (repo_resolve_gitlink_ref(the_repository, elem->path,
+			if (repo_resolve_gitlink_ref(opt->repo, elem->path,
 						     "HEAD", &oid) < 0)
 				result = grab_blob(opt->repo, &elem->oid,
 						   elem->mode, &result_size,
@@ -1068,7 +1069,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
 						   &result_size, NULL, NULL);
 		} else if (textconv) {
 			struct diff_filespec *df = alloc_filespec(elem->path);
-			fill_filespec(df, null_oid(the_hash_algo), 0, st.st_mode);
+			fill_filespec(df, null_oid(opt->repo->hash_algo),
+				      0, st.st_mode);
 			result_size = fill_textconv(opt->repo, textconv, df, &result);
 			free_filespec(df);
 		} else if (0 <= (fd = open(elem->path, O_RDONLY))) {

base-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e
-- 
2.56.0



```
