add-patch: split out header from "add-interactive.h"

While we have a "add-patch.c" code file, its declarations are part of "add-interactive.h". This makes it somewhat harder than necessary to find relevant code and to identify clear boundaries between the two subsystems. Split up concerns and move declarations that relate to "add-patch.c" into a new "add-patch.h" header. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Mar 2, 2026 at 13:13 UTC 6e4d923267ca80dd1392bf7e0673c74711e8cb68
3 files changed +31 -21
add-interactive.h
+3 -21
@@ -1,15 +1,11 @@
1 #ifndef ADD_INTERACTIVE_H
2 #define ADD_INTERACTIVE_H
3
4 +#include "add-patch.h"
5 #include "color.h"
6
6 -struct add_p_opt {
7 - int context;
8 - int interhunkcontext;
9 - int auto_advance;
10 -};
11 -
12 -#define ADD_P_OPT_INIT { .context = -1, .interhunkcontext = -1, .auto_advance = 1 }
7 +struct pathspec;
8 +struct repository;
9
10 struct add_i_state {
11 struct repository *r;
@@ -37,21 +33,7 @@ void init_add_i_state(struct add_i_state *s, struct repository *r,
33 struct add_p_opt *add_p_opt);
34 void clear_add_i_state(struct add_i_state *s);
35
40 -struct repository;
41 -struct pathspec;
36 int run_add_i(struct repository *r, const struct pathspec *ps,
37 struct add_p_opt *add_p_opt);
38
45 -enum add_p_mode {
46 - ADD_P_ADD,
47 - ADD_P_STASH,
48 - ADD_P_RESET,
49 - ADD_P_CHECKOUT,
50 - ADD_P_WORKTREE,
51 -};
52 -
53 -int run_add_p(struct repository *r, enum add_p_mode mode,
54 - struct add_p_opt *o, const char *revision,
55 - const struct pathspec *ps);
56 -
39 #endif
add-patch.c
+1
@@ -3,6 +3,7 @@
3
4 #include "git-compat-util.h"
5 #include "add-interactive.h"
6 +#include "add-patch.h"
7 #include "advice.h"
8 #include "editor.h"
9 #include "environment.h"
add-patch.h new
+27
@@ -0,0 +1,27 @@
1 +#ifndef ADD_PATCH_H
2 +#define ADD_PATCH_H
3 +
4 +struct pathspec;
5 +struct repository;
6 +
7 +struct add_p_opt {
8 + int context;
9 + int interhunkcontext;
10 + int auto_advance;
11 +};
12 +
13 +#define ADD_P_OPT_INIT { .context = -1, .interhunkcontext = -1, .auto_advance = 1 }
14 +
15 +enum add_p_mode {
16 + ADD_P_ADD,
17 + ADD_P_STASH,
18 + ADD_P_RESET,
19 + ADD_P_CHECKOUT,
20 + ADD_P_WORKTREE,
21 +};
22 +
23 +int run_add_p(struct repository *r, enum add_p_mode mode,
24 + struct add_p_opt *o, const char *revision,
25 + const struct pathspec *ps);
26 +
27 +#endif