merge-recursive: comment and reorder the merge_options fields
The merge_options struct had lots of fields, making it a little imposing, but the options naturally fall into multiple different groups. Grouping similar options and adding a comment or two makes it easier to read, easier for new folks to figure out which options are related, and thus easier for them to find the options they need. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Elijah Newren committed
Aug 17, 2019 at 11:41 UTC
a779fb829bf6160cb519500ac1e15d8ab8a247a4
2 files changed
+37
-19
merge-recursive.c
+11
-5
@@ -3754,21 +3754,27 @@ void init_merge_options(struct merge_options *opt,
3754
{
3755
const char *merge_verbosity;
3756
memset(opt, 0, sizeof(struct merge_options));
3757
+
3758
opt->repo = repo;
3759
+
3760
+ opt->detect_renames = -1;
3761
+ opt->detect_directory_renames = MERGE_DIRECTORY_RENAMES_CONFLICT;
3762
+ opt->rename_limit = -1;
3763
+
3764
opt->verbosity = 2;
3765
opt->buffer_output = 1;
3760
- opt->rename_limit = -1;
3766
+ strbuf_init(&opt->obuf, 0);
3767
+
3768
opt->renormalize = 0;
3762
- opt->detect_renames = -1;
3763
- opt->detect_directory_renames = MERGE_DIRECTORY_RENAMES_CONFLICT;
3769
+
3770
+ string_list_init(&opt->df_conflict_file_set, 1);
3771
+
3772
merge_recursive_config(opt);
3773
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");
3774
if (merge_verbosity)
3775
opt->verbosity = strtol(merge_verbosity, NULL, 10);
3776
if (opt->verbosity >= 5)
3777
opt->buffer_output = 0;
3770
- strbuf_init(&opt->obuf, 0);
3771
- string_list_init(&opt->df_conflict_file_set, 1);
3778
}
3779
3780
int parse_merge_opt(struct merge_options *opt, const char *s)
merge-recursive.h
+26
-14
@@ -9,36 +9,48 @@ struct commit;
9
struct repository;
10
11
struct merge_options {
12
+ struct repository *repo;
13
+
14
+ /* ref names used in console messages and conflict markers */
15
const char *ancestor;
16
const char *branch1;
17
const char *branch2;
15
- enum {
16
- MERGE_RECURSIVE_NORMAL = 0,
17
- MERGE_RECURSIVE_OURS,
18
- MERGE_RECURSIVE_THEIRS
19
- } recursive_variant;
20
- const char *subtree_shift;
21
- unsigned buffer_output; /* 1: output at end, 2: keep buffered */
22
- unsigned renormalize : 1;
23
- long xdl_opts;
24
- int verbosity;
18
+
19
+ /* rename related options */
20
+ int detect_renames;
21
enum {
22
MERGE_DIRECTORY_RENAMES_NONE = 0,
23
MERGE_DIRECTORY_RENAMES_CONFLICT = 1,
24
MERGE_DIRECTORY_RENAMES_TRUE = 2
25
} detect_directory_renames;
30
- int detect_renames;
26
int rename_limit;
27
int rename_score;
33
- int needed_rename_limit;
28
int show_rename_progress;
29
+
30
+ /* xdiff-related options (patience, ignore whitespace, ours/theirs) */
31
+ long xdl_opts;
32
+ enum {
33
+ MERGE_RECURSIVE_NORMAL = 0,
34
+ MERGE_RECURSIVE_OURS,
35
+ MERGE_RECURSIVE_THEIRS
36
+ } recursive_variant;
37
+
38
+ /* console output related options */
39
+ int verbosity;
40
+ unsigned buffer_output; /* 1: output at end, 2: keep buffered */
41
+ struct strbuf obuf; /* output buffer */
42
+
43
+ /* miscellaneous control options */
44
+ const char *subtree_shift;
45
+ unsigned renormalize : 1;
46
+
47
+ /* internal fields used by the implementation (do NOT set these) */
48
int call_depth;
36
- struct strbuf obuf;
49
+ int needed_rename_limit;
50
struct hashmap current_file_dir_set;
51
struct string_list df_conflict_file_set;
52
struct unpack_trees_options unpack_opts;
53
struct index_state orig_index;
41
- struct repository *repo;
54
};
55
56
void init_merge_options(struct merge_options *opt, struct repository *repo);