{"thread":{"id":"66695","subject":"[PATCH] add -i: hide init/clear_add_i_state() functions","startedAt":"2026-10-28T19:57:51Z","lastAt":"2026-11-02T08:42:25Z","messageCount":6,"participants":["Junio C Hamano","Ben Knoble","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556700","messageId":"xmqqh5i58uo0.fsf@gitster.g","threadId":"66695","inReplyTo":null,"subject":"[PATCH] add -i: hide init/clear_add_i_state() functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-28T19:57:51Z","receivedAt":"2026-10-28T19:57:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The \"add -i\" machinery is encapsulated in run_add_i() function,\nwhich uses init_add_i_state() to initialize the machinery, does its\nthing, and clear_add_i_state() to tear it down.  External callers\nhave no need to call anything other than run_add_i().\n\nMake init/clear_add_i_state() file-scope static functions, and\n\"struct add_i_state\" type as well.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n add-interactive.c | 11 ++++++++---\n add-interactive.h |  9 ---------\n 2 files changed, 8 insertions(+), 12 deletions(-)\n\ndiff --git a/add-interactive.c b/add-interactive.c\nindex 3cf8a1dbf8..9a00daf9f9 100644\n--- a/add-interactive.c\n+++ b/add-interactive.c\n@@ -19,14 +19,19 @@\n #include \"prompt.h\"\n #include \"tree.h\"\n \n-void init_add_i_state(struct add_i_state *s, struct repository *r,\n-\t\t      struct interactive_options *opts)\n+struct add_i_state {\n+\tstruct repository *r;\n+\tstruct interactive_config cfg;\n+};\n+\n+static void init_add_i_state(struct add_i_state *s, struct repository *r,\n+\t\t\t     struct interactive_options *opts)\n {\n \ts->r = r;\n \tinteractive_config_init(&s->cfg, r, opts);\n }\n \n-void clear_add_i_state(struct add_i_state *s)\n+static void clear_add_i_state(struct add_i_state *s)\n {\n \tinteractive_config_clear(&s->cfg);\n \tmemset(s, 0, sizeof(*s));\ndiff --git a/add-interactive.h b/add-interactive.h\nindex eefa2edc7c..47f67ede82 100644\n--- a/add-interactive.h\n+++ b/add-interactive.h\n@@ -6,15 +6,6 @@\n struct pathspec;\n struct repository;\n \n-struct add_i_state {\n-\tstruct repository *r;\n-\tstruct interactive_config cfg;\n-};\n-\n-void init_add_i_state(struct add_i_state *s, struct repository *r,\n-\t\t      struct interactive_options *opts);\n-void clear_add_i_state(struct add_i_state *s);\n-\n int run_add_i(struct repository *r, const struct pathspec *ps,\n \t      struct interactive_options *opts);\n \n-- \n2.56.0-433-ga9209adf11\n\n\n"},{"id":"556707","messageId":"2E0FBA76-AB3A-4B5C-A08A-9B3272C65307@gmail.com","threadId":"66695","inReplyTo":"xmqqh5i58uo0.fsf@gitster.g","subject":"Re: [PATCH] add -i: hide init/clear_add_i_state() functions","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-10-28T20:48:13Z","receivedAt":"2026-10-28T20:48:13Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"\n> Le 28 oct. 2026 à 16:22, Junio C Hamano <gitster@pobox.com> a écrit :\n> \n> ﻿The \"add -i\" machinery is encapsulated in run_add_i() function,\n> which uses init_add_i_state() to initialize the machinery, does its\n> thing, and clear_add_i_state() to tear it down.  External callers\n> have no need to call anything other than run_add_i().\n> \n> Make init/clear_add_i_state() file-scope static functions, and\n> \"struct add_i_state\" type as well.\n\nYep, narrower interfaces are easier for programmers to consume, thanks. \n\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n> add-interactive.c | 11 ++++++++---\n> add-interactive.h |  9 ---------\n> 2 files changed, 8 insertions(+), 12 deletions(-)\n> \n> diff --git a/add-interactive.c b/add-interactive.c\n> index 3cf8a1dbf8..9a00daf9f9 100644\n> --- a/add-interactive.c\n> +++ b/add-interactive.c\n> @@ -19,14 +19,19 @@\n> #include \"prompt.h\"\n> #include \"tree.h\"\n> \n> -void init_add_i_state(struct add_i_state *s, struct repository *r,\n> -              struct interactive_options *opts)\n> +struct add_i_state {\n> +    struct repository *r;\n> +    struct interactive_config cfg;\n> +};\n> +\n> +static void init_add_i_state(struct add_i_state *s, struct repository *r,\n> +                 struct interactive_options *opts)\n> {\n>    s->r = r;\n>    interactive_config_init(&s->cfg, r, opts);\n> }\n> \n> -void clear_add_i_state(struct add_i_state *s)\n> +static void clear_add_i_state(struct add_i_state *s)\n> {\n>    interactive_config_clear(&s->cfg);\n>    memset(s, 0, sizeof(*s));\n> diff --git a/add-interactive.h b/add-interactive.h\n> index eefa2edc7c..47f67ede82 100644\n> --- a/add-interactive.h\n> +++ b/add-interactive.h\n> @@ -6,15 +6,6 @@\n> struct pathspec;\n> struct repository;\n> \n> -struct add_i_state {\n> -    struct repository *r;\n> -    struct interactive_config cfg;\n> -};\n> -\n> -void init_add_i_state(struct add_i_state *s, struct repository *r,\n> -              struct interactive_options *opts);\n> -void clear_add_i_state(struct add_i_state *s);\n> -\n> int run_add_i(struct repository *r, const struct pathspec *ps,\n>          struct interactive_options *opts);\n> \n> --\n> 2.56.0-433-ga9209adf11\n\nAnd this matches the log message.\n\nI did not check for callers, but I assume you did your due-diligence there ;) \n"},{"id":"556867","messageId":"auRlfDXPhp3RjNyk@pks.im","threadId":"66695","inReplyTo":"xmqqh5i58uo0.fsf@gitster.g","subject":"Re: [PATCH] add -i: hide init/clear_add_i_state() functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-10-30T09:38:04Z","receivedAt":"2026-10-30T09:38:04Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Wed, Oct 28, 2026 at 12:57:51PM -0700, Junio C Hamano wrote:\n> The \"add -i\" machinery is encapsulated in run_add_i() function,\n> which uses init_add_i_state() to initialize the machinery, does its\n> thing, and clear_add_i_state() to tear it down.  External callers\n> have no need to call anything other than run_add_i().\n> \n> Make init/clear_add_i_state() file-scope static functions, and\n> \"struct add_i_state\" type as well.\n\nNice cleanup. For historical context, these declarations are not needed\nanymore starting with d51b61f5dab (add-patch: remove dependency on\n\"add-interactive\" subsystem, 2026-03-02).\n\nThanks!\n\nPatrick\n\n"},{"id":"556924","messageId":"xmqqv76jxl22.fsf@gitster.g","threadId":"66695","inReplyTo":"auRlfDXPhp3RjNyk@pks.im","subject":"Re: [PATCH] add -i: hide init/clear_add_i_state() functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-10-30T15:30:45Z","receivedAt":"2026-10-30T15:30:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Patrick Steinhardt <ps@pks.im> writes:\n\n> On Wed, Oct 28, 2026 at 12:57:51PM -0700, Junio C Hamano wrote:\n>> The \"add -i\" machinery is encapsulated in run_add_i() function,\n>> which uses init_add_i_state() to initialize the machinery, does its\n>> thing, and clear_add_i_state() to tear it down.  External callers\n>> have no need to call anything other than run_add_i().\n>> \n>> Make init/clear_add_i_state() file-scope static functions, and\n>> \"struct add_i_state\" type as well.\n>\n> Nice cleanup. For historical context, these declarations are not needed\n> anymore starting with d51b61f5dab (add-patch: remove dependency on\n> \"add-interactive\" subsystem, 2026-03-02).\n\nThanks.  I did not notice that I gave a backstory for the other\nthree commits but apparently did so without digging into the history\nfor this one.\n\nBy the way, I queued the patches sent to the list on a branch (I\ninitially made them on a detached HEAD without keeping a local copy\nafter sending them out) and tried 'git history reword' to update\nthis one, but it seems it does not honor the notes.rewriteref\nconfiguration variable.  I wonder if this is a known limitation, or\na deliberate design.\n\nThanks.\n\n\n\n"},{"id":"556977","messageId":"EDD8FC7B-91B4-49CA-AE6B-3475E03EF786@gmail.com","threadId":"66695","inReplyTo":"xmqqv76jxl22.fsf@gitster.g","subject":"Re: [PATCH] add -i: hide init/clear_add_i_state() functions","fromName":"Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2026-10-30T21:35:20Z","receivedAt":"2026-10-30T21:35:20Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"\n> Le 30 oct. 2026 à 11:30, Junio C Hamano <gitster@pobox.com> a écrit :\n> \n> ﻿Patrick Steinhardt <ps@pks.im> writes:\n> \n>>> On Wed, Oct 28, 2026 at 12:57:51PM -0700, Junio C Hamano wrote:\n>>> The \"add -i\" machinery is encapsulated in run_add_i() function,\n>>> which uses init_add_i_state() to initialize the machinery, does its\n>>> thing, and clear_add_i_state() to tear it down.  External callers\n>>> have no need to call anything other than run_add_i().\n>>> \n>>> Make init/clear_add_i_state() file-scope static functions, and\n>>> \"struct add_i_state\" type as well.\n>> \n>> Nice cleanup. For historical context, these declarations are not needed\n>> anymore starting with d51b61f5dab (add-patch: remove dependency on\n>> \"add-interactive\" subsystem, 2026-03-02).\n> \n> Thanks.  I did not notice that I gave a backstory for the other\n> three commits but apparently did so without digging into the history\n> for this one.\n> \n> By the way, I queued the patches sent to the list on a branch (I\n> initially made them on a detached HEAD without keeping a local copy\n> after sending them out) and tried 'git history reword' to update\n> this one, but it seems it does not honor the notes.rewriteref\n> configuration variable.  I wonder if this is a known limitation, or\n> a deliberate design.\n\nIndeed. I believe it is a known limitation (one I would love to\nlift, but will probably not dedicate time to produce code soon). Still, I’ll help\nin the usual ways if I can ;)\n"},{"id":"557121","messageId":"auhM8Y8mkRMJOdjH@pks.im","threadId":"66695","inReplyTo":"EDD8FC7B-91B4-49CA-AE6B-3475E03EF786@gmail.com","subject":"Re: [PATCH] add -i: hide init/clear_add_i_state() functions","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-02T08:42:25Z","receivedAt":"2026-11-02T08:42:25Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Fri, Oct 30, 2026 at 05:35:20PM -0400, Ben Knoble wrote:\n> \n> > Le 30 oct. 2026 à 11:30, Junio C Hamano <gitster@pobox.com> a écrit :\n> > \n> > ﻿Patrick Steinhardt <ps@pks.im> writes:\n> > \n> >>> On Wed, Oct 28, 2026 at 12:57:51PM -0700, Junio C Hamano wrote:\n> >>> The \"add -i\" machinery is encapsulated in run_add_i() function,\n> >>> which uses init_add_i_state() to initialize the machinery, does its\n> >>> thing, and clear_add_i_state() to tear it down.  External callers\n> >>> have no need to call anything other than run_add_i().\n> >>> \n> >>> Make init/clear_add_i_state() file-scope static functions, and\n> >>> \"struct add_i_state\" type as well.\n> >> \n> >> Nice cleanup. For historical context, these declarations are not needed\n> >> anymore starting with d51b61f5dab (add-patch: remove dependency on\n> >> \"add-interactive\" subsystem, 2026-03-02).\n> > \n> > Thanks.  I did not notice that I gave a backstory for the other\n> > three commits but apparently did so without digging into the history\n> > for this one.\n> > \n> > By the way, I queued the patches sent to the list on a branch (I\n> > initially made them on a detached HEAD without keeping a local copy\n> > after sending them out) and tried 'git history reword' to update\n> > this one, but it seems it does not honor the notes.rewriteref\n> > configuration variable.  I wonder if this is a known limitation, or\n> > a deliberate design.\n> \n> Indeed. I believe it is a known limitation (one I would love to\n> lift, but will probably not dedicate time to produce code soon).\n> Still, I’ll help in the usual ways if I can ;)\n\nYeah, it's a limitation and not a design decision. I'd be happy to\nreview any such patch series, as I'm also a bit short on time recently.\nMeanwhile I've also created an issue in our bug tracker, so we may pick\nthis up in the next release cycle.\n\nPatrick\n\n"}]}