Skip to content

Commit 6e4d923

Browse files
pks-tgitster
authored andcommitted
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>
1 parent 50d063e commit 6e4d923

3 files changed

Lines changed: 31 additions & 21 deletions

File tree

add-interactive.h

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
#ifndef ADD_INTERACTIVE_H
22
#define ADD_INTERACTIVE_H
33

4+
#include "add-patch.h"
45
#include "color.h"
56

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;
139

1410
struct add_i_state {
1511
struct repository *r;
@@ -37,21 +33,7 @@ void init_add_i_state(struct add_i_state *s, struct repository *r,
3733
struct add_p_opt *add_p_opt);
3834
void clear_add_i_state(struct add_i_state *s);
3935

40-
struct repository;
41-
struct pathspec;
4236
int run_add_i(struct repository *r, const struct pathspec *ps,
4337
struct add_p_opt *add_p_opt);
4438

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-
5739
#endif

add-patch.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "git-compat-util.h"
55
#include "add-interactive.h"
6+
#include "add-patch.h"
67
#include "advice.h"
78
#include "editor.h"
89
#include "environment.h"

add-patch.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

0 commit comments

Comments
 (0)