🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.git
6 messages
6 total messages Started by Okhuomon Ajayi Sat, 17 Oct 2026 10:52
[Outreachy PATCH] merge-blobs: stop using the_repository
#732
Author: Okhuomon Ajayi
Date: Sat, 17 Oct 2026 10:52
64 lines
9607 bytes
merge_blobs() already has the repository through istate.
Pass it to fill_mmfile_blob() and use it when reading objects.

Remove the USE_THE_REPOSITORY_VARIABLE definition and
include the headers needed for the structure definitions.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 merge-blobs.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/merge-blobs.c b/merge-blobs.c
index 49dbec9529..1b0621c814 100644
--- a/merge-blobs.c
+++ b/merge-blobs.c
@@ -1,18 +1,19 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "git-compat-util.h"
 #include "merge-ll.h"
 #include "blob.h"
 #include "merge-blobs.h"
 #include "odb.h"
+#include "read-cache-ll.h"
+#include "repository.h"
 
-static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
+static int fill_mmfile_blob(struct repository *r, mmfile_t *f,
+			    struct blob *obj)
 {
 	void *buf;
 	size_t size;
 	enum object_type type;
 
-	buf = odb_read_object(the_repository->objects, &obj->object.oid,
+	buf = odb_read_object(r->objects, &obj->object.oid,
 			      &type, &size);
 	if (!buf)
 		return -1;
@@ -79,17 +80,17 @@ void *merge_blobs(struct index_state *istate, const char *path,
 			return NULL;
 		if (!our)
 			our = their;
-		return odb_read_object(the_repository->objects, &our->object.oid,
+		return odb_read_object(istate->repo->objects, &our->object.oid,
 				       &type, size);
 	}
 
-	if (fill_mmfile_blob(&f1, our) < 0)
+	if (fill_mmfile_blob(istate->repo, &f1, our) < 0)
 		goto out_no_mmfile;
-	if (fill_mmfile_blob(&f2, their) < 0)
+	if (fill_mmfile_blob(istate->repo, &f2, their) < 0)
 		goto out_free_f1;
 
 	if (base) {
-		if (fill_mmfile_blob(&common, base) < 0)
+		if (fill_mmfile_blob(istate->repo, &common, base) < 0)
 			goto out_free_f2_f1;
 	} else {
 		common.ptr = xstrdup("");
-- 
2.54.0
Re: [Outreachy PATCH] merge-blobs: stop using the_repository
#926
Author: Usman Akinyemi
Date: Tue, 20 Oct 2026 16:53
76 lines
14007 bytes
>
> merge_blobs() already has the repository through istate.
> Pass it to fill_mmfile_blob() and use it when reading objects.
>
> Remove the USE_THE_REPOSITORY_VARIABLE definition and
> include the headers needed for the structure definitions.
>
> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
> ---
Good.
>  merge-blobs.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/merge-blobs.c b/merge-blobs.c
> index 49dbec9529..1b0621c814 100644
> --- a/merge-blobs.c
> +++ b/merge-blobs.c
> @@ -1,18 +1,19 @@
> -#define USE_THE_REPOSITORY_VARIABLE
> -
>  #include "git-compat-util.h"
>  #include "merge-ll.h"
>  #include "blob.h"
>  #include "merge-blobs.h"
>  #include "odb.h"
> +#include "read-cache-ll.h"
> +#include "repository.h"
>
> -static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
> +static int fill_mmfile_blob(struct repository *r, mmfile_t *f,
> +                           struct blob *obj)

Is there a reason why the repo variable is named "r" instead of repo ?

"repo" seems more "descriptive" than "r". if there is no reason, let's change
it to "repo" from "r"

>  {
>         void *buf;
>         size_t size;
>         enum object_type type;
>
> -       buf = odb_read_object(the_repository->objects, &obj->object.oid,
> +       buf = odb_read_object(r->objects, &obj->object.oid,
>                               &type, &size);
this r->objects will become repo->objects
>         if (!buf)
>                 return -1;
> @@ -79,17 +80,17 @@ void *merge_blobs(struct index_state *istate, const char *path,
>                         return NULL;
>                 if (!our)
>                         our = their;
> -               return odb_read_object(the_repository->objects, &our->object.oid,
> +               return odb_read_object(istate->repo->objects, &our->object.oid,
>                                        &type, size);
>         }
>
> -       if (fill_mmfile_blob(&f1, our) < 0)
> +       if (fill_mmfile_blob(istate->repo, &f1, our) < 0)
>                 goto out_no_mmfile;
> -       if (fill_mmfile_blob(&f2, their) < 0)
> +       if (fill_mmfile_blob(istate->repo, &f2, their) < 0)
>                 goto out_free_f1;
>
>         if (base) {
> -               if (fill_mmfile_blob(&common, base) < 0)
> +               if (fill_mmfile_blob(istate->repo, &common, base) < 0)
>                         goto out_free_f2_f1;
>         } else {
>                 common.ptr = xstrdup("");
> --
apart from the nit about r vs repo this looks good.
> 2.54.0
>
Thanks.
Re: [Outreachy PATCH] merge-blobs: stop using the_repository
#963
Author: Okhuomon Ajayi
Date: Tue, 20 Oct 2026 21:41
14 lines
12295 bytes
On Tue, Oct 20, 2026 at 5:53 PM Usman Akinyemi
<usmanakinyemi202@gmail.com> wrote:

> Is there a reason why the repo variable is named "r" instead of repo ?
>
> "repo" seems more "descriptive" than "r". if there is no reason, let's change
> it to "repo" from "r"
Thanks for the review.
There is no particular reason. I studied some files and saw it written
as "r", but I will change it to "repo" in v2 so it is more
descriptive, as you said.
Okhuomon
Re: [Outreachy PATCH] merge-blobs: stop using the_repository
#964
Author: Junio C Hamano
Date: Tue, 20 Oct 2026 21:54
20 lines
13462 bytes
Usman Akinyemi <usmanakinyemi202@gmail.com> writes:

>> +static int fill_mmfile_blob(struct repository *r, mmfile_t *f,
>> +                           struct blob *obj)
>
> Is there a reason why the repo variable is named "r" instead of repo ?
>
> "repo" seems more "descriptive" than "r". if there is no reason, let's change
> it to "repo" from "r"

Is that really needed?

I thought that we already use short-and-sweet "r" elsewhere, and it
is expected we will have many more functions that take "struct
repository *" as the first parameter as the libification stuff goes
further, so if we consistently say "r", that would be just familiar
and descriptive as "repository" to our developers, without risking
to make readers wonder what "repo" stands for, things other than
"repository", like "reposses" ;-).
Re: [Outreachy PATCH] merge-blobs: stop using the_repository
#969
Author: Usman Akinyemi
Date: Tue, 20 Oct 2026 22:16
19 lines
12436 bytes
>
> Is that really needed?
>
> I thought that we already use short-and-sweet "r" elsewhere, and it
> is expected we will have many more functions that take "struct
> repository *" as the first parameter as the libification stuff goes
> further, so if we consistently say "r", that would be just familiar
> and descriptive as "repository" to our developers, without risking
> to make readers wonder what "repo" stands for, things other than
> "repository", like "reposses" ;-).

We also have "repo" used in some places, we might want to pick one, but
I do not think it is a big issue.

Since, there instances of "r"  Okhuomon does not have to send a new patch
for changing the variable name then.

Thanks.
Re: [Outreachy PATCH] merge-blobs: stop using the_repository
#2564
Author: Junio C Hamano
Date: Sat, 07 Nov 2026 02:30
31 lines
13853 bytes
Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:

> merge_blobs() already has the repository through istate.
> Pass it to fill_mmfile_blob() and use it when reading objects.
>
> Remove the USE_THE_REPOSITORY_VARIABLE definition and
> include the headers needed for the structure definitions.
>
> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
> ---
>  merge-blobs.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)

Even though I would have introduced a single repo variable instead
of dereferencing istate->repo number of times inside merge_blobs()
function, that probably falls into personal preference category, so
insignificant a difference that once code is written in one way, it
is not worth going in and rewrite into the other way.

Let's mark the topic as ready for 'next'.  Thanks.

> -		return odb_read_object(the_repository->objects, &our->object.oid,
> +		return odb_read_object(istate->repo->objects, &our->object.oid,
> -	if (fill_mmfile_blob(&f1, our) < 0)
> +	if (fill_mmfile_blob(istate->repo, &f1, our) < 0)
>  		goto out_no_mmfile;
> -	if (fill_mmfile_blob(&f2, their) < 0)
> +	if (fill_mmfile_blob(istate->repo, &f2, their) < 0)
> -		if (fill_mmfile_blob(&common, base) < 0)
> +		if (fill_mmfile_blob(istate->repo, &common, base) < 0)
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