* [PATCH] add -i: hide init/clear_add_i_state() functions
@ 2026-10-28 19:57 Junio C Hamano
2026-10-28 20:48 ` Ben Knoble
0 siblings, 1 reply; 2+ messages in thread
From: Junio C Hamano @ 2026-10-28 19:57 UTC (permalink / raw)
To: git
The "add -i" machinery is encapsulated in run_add_i() function,
which uses init_add_i_state() to initialize the machinery, does its
thing, and clear_add_i_state() to tear it down. External callers
have no need to call anything other than run_add_i().
Make init/clear_add_i_state() file-scope static functions, and
"struct add_i_state" type as well.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
add-interactive.c | 11 ++++++++---
add-interactive.h | 9 ---------
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/add-interactive.c b/add-interactive.c
index 3cf8a1dbf8..9a00daf9f9 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -19,14 +19,19 @@
#include "prompt.h"
#include "tree.h"
-void init_add_i_state(struct add_i_state *s, struct repository *r,
- struct interactive_options *opts)
+struct add_i_state {
+ struct repository *r;
+ struct interactive_config cfg;
+};
+
+static void init_add_i_state(struct add_i_state *s, struct repository *r,
+ struct interactive_options *opts)
{
s->r = r;
interactive_config_init(&s->cfg, r, opts);
}
-void clear_add_i_state(struct add_i_state *s)
+static void clear_add_i_state(struct add_i_state *s)
{
interactive_config_clear(&s->cfg);
memset(s, 0, sizeof(*s));
diff --git a/add-interactive.h b/add-interactive.h
index eefa2edc7c..47f67ede82 100644
--- a/add-interactive.h
+++ b/add-interactive.h
@@ -6,15 +6,6 @@
struct pathspec;
struct repository;
-struct add_i_state {
- struct repository *r;
- struct interactive_config cfg;
-};
-
-void init_add_i_state(struct add_i_state *s, struct repository *r,
- struct interactive_options *opts);
-void clear_add_i_state(struct add_i_state *s);
-
int run_add_i(struct repository *r, const struct pathspec *ps,
struct interactive_options *opts);
--
2.56.0-433-ga9209adf11
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] add -i: hide init/clear_add_i_state() functions
2026-10-28 19:57 [PATCH] add -i: hide init/clear_add_i_state() functions Junio C Hamano
@ 2026-10-28 20:48 ` Ben Knoble
0 siblings, 0 replies; 2+ messages in thread
From: Ben Knoble @ 2026-10-28 20:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
> Le 28 oct. 2026 à 16:22, Junio C Hamano <gitster@pobox.com> a écrit :
>
> The "add -i" machinery is encapsulated in run_add_i() function,
> which uses init_add_i_state() to initialize the machinery, does its
> thing, and clear_add_i_state() to tear it down. External callers
> have no need to call anything other than run_add_i().
>
> Make init/clear_add_i_state() file-scope static functions, and
> "struct add_i_state" type as well.
Yep, narrower interfaces are easier for programmers to consume, thanks.
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> add-interactive.c | 11 ++++++++---
> add-interactive.h | 9 ---------
> 2 files changed, 8 insertions(+), 12 deletions(-)
>
> diff --git a/add-interactive.c b/add-interactive.c
> index 3cf8a1dbf8..9a00daf9f9 100644
> --- a/add-interactive.c
> +++ b/add-interactive.c
> @@ -19,14 +19,19 @@
> #include "prompt.h"
> #include "tree.h"
>
> -void init_add_i_state(struct add_i_state *s, struct repository *r,
> - struct interactive_options *opts)
> +struct add_i_state {
> + struct repository *r;
> + struct interactive_config cfg;
> +};
> +
> +static void init_add_i_state(struct add_i_state *s, struct repository *r,
> + struct interactive_options *opts)
> {
> s->r = r;
> interactive_config_init(&s->cfg, r, opts);
> }
>
> -void clear_add_i_state(struct add_i_state *s)
> +static void clear_add_i_state(struct add_i_state *s)
> {
> interactive_config_clear(&s->cfg);
> memset(s, 0, sizeof(*s));
> diff --git a/add-interactive.h b/add-interactive.h
> index eefa2edc7c..47f67ede82 100644
> --- a/add-interactive.h
> +++ b/add-interactive.h
> @@ -6,15 +6,6 @@
> struct pathspec;
> struct repository;
>
> -struct add_i_state {
> - struct repository *r;
> - struct interactive_config cfg;
> -};
> -
> -void init_add_i_state(struct add_i_state *s, struct repository *r,
> - struct interactive_options *opts);
> -void clear_add_i_state(struct add_i_state *s);
> -
> int run_add_i(struct repository *r, const struct pathspec *ps,
> struct interactive_options *opts);
>
> --
> 2.56.0-433-ga9209adf11
And this matches the log message.
I did not check for callers, but I assume you did your due-diligence there ;)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-28 20:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-28 19:57 [PATCH] add -i: hide init/clear_add_i_state() functions Junio C Hamano
2026-10-28 20:48 ` Ben Knoble
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.