🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
3 messages
3 total messages Started by Okhuomon Ajayi Mon, 26 Oct 2026 11:13
[Outreachy PATCH] combine-diff: use the repository from diff options
#1506
Author: Okhuomon Ajayi
Date: Mon, 26 Oct 2026 11:13
65 lines
13287 bytes
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
Re: [Outreachy PATCH] combine-diff: use the repository from diff options
#4104
Author: Christian Couder
Date: Mon, 30 Nov 2026 10:19
58 lines
13968 bytes
Hi Okhuomon,



On Mon, Oct 26, 2026 at 12:13 PM Okhuomon Ajayi
<okhuomonajayi54@gmail.com> wrote:
>
> 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.

Sorry, this patch might have fallen into the cracks.

> @@ -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))) {

Below this there is:

                } else if (0 <= (fd = open(elem->path, O_RDONLY))) {
                        size_t len = xsize_t(st.st_size);
                        ssize_t done;
                        int is_file, i;

                        elem->mode = canon_mode(st.st_mode);
                        /* if symlinks don't work, assume symlink if all parents
                         * are symlinks
                         */
                        is_file = repo_has_symlinks(rev->repo);

So `rev->repo` seems to already be used in one of these functions.

It would be more consistent to use either `rev->repo` or `opt->repo`
everywhere in these functions rather than mixing both.

If there is a reason (like consistency with other functions in this
file) to use one over the other, the commit message might want to
explain it.

Thanks.
Re: [Outreachy PATCH] combine-diff: use the repository from diff options
#4105
Author: Okhuomon Ajayi
Date: Mon, 30 Nov 2026 10:38
87 lines
15062 bytes
Hi Christian,

On Mon, Nov 30, 2026 at 11:19 AM Christian Couder
<christian.couder@gmail.com> wrote:
>
> Sorry, this patch might have fallen into the cracks.

No worries, thanks for coming back to it.

> So `rev->repo` seems to already be used in one of these functions.
>
> It would be more consistent to use either `rev->repo` or `opt->repo`
> everywhere in these functions rather than mixing both.

Agreed. opt->repo is already what the rest of combine-diff.c uses:
show_combined_header() and the other grab_blob() calls in
show_patch_diff() all go through opt->repo, and rev->repo appears only
in the repo_has_symlinks() call just below my change. I'll convert that
call to opt->repo as well in v2 so show_patch_diff() uses opt->repo
throughout, instead of leaving the two mixed.

Thanks,
Okhuomon

On Mon, Nov 30, 2026 at 11:19 AM Christian Couder
<christian.couder@gmail.com> wrote:
>
> Hi Okhuomon,
>
>
>
> On Mon, Oct 26, 2026 at 12:13 PM Okhuomon Ajayi
> <okhuomonajayi54@gmail.com> wrote:
> >
> > 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.
>
> Sorry, this patch might have fallen into the cracks.
>
> > @@ -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))) {
>
> Below this there is:
>
>                 } else if (0 <= (fd = open(elem->path, O_RDONLY))) {
>                         size_t len = xsize_t(st.st_size);
>                         ssize_t done;
>                         int is_file, i;
>
>                         elem->mode = canon_mode(st.st_mode);
>                         /* if symlinks don't work, assume symlink if all parents
>                          * are symlinks
>                          */
>                         is_file = repo_has_symlinks(rev->repo);
>
> So `rev->repo` seems to already be used in one of these functions.
>
> It would be more consistent to use either `rev->repo` or `opt->repo`
> everywhere in these functions rather than mixing both.
>
> If there is a reason (like consistency with other functions in this
> file) to use one over the other, the commit message might want to
> explain it.
>
> Thanks.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads