{"thread":{"id":"65277","subject":"[PATCH] add-patch: use repository instance from add_i_state instead of the_repository","startedAt":"2026-03-17T15:53:35Z","lastAt":"2026-03-18T16:43:06Z","messageCount":9,"participants":["Shreyansh Paliwal","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"539229","messageId":"20260317155230.619378-1-shreyanshpaliwalcmsmn@gmail.com","threadId":"65277","inReplyTo":null,"subject":"[PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Shreyansh Paliwal","fromEmail":"shreyanshpaliwalcmsmn@gmail.com","sentAt":"2026-03-17T15:50:29Z","receivedAt":"2026-03-17T15:53:35Z","isPatch":true,"sender":{"key":"shreyanshpaliwalcmsmn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152720574?v=4"},"body":"Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\nthe_repository even though a repository instance is already available via\nstruct add_i_state s which is defined in struct add_p_state *s.\n\nUse 's->s.r' instead of the_repository to avoid relying on global state. All\ncallers pass a valid add_p_state and this does not change any behavior.\n\nThis aligns with the ongoing effort to reduce usage of the_repository global\nstate.\n\nSigned-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n---\n add-patch.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/add-patch.c b/add-patch.c\nindex 8c03f710d3..30df920723 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -434,8 +434,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n \t\tstrvec_push(&args,\n \t\t\t    /* could be on an unborn branch */\n \t\t\t    !strcmp(\"HEAD\", s->revision) &&\n-\t\t\t    repo_get_oid(the_repository, \"HEAD\", &oid) ?\n-\t\t\t    empty_tree_oid_hex(the_repository->hash_algo) : s->revision);\n+\t\t\t    repo_get_oid(s->s.r, \"HEAD\", &oid) ?\n+\t\t\t    empty_tree_oid_hex(s->s.r->hash_algo) : s->revision);\n \t}\n \tcolor_arg_index = args.nr;\n \t/* Use `--no-color` explicitly, just in case `diff.color = always`. */\n@@ -1147,7 +1147,7 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)\n \t\t\t\t\"removed, then the edit is\\n\"\n \t\t\t\t\"aborted and the hunk is left unchanged.\\n\"));\n\n-\tif (strbuf_edit_interactively(the_repository, &s->buf,\n+\tif (strbuf_edit_interactively(s->s.r, &s->buf,\n \t\t\t\t      \"addp-hunk-edit.diff\", NULL) < 0)\n \t\treturn -1;\n\n@@ -1551,7 +1551,7 @@ static size_t patch_update_file(struct add_p_state *s, size_t idx)\n \t\tif (file_diff->hunk_nr) {\n \t\t\tif (rendered_hunk_index != hunk_index) {\n \t\t\t\tif (use_pager) {\n-\t\t\t\t\tsetup_pager(the_repository);\n+\t\t\t\t\tsetup_pager(s->s.r);\n \t\t\t\t\tsigchain_push(SIGPIPE, SIG_IGN);\n \t\t\t\t}\n \t\t\t\trender_hunk(s, hunk, 0, colored, &s->buf);\n--\n2.53.0\n\n"},{"id":"539239","messageId":"xmqqzf46l7x1.fsf@gitster.g","threadId":"65277","inReplyTo":"20260317155230.619378-1-shreyanshpaliwalcmsmn@gmail.com","subject":"Re: [PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-17T16:47:38Z","receivedAt":"2026-03-17T16:47:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:\n\n> Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\n> the_repository even though a repository instance is already available via\n> struct add_i_state s which is defined in struct add_p_state *s.\n>\n> Use 's->s.r' instead of the_repository to avoid relying on global state. All\n> callers pass a valid add_p_state and this does not change any behavior.\n>\n> This aligns with the ongoing effort to reduce usage of the_repository global\n> state.\n\nSo we can call this \"reduce\" but cannot say \"eliminate\" yet, as the\nfiles uses comment_line_str?\n\nThe <environment.h> header lists some global variables inside\n\"#ifndef USE_THE_REPOSITORY_VARIABLE/#endif\" block, and the\ncomment-line stuff is among them.\n\nThe patch looks correct.  Will queue.  Thanks.\n\n\n> Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n> ---\n>  add-patch.c | 8 ++++----\n>  1 file changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/add-patch.c b/add-patch.c\n> index 8c03f710d3..30df920723 100644\n> --- a/add-patch.c\n> +++ b/add-patch.c\n> @@ -434,8 +434,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n>  \t\tstrvec_push(&args,\n>  \t\t\t    /* could be on an unborn branch */\n>  \t\t\t    !strcmp(\"HEAD\", s->revision) &&\n> -\t\t\t    repo_get_oid(the_repository, \"HEAD\", &oid) ?\n> -\t\t\t    empty_tree_oid_hex(the_repository->hash_algo) : s->revision);\n> +\t\t\t    repo_get_oid(s->s.r, \"HEAD\", &oid) ?\n> +\t\t\t    empty_tree_oid_hex(s->s.r->hash_algo) : s->revision);\n>  \t}\n>  \tcolor_arg_index = args.nr;\n>  \t/* Use `--no-color` explicitly, just in case `diff.color = always`. */\n> @@ -1147,7 +1147,7 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)\n>  \t\t\t\t\"removed, then the edit is\\n\"\n>  \t\t\t\t\"aborted and the hunk is left unchanged.\\n\"));\n>\n> -\tif (strbuf_edit_interactively(the_repository, &s->buf,\n> +\tif (strbuf_edit_interactively(s->s.r, &s->buf,\n>  \t\t\t\t      \"addp-hunk-edit.diff\", NULL) < 0)\n>  \t\treturn -1;\n>\n> @@ -1551,7 +1551,7 @@ static size_t patch_update_file(struct add_p_state *s, size_t idx)\n>  \t\tif (file_diff->hunk_nr) {\n>  \t\t\tif (rendered_hunk_index != hunk_index) {\n>  \t\t\t\tif (use_pager) {\n> -\t\t\t\t\tsetup_pager(the_repository);\n> +\t\t\t\t\tsetup_pager(s->s.r);\n>  \t\t\t\t\tsigchain_push(SIGPIPE, SIG_IGN);\n>  \t\t\t\t}\n>  \t\t\t\trender_hunk(s, hunk, 0, colored, &s->buf);\n> --\n> 2.53.0\n"},{"id":"539240","messageId":"20260317165230.628705-1-shreyanshpaliwalcmsmn@gmail.com","threadId":"65277","inReplyTo":"xmqqzf46l7x1.fsf@gitster.g","subject":"Re: [PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Shreyansh Paliwal","fromEmail":"shreyanshpaliwalcmsmn@gmail.com","sentAt":"2026-03-17T16:51:38Z","receivedAt":"2026-03-17T16:52:41Z","isPatch":true,"sender":{"key":"shreyanshpaliwalcmsmn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152720574?v=4"},"body":"> > Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\n> > the_repository even though a repository instance is already available via\n> > struct add_i_state s which is defined in struct add_p_state *s.\n> >\n> > Use 's->s.r' instead of the_repository to avoid relying on global state. All\n> > callers pass a valid add_p_state and this does not change any behavior.\n> >\n> > This aligns with the ongoing effort to reduce usage of the_repository global\n> > state.\n>\n> So we can call this \"reduce\" but cannot say \"eliminate\" yet, as the\n> files uses comment_line_str?\n>\n> The <environment.h> header lists some global variables inside\n> \"#ifndef USE_THE_REPOSITORY_VARIABLE/#endif\" block, and the\n> comment-line stuff is among them.\n>\n\nYes that's right, there is an instance of comment_line_str, should I add this\nin the commit message and send a reroll ?\n"},{"id":"539246","messageId":"xmqqh5qel4c5.fsf@gitster.g","threadId":"65277","inReplyTo":"20260317165230.628705-1-shreyanshpaliwalcmsmn@gmail.com","subject":"Re: [PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-17T18:04:58Z","receivedAt":"2026-03-17T18:05:00Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:\n\n>> > Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\n>> > the_repository even though a repository instance is already available via\n>> > struct add_i_state s which is defined in struct add_p_state *s.\n>> >\n>> > Use 's->s.r' instead of the_repository to avoid relying on global state. All\n>> > callers pass a valid add_p_state and this does not change any behavior.\n>> >\n>> > This aligns with the ongoing effort to reduce usage of the_repository global\n>> > state.\n>>\n>> So we can call this \"reduce\" but cannot say \"eliminate\" yet, as the\n>> files uses comment_line_str?\n>>\n>> The <environment.h> header lists some global variables inside\n>> \"#ifndef USE_THE_REPOSITORY_VARIABLE/#endif\" block, and the\n>> comment-line stuff is among them.\n>>\n>\n> Yes that's right, there is an instance of comment_line_str, should I add this\n> in the commit message and send a reroll ?\n\nNo need to.  I was just wondering if there are something I missed.\n"},{"id":"539257","messageId":"xmqqse9yjjz9.fsf@gitster.g","threadId":"65277","inReplyTo":"20260317165230.628705-1-shreyanshpaliwalcmsmn@gmail.com","subject":"Re: [PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-17T20:10:02Z","receivedAt":"2026-03-17T20:10:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:\n\n>> > Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\n>> > the_repository even though a repository instance is already available via\n>> > struct add_i_state s which is defined in struct add_p_state *s.\n>> >\n>> > Use 's->s.r' instead of the_repository to avoid relying on global state. All\n>> > callers pass a valid add_p_state and this does not change any behavior.\n>> >\n>> > This aligns with the ongoing effort to reduce usage of the_repository global\n>> > state.\n>>\n>> So we can call this \"reduce\" but cannot say \"eliminate\" yet, as the\n>> files uses comment_line_str?\n>>\n>> The <environment.h> header lists some global variables inside\n>> \"#ifndef USE_THE_REPOSITORY_VARIABLE/#endif\" block, and the\n>> comment-line stuff is among them.\n>>\n>\n> Yes that's right, there is an instance of comment_line_str, should I add this\n> in the commit message and send a reroll ?\n\nHaving said that, please make sure your patch works well with\npatches others are working on.  In this case, s->s.r would no longer\nexist after this one:\n\ncommit d51b61f5dab9c8e715fa792f31d572bc96fb5687\nAuthor: Patrick Steinhardt <ps@pks.im>\nDate:   Mon Mar 2 13:13:07 2026 +0100\n\n    add-patch: remove dependency on \"add-interactive\" subsystem\n    \n    With the preceding commit we have split out interactive configuration\n    that is used by both \"git add -p\" and \"git add -i\". But we still\n    initialize that configuration in the \"add -p\" subsystem by calling\n    `init_add_i_state()`, even though we only do so to initialize the\n    interactive configuration as well as a repository pointer.\n    \n    Stop doing so and instead store and initialize the interactive\n    configuration in `struct add_p_state` directly.\n    \n    Signed-off-by: Patrick Steinhardt <ps@pks.im>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\nA good way to ensure that you do not send a patch that does not work\nwell with others is to make a trial merge to 'next' and 'seen' and\nensure that they produce working Git, after making sure your patch\napplied directly on top of 'master' works well.\n\nThanks.\n"},{"id":"539258","messageId":"xmqqo6kmjj9d.fsf@gitster.g","threadId":"65277","inReplyTo":"xmqqse9yjjz9.fsf@gitster.g","subject":"Re: [PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-17T20:25:34Z","receivedAt":"2026-03-17T20:25:36Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Having said that, please make sure your patch works well with\n> patches others are working on.  In this case, s->s.r would no longer\n> exist after this one:\n>\n> commit d51b61f5dab9c8e715fa792f31d572bc96fb5687\n> Author: Patrick Steinhardt <ps@pks.im>\n> Date:   Mon Mar 2 13:13:07 2026 +0100\n>\n>     add-patch: remove dependency on \"add-interactive\" subsystem\n>     \n>     With the preceding commit we have split out interactive configuration\n>     that is used by both \"git add -p\" and \"git add -i\". But we still\n>     initialize that configuration in the \"add -p\" subsystem by calling\n>     `init_add_i_state()`, even though we only do so to initialize the\n>     interactive configuration as well as a repository pointer.\n>     \n>     Stop doing so and instead store and initialize the interactive\n>     configuration in `struct add_p_state` directly.\n>     \n>     Signed-off-by: Patrick Steinhardt <ps@pks.im>\n>     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n>\n> A good way to ensure that you do not send a patch that does not work\n> well with others is to make a trial merge to 'next' and 'seen' and\n> ensure that they produce working Git, after making sure your patch\n> applied directly on top of 'master' works well.\n\nThe above \"good way\" is to notice and stop yourself from sending a\npatch that wants s->s.r to still exist.\n\nAfter that happens, it is tempting to rebuild your change on top of\n'next'.  But please do *NOT* do so.\n\nInstead, identify such dependencies (i.e. other topics with changes\nrelative to what 'master' has, that break what you developed\ndirectly on top of 'master'), and then merge them to 'master'\nyourself.  And then bulid your topic on top of the merge.  Work hard\nto limit your dependencies to absolute minimum, as these topics will\ntake your work hostage---until they get merged down to 'master',\nyour topic will not be able to be merged to 'master'.\n\nIn this case, you'll be likely to do something like\n\n    $ git checkout -b sp/add-patch-with-fewer-the-repository origin/master\n    $ git merge --no-ff origin/ps-history-split\n    $ edit ... && git add ... && make test\n    $ git commit -m 'add-patch: use repository instance...'\n\nto build your single patch series on top of 'master' taken from my\ntree, with Patrick's history-split topic merged into it.\nAfter the commit is made, send out only your work (i.e., above the\nmerge of Patrick's topic) to the list and you're done.\n\nThanks.\n"},{"id":"539280","messageId":"20260318070237.659845-1-shreyanshpaliwalcmsmn@gmail.com","threadId":"65277","inReplyTo":"xmqqo6kmjj9d.fsf@gitster.g","subject":"Re: [PATCH] add-patch: use repository instance from add_i_state instead of the_repository","fromName":"Shreyansh Paliwal","fromEmail":"shreyanshpaliwalcmsmn@gmail.com","sentAt":"2026-03-18T07:01:20Z","receivedAt":"2026-03-18T07:03:10Z","isPatch":true,"sender":{"key":"shreyanshpaliwalcmsmn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152720574?v=4"},"body":"> Junio C Hamano <gitster@pobox.com> writes:\n>\n> > Having said that, please make sure your patch works well with\n> > patches others are working on.  In this case, s->s.r would no longer\n> > exist after this one:\n> >\n> > commit d51b61f5dab9c8e715fa792f31d572bc96fb5687\n> > Author: Patrick Steinhardt <ps@pks.im>\n> > Date:   Mon Mar 2 13:13:07 2026 +0100\n> >\n> >     add-patch: remove dependency on \"add-interactive\" subsystem\n> >\n> >     With the preceding commit we have split out interactive configuration\n> >     that is used by both \"git add -p\" and \"git add -i\". But we still\n> >     initialize that configuration in the \"add -p\" subsystem by calling\n> >     `init_add_i_state()`, even though we only do so to initialize the\n> >     interactive configuration as well as a repository pointer.\n> >\n> >     Stop doing so and instead store and initialize the interactive\n> >     configuration in `struct add_p_state` directly.\n> >\n> >     Signed-off-by: Patrick Steinhardt <ps@pks.im>\n> >     Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> >\n> > A good way to ensure that you do not send a patch that does not work\n> > well with others is to make a trial merge to 'next' and 'seen' and\n> > ensure that they produce working Git, after making sure your patch\n> > applied directly on top of 'master' works well.\n>\n> The above \"good way\" is to notice and stop yourself from sending a\n> patch that wants s->s.r to still exist.\n>\n> After that happens, it is tempting to rebuild your change on top of\n> 'next'.  But please do *NOT* do so.\n>\n> Instead, identify such dependencies (i.e. other topics with changes\n> relative to what 'master' has, that break what you developed\n> directly on top of 'master'), and then merge them to 'master'\n> yourself.  And then bulid your topic on top of the merge.  Work hard\n> to limit your dependencies to absolute minimum, as these topics will\n> take your work hostage---until they get merged down to 'master',\n> your topic will not be able to be merged to 'master'.\n>\n> In this case, you'll be likely to do something like\n>\n>     $ git checkout -b sp/add-patch-with-fewer-the-repository origin/master\n>     $ git merge --no-ff origin/ps-history-split\n>     $ edit ... && git add ... && make test\n>     $ git commit -m 'add-patch: use repository instance...'\n>\n> to build your single patch series on top of 'master' taken from my\n> tree, with Patrick's history-split topic merged into it.\n> After the commit is made, send out only your work (i.e., above the\n> merge of Patrick's topic) to the list and you're done.\n>\n\nThanks a lot for this useful tip.\nGoing forward, I will first try to ensure that there are no on-going\nconflicting patches by a trial merge to seen/next branch. Then after\nif there are any I would merge those dependent patches locally on a\ncopy of master, thereafter build my changes on that and send them.\n\nBest,\nShreyansh\n"},{"id":"539282","messageId":"20260318090546.1213077-1-shreyanshpaliwalcmsmn@gmail.com","threadId":"65277","inReplyTo":"20260317155230.619378-1-shreyanshpaliwalcmsmn@gmail.com","subject":"[PATCH v2 ] add-patch: use repository instance from add_p_state instead of the_repository","fromName":"Shreyansh Paliwal","fromEmail":"shreyanshpaliwalcmsmn@gmail.com","sentAt":"2026-03-18T09:00:03Z","receivedAt":"2026-03-18T09:06:07Z","isPatch":true,"sender":{"key":"shreyanshpaliwalcmsmn@gmail.com","avatar":"https://avatars.githubusercontent.com/u/152720574?v=4"},"body":"Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\nthe_repository even though a repository instance is already available via\nstruct add_p_state *s.\nUse 's->r' instead of the_repository to avoid relying on global state.\nAll callers pass a valid add_p_state and this does not change any behavior.\n\nThis follows recent refactoring that removed 'add_i_state' and moved\nrepository pointer and other add-patch config into struct add_p_state [1].\nThis aligns with the ongoing effort to reduce usage of the_repository\nglobal state.\n\n[1]- https://lore.kernel.org/git/20260302-pks-history-split-v1-3-444fc987a324@pks.im/\n\nSigned-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n---\nChanges in v2:\n - made changes on top of ps/history-split and used s->r instead of s->s.r\n\n add-patch.c | 8 ++++----\n 1 file changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/add-patch.c b/add-patch.c\nindex 4e28e5c187..f27edcbe8d 100644\n--- a/add-patch.c\n+++ b/add-patch.c\n@@ -558,8 +558,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n \t\tstrvec_push(&args,\n \t\t\t    /* could be on an unborn branch */\n \t\t\t    !strcmp(\"HEAD\", s->revision) &&\n-\t\t\t    repo_get_oid(the_repository, \"HEAD\", &oid) ?\n-\t\t\t    empty_tree_oid_hex(the_repository->hash_algo) : s->revision);\n+\t\t\t    repo_get_oid(s->r, \"HEAD\", &oid) ?\n+\t\t\t    empty_tree_oid_hex(s->r->hash_algo) : s->revision);\n \t}\n \tcolor_arg_index = args.nr;\n \t/* Use `--no-color` explicitly, just in case `diff.color = always`. */\n@@ -1271,7 +1271,7 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)\n \t\t\t\t\"removed, then the edit is\\n\"\n \t\t\t\t\"aborted and the hunk is left unchanged.\\n\"));\n\n-\tif (strbuf_edit_interactively(the_repository, &s->buf,\n+\tif (strbuf_edit_interactively(s->r, &s->buf,\n \t\t\t\t      \"addp-hunk-edit.diff\", NULL) < 0)\n \t\treturn -1;\n\n@@ -1679,7 +1679,7 @@ static size_t patch_update_file(struct add_p_state *s,\n \t\tif (file_diff->hunk_nr) {\n \t\t\tif (rendered_hunk_index != hunk_index) {\n \t\t\t\tif (use_pager) {\n-\t\t\t\t\tsetup_pager(the_repository);\n+\t\t\t\t\tsetup_pager(s->r);\n \t\t\t\t\tsigchain_push(SIGPIPE, SIG_IGN);\n \t\t\t\t}\n \t\t\t\trender_hunk(s, hunk, 0, colored, &s->buf);\n--\n2.53.0\n\n"},{"id":"539299","messageId":"xmqqbjglgkbs.fsf@gitster.g","threadId":"65277","inReplyTo":"20260318090546.1213077-1-shreyanshpaliwalcmsmn@gmail.com","subject":"Re: [PATCH v2 ] add-patch: use repository instance from add_p_state instead of the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-03-18T16:43:03Z","receivedAt":"2026-03-18T16:43:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com> writes:\n\n> Functions parse_diff(), edit_hunk_manually() and patch_update_file() use\n> the_repository even though a repository instance is already available via\n> struct add_p_state *s.\n> Use 's->r' instead of the_repository to avoid relying on global state.\n> All callers pass a valid add_p_state and this does not change any behavior.\n>\n> This follows recent refactoring that removed 'add_i_state' and moved\n> repository pointer and other add-patch config into struct add_p_state [1].\n> This aligns with the ongoing effort to reduce usage of the_repository\n> global state.\n>\n> [1]- https://lore.kernel.org/git/20260302-pks-history-split-v1-3-444fc987a324@pks.im/\n>\n> Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>\n> ---\n> Changes in v2:\n>  - made changes on top of ps/history-split and used s->r instead of s->s.r\n\nGood.  Brief and clear description on what this patch was based on.\n\nThanks.\n\n>\n>  add-patch.c | 8 ++++----\n>  1 file changed, 4 insertions(+), 4 deletions(-)\n>\n> diff --git a/add-patch.c b/add-patch.c\n> index 4e28e5c187..f27edcbe8d 100644\n> --- a/add-patch.c\n> +++ b/add-patch.c\n> @@ -558,8 +558,8 @@ static int parse_diff(struct add_p_state *s, const struct pathspec *ps)\n>  \t\tstrvec_push(&args,\n>  \t\t\t    /* could be on an unborn branch */\n>  \t\t\t    !strcmp(\"HEAD\", s->revision) &&\n> -\t\t\t    repo_get_oid(the_repository, \"HEAD\", &oid) ?\n> -\t\t\t    empty_tree_oid_hex(the_repository->hash_algo) : s->revision);\n> +\t\t\t    repo_get_oid(s->r, \"HEAD\", &oid) ?\n> +\t\t\t    empty_tree_oid_hex(s->r->hash_algo) : s->revision);\n>  \t}\n>  \tcolor_arg_index = args.nr;\n>  \t/* Use `--no-color` explicitly, just in case `diff.color = always`. */\n> @@ -1271,7 +1271,7 @@ static int edit_hunk_manually(struct add_p_state *s, struct hunk *hunk)\n>  \t\t\t\t\"removed, then the edit is\\n\"\n>  \t\t\t\t\"aborted and the hunk is left unchanged.\\n\"));\n>\n> -\tif (strbuf_edit_interactively(the_repository, &s->buf,\n> +\tif (strbuf_edit_interactively(s->r, &s->buf,\n>  \t\t\t\t      \"addp-hunk-edit.diff\", NULL) < 0)\n>  \t\treturn -1;\n>\n> @@ -1679,7 +1679,7 @@ static size_t patch_update_file(struct add_p_state *s,\n>  \t\tif (file_diff->hunk_nr) {\n>  \t\t\tif (rendered_hunk_index != hunk_index) {\n>  \t\t\t\tif (use_pager) {\n> -\t\t\t\t\tsetup_pager(the_repository);\n> +\t\t\t\t\tsetup_pager(s->r);\n>  \t\t\t\t\tsigchain_push(SIGPIPE, SIG_IGN);\n>  \t\t\t\t}\n>  \t\t\t\trender_hunk(s, hunk, 0, colored, &s->buf);\n> --\n> 2.53.0\n"}]}