{"thread":{"id":"66663","subject":"[Outreachy PATCH] combine-diff: use the repository from diff options","startedAt":"2026-10-26T11:13:03Z","lastAt":"2026-10-26T11:13:03Z","messageCount":1,"participants":["Okhuomon Ajayi"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556314","messageId":"20261026111303.92117-1-okhuomonajayi54@gmail.com","threadId":"66663","inReplyTo":null,"subject":"[Outreachy PATCH] combine-diff: use the repository from diff options","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-26T11:13:03Z","receivedAt":"2026-10-26T11:13:03Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"show_combined_header() and show_patch_diff() already have the\nrepository through opt->repo, but still used the_repository for\nthe hash algorithm, abbreviating object names and resolving\ngitlinks. Use opt->repo instead.\n\nThe file still needs USE_THE_REPOSITORY_VARIABLE for\nDEFAULT_ABBREV, which refers to the global default_abbrev.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n combine-diff.c | 12 +++++++-----\n 1 file changed, 7 insertions(+), 5 deletions(-)\n\ndiff --git a/combine-diff.c b/combine-diff.c\nindex 717d537688..9e7b05e6f8 100644\n--- a/combine-diff.c\n+++ b/combine-diff.c\n@@ -927,7 +927,8 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t\t int show_file_header)\n {\n \tstruct diff_options *opt = &rev->diffopt;\n-\tint abbrev = opt->flags.full_index ? the_hash_algo->hexsz : DEFAULT_ABBREV;\n+\tint abbrev = opt->flags.full_index ? opt->repo->hash_algo->hexsz\n+\t\t\t\t\t   : DEFAULT_ABBREV;\n \tconst char *a_prefix = opt->a_prefix ? opt->a_prefix : \"a/\";\n \tconst char *b_prefix = opt->b_prefix ? opt->b_prefix : \"b/\";\n \tconst char *c_meta = diff_get_color_opt(opt, DIFF_METAINFO);\n@@ -945,11 +946,11 @@ static void show_combined_header(struct combine_diff_path *elem,\n \t\t\t \"\", elem->path, line_prefix, c_meta, c_reset);\n \tprintf(\"%s%sindex \", line_prefix, c_meta);\n \tfor (i = 0; i < num_parent; i++) {\n-\t\tabb = repo_find_unique_abbrev(the_repository,\n+\t\tabb = repo_find_unique_abbrev(opt->repo,\n \t\t\t\t\t      &elem->parent[i].oid, abbrev);\n \t\tprintf(\"%s%s\", i ? \",\" : \"\", abb);\n \t}\n-\tabb = repo_find_unique_abbrev(the_repository, &elem->oid, abbrev);\n+\tabb = repo_find_unique_abbrev(opt->repo, &elem->oid, abbrev);\n \tprintf(\"..%s%s\\n\", abb, c_reset);\n \n \tif (mode_differs) {\n@@ -1058,7 +1059,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\telem->mode = canon_mode(st.st_mode);\n \t\t} else if (S_ISDIR(st.st_mode)) {\n \t\t\tstruct object_id oid;\n-\t\t\tif (repo_resolve_gitlink_ref(the_repository, elem->path,\n+\t\t\tif (repo_resolve_gitlink_ref(opt->repo, elem->path,\n \t\t\t\t\t\t     \"HEAD\", &oid) < 0)\n \t\t\t\tresult = grab_blob(opt->repo, &elem->oid,\n \t\t\t\t\t\t   elem->mode, &result_size,\n@@ -1068,7 +1069,8 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,\n \t\t\t\t\t\t   &result_size, NULL, NULL);\n \t\t} else if (textconv) {\n \t\t\tstruct diff_filespec *df = alloc_filespec(elem->path);\n-\t\t\tfill_filespec(df, null_oid(the_hash_algo), 0, st.st_mode);\n+\t\t\tfill_filespec(df, null_oid(opt->repo->hash_algo),\n+\t\t\t\t      0, st.st_mode);\n \t\t\tresult_size = fill_textconv(opt->repo, textconv, df, &result);\n \t\t\tfree_filespec(df);\n \t\t} else if (0 <= (fd = open(elem->path, O_RDONLY))) {\n\nbase-commit: 7e34d8174dcda3435d1404c9a30bef46afe6c13e\n-- \n2.56.0\n\n\n"}]}