{"thread":{"id":"66566","subject":"[Outreachy PATCH] merge-blobs: stop using the_repository","startedAt":"2026-10-17T10:52:43Z","lastAt":"2026-11-07T02:30:15Z","messageCount":6,"participants":["Okhuomon Ajayi","Usman Akinyemi","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"555315","messageId":"20261017105244.90295-1-okhuomonajayi54@gmail.com","threadId":"66566","inReplyTo":null,"subject":"[Outreachy PATCH] merge-blobs: stop using the_repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-17T10:52:43Z","receivedAt":"2026-10-17T10:52:43Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"merge_blobs() already has the repository through istate.\nPass it to fill_mmfile_blob() and use it when reading objects.\n\nRemove the USE_THE_REPOSITORY_VARIABLE definition and\ninclude the headers needed for the structure definitions.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n merge-blobs.c | 17 +++++++++--------\n 1 file changed, 9 insertions(+), 8 deletions(-)\n\ndiff --git a/merge-blobs.c b/merge-blobs.c\nindex 49dbec9529..1b0621c814 100644\n--- a/merge-blobs.c\n+++ b/merge-blobs.c\n@@ -1,18 +1,19 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"merge-ll.h\"\n #include \"blob.h\"\n #include \"merge-blobs.h\"\n #include \"odb.h\"\n+#include \"read-cache-ll.h\"\n+#include \"repository.h\"\n \n-static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n+static int fill_mmfile_blob(struct repository *r, mmfile_t *f,\n+\t\t\t    struct blob *obj)\n {\n \tvoid *buf;\n \tsize_t size;\n \tenum object_type type;\n \n-\tbuf = odb_read_object(the_repository->objects, &obj->object.oid,\n+\tbuf = odb_read_object(r->objects, &obj->object.oid,\n \t\t\t      &type, &size);\n \tif (!buf)\n \t\treturn -1;\n@@ -79,17 +80,17 @@ void *merge_blobs(struct index_state *istate, const char *path,\n \t\t\treturn NULL;\n \t\tif (!our)\n \t\t\tour = their;\n-\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n+\t\treturn odb_read_object(istate->repo->objects, &our->object.oid,\n \t\t\t\t       &type, size);\n \t}\n \n-\tif (fill_mmfile_blob(&f1, our) < 0)\n+\tif (fill_mmfile_blob(istate->repo, &f1, our) < 0)\n \t\tgoto out_no_mmfile;\n-\tif (fill_mmfile_blob(&f2, their) < 0)\n+\tif (fill_mmfile_blob(istate->repo, &f2, their) < 0)\n \t\tgoto out_free_f1;\n \n \tif (base) {\n-\t\tif (fill_mmfile_blob(&common, base) < 0)\n+\t\tif (fill_mmfile_blob(istate->repo, &common, base) < 0)\n \t\t\tgoto out_free_f2_f1;\n \t} else {\n \t\tcommon.ptr = xstrdup(\"\");\n-- \n2.54.0\n\n\n"},{"id":"555582","messageId":"CAPSxiM-OyrVEzYgja0nwa8PikfU1WpsCYbiNiXpcxb4TM4=mOA@mail.gmail.com","threadId":"66566","inReplyTo":"20261017105244.90295-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH] merge-blobs: stop using the_repository","fromName":"Usman Akinyemi","fromEmail":"usmanakinyemi202@gmail.com","sentAt":"2026-10-20T16:53:02Z","receivedAt":"2026-10-20T16:53:02Z","isPatch":true,"sender":{"key":"usmanakinyemi202@gmail.com","avatar":"https://avatars.githubusercontent.com/u/86585626?v=4"},"body":">\n> merge_blobs() already has the repository through istate.\n> Pass it to fill_mmfile_blob() and use it when reading objects.\n>\n> Remove the USE_THE_REPOSITORY_VARIABLE definition and\n> include the headers needed for the structure definitions.\n>\n> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n> ---\nGood.\n>  merge-blobs.c | 17 +++++++++--------\n>  1 file changed, 9 insertions(+), 8 deletions(-)\n>\n> diff --git a/merge-blobs.c b/merge-blobs.c\n> index 49dbec9529..1b0621c814 100644\n> --- a/merge-blobs.c\n> +++ b/merge-blobs.c\n> @@ -1,18 +1,19 @@\n> -#define USE_THE_REPOSITORY_VARIABLE\n> -\n>  #include \"git-compat-util.h\"\n>  #include \"merge-ll.h\"\n>  #include \"blob.h\"\n>  #include \"merge-blobs.h\"\n>  #include \"odb.h\"\n> +#include \"read-cache-ll.h\"\n> +#include \"repository.h\"\n>\n> -static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)\n> +static int fill_mmfile_blob(struct repository *r, mmfile_t *f,\n> +                           struct blob *obj)\n\nIs there a reason why the repo variable is named \"r\" instead of repo ?\n\n\"repo\" seems more \"descriptive\" than \"r\". if there is no reason, let's change\nit to \"repo\" from \"r\"\n\n>  {\n>         void *buf;\n>         size_t size;\n>         enum object_type type;\n>\n> -       buf = odb_read_object(the_repository->objects, &obj->object.oid,\n> +       buf = odb_read_object(r->objects, &obj->object.oid,\n>                               &type, &size);\nthis r->objects will become repo->objects\n>         if (!buf)\n>                 return -1;\n> @@ -79,17 +80,17 @@ void *merge_blobs(struct index_state *istate, const char *path,\n>                         return NULL;\n>                 if (!our)\n>                         our = their;\n> -               return odb_read_object(the_repository->objects, &our->object.oid,\n> +               return odb_read_object(istate->repo->objects, &our->object.oid,\n>                                        &type, size);\n>         }\n>\n> -       if (fill_mmfile_blob(&f1, our) < 0)\n> +       if (fill_mmfile_blob(istate->repo, &f1, our) < 0)\n>                 goto out_no_mmfile;\n> -       if (fill_mmfile_blob(&f2, their) < 0)\n> +       if (fill_mmfile_blob(istate->repo, &f2, their) < 0)\n>                 goto out_free_f1;\n>\n>         if (base) {\n> -               if (fill_mmfile_blob(&common, base) < 0)\n> +               if (fill_mmfile_blob(istate->repo, &common, base) < 0)\n>                         goto out_free_f2_f1;\n>         } else {\n>                 common.ptr = xstrdup(\"\");\n> --\napart from the nit about r vs repo this looks good.\n> 2.54.0\n>\nThanks.\n\n"},{"id":"555627","messageId":"CAFpMFfA1yMJO8=UX92+_x=Bi2CCUVT5rw7gEFqH-DfdNSsjevg@mail.gmail.com","threadId":"66566","inReplyTo":"CAPSxiM-OyrVEzYgja0nwa8PikfU1WpsCYbiNiXpcxb4TM4=mOA@mail.gmail.com","subject":"Re: [Outreachy PATCH] merge-blobs: stop using the_repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-20T21:41:01Z","receivedAt":"2026-10-20T21:41:01Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"On Tue, Oct 20, 2026 at 5:53 PM Usman Akinyemi\n<usmanakinyemi202@gmail.com> wrote:\n\n> Is there a reason why the repo variable is named \"r\" instead of repo ?\n>\n> \"repo\" seems more \"descriptive\" than \"r\". if there is no reason, let's change\n> it to \"repo\" from \"r\"\nThanks for the review.\nThere is no particular reason. I studied some files and saw it written\nas \"r\", but I will change it to \"repo\" in v2 so it is more\ndescriptive, as you said.\nOkhuomon\n\n"},{"id":"555628","messageId":"xmqqwlrcrqaz.fsf@gitster.g","threadId":"66566","inReplyTo":"CAPSxiM-OyrVEzYgja0nwa8PikfU1WpsCYbiNiXpcxb4TM4=mOA@mail.gmail.com","subject":"Re: [Outreachy PATCH] merge-blobs: stop using the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-20T21:54:28Z","receivedAt":"2026-10-20T21:54:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Usman Akinyemi <usmanakinyemi202@gmail.com> writes:\n\n>> +static int fill_mmfile_blob(struct repository *r, mmfile_t *f,\n>> +                           struct blob *obj)\n>\n> Is there a reason why the repo variable is named \"r\" instead of repo ?\n>\n> \"repo\" seems more \"descriptive\" than \"r\". if there is no reason, let's change\n> it to \"repo\" from \"r\"\n\nIs that really needed?\n\nI thought that we already use short-and-sweet \"r\" elsewhere, and it\nis expected we will have many more functions that take \"struct\nrepository *\" as the first parameter as the libification stuff goes\nfurther, so if we consistently say \"r\", that would be just familiar\nand descriptive as \"repository\" to our developers, without risking\nto make readers wonder what \"repo\" stands for, things other than\n\"repository\", like \"reposses\" ;-).\n\n"},{"id":"555633","messageId":"CAPSxiM-8Uuj5HMDbz_Mow6gYfUkYTiPVVc+Uc0qQbVYD9jjrYA@mail.gmail.com","threadId":"66566","inReplyTo":"xmqqwlrcrqaz.fsf@gitster.g","subject":"Re: [Outreachy PATCH] merge-blobs: stop using the_repository","fromName":"Usman Akinyemi","fromEmail":"usmanakinyemi202@gmail.com","sentAt":"2026-10-20T22:16:09Z","receivedAt":"2026-10-20T22:16:09Z","isPatch":true,"sender":{"key":"usmanakinyemi202@gmail.com","avatar":"https://avatars.githubusercontent.com/u/86585626?v=4"},"body":">\n> Is that really needed?\n>\n> I thought that we already use short-and-sweet \"r\" elsewhere, and it\n> is expected we will have many more functions that take \"struct\n> repository *\" as the first parameter as the libification stuff goes\n> further, so if we consistently say \"r\", that would be just familiar\n> and descriptive as \"repository\" to our developers, without risking\n> to make readers wonder what \"repo\" stands for, things other than\n> \"repository\", like \"reposses\" ;-).\n\nWe also have \"repo\" used in some places, we might want to pick one, but\nI do not think it is a big issue.\n\nSince, there instances of \"r\"  Okhuomon does not have to send a new patch\nfor changing the variable name then.\n\nThanks.\n\n"},{"id":"557756","messageId":"xmqqy0b59xvs.fsf@gitster.g","threadId":"66566","inReplyTo":"20261017105244.90295-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH] merge-blobs: stop using the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-07T02:30:15Z","receivedAt":"2026-11-07T02:30:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n\n> merge_blobs() already has the repository through istate.\n> Pass it to fill_mmfile_blob() and use it when reading objects.\n>\n> Remove the USE_THE_REPOSITORY_VARIABLE definition and\n> include the headers needed for the structure definitions.\n>\n> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n> ---\n>  merge-blobs.c | 17 +++++++++--------\n>  1 file changed, 9 insertions(+), 8 deletions(-)\n\nEven though I would have introduced a single repo variable instead\nof dereferencing istate->repo number of times inside merge_blobs()\nfunction, that probably falls into personal preference category, so\ninsignificant a difference that once code is written in one way, it\nis not worth going in and rewrite into the other way.\n\nLet's mark the topic as ready for 'next'.  Thanks.\n\n> -\t\treturn odb_read_object(the_repository->objects, &our->object.oid,\n> +\t\treturn odb_read_object(istate->repo->objects, &our->object.oid,\n> -\tif (fill_mmfile_blob(&f1, our) < 0)\n> +\tif (fill_mmfile_blob(istate->repo, &f1, our) < 0)\n>  \t\tgoto out_no_mmfile;\n> -\tif (fill_mmfile_blob(&f2, their) < 0)\n> +\tif (fill_mmfile_blob(istate->repo, &f2, their) < 0)\n> -\t\tif (fill_mmfile_blob(&common, base) < 0)\n> +\t\tif (fill_mmfile_blob(istate->repo, &common, base) < 0)\n\n"}]}