Skip to content

Commit a779fb8

Browse files
newrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8599ab4 commit a779fb8

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

merge-recursive.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,21 +3754,27 @@ void init_merge_options(struct merge_options *opt,
37543754
{
37553755
const char *merge_verbosity;
37563756
memset(opt, 0, sizeof(struct merge_options));
3757+
37573758
opt->repo = repo;
3759+
3760+
opt->detect_renames = -1;
3761+
opt->detect_directory_renames = MERGE_DIRECTORY_RENAMES_CONFLICT;
3762+
opt->rename_limit = -1;
3763+
37583764
opt->verbosity = 2;
37593765
opt->buffer_output = 1;
3760-
opt->rename_limit = -1;
3766+
strbuf_init(&opt->obuf, 0);
3767+
37613768
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+
37643772
merge_recursive_config(opt);
37653773
merge_verbosity = getenv("GIT_MERGE_VERBOSITY");
37663774
if (merge_verbosity)
37673775
opt->verbosity = strtol(merge_verbosity, NULL, 10);
37683776
if (opt->verbosity >= 5)
37693777
opt->buffer_output = 0;
3770-
strbuf_init(&opt->obuf, 0);
3771-
string_list_init(&opt->df_conflict_file_set, 1);
37723778
}
37733779

37743780
int parse_merge_opt(struct merge_options *opt, const char *s)

merge-recursive.h

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,48 @@ struct commit;
99
struct repository;
1010

1111
struct merge_options {
12+
struct repository *repo;
13+
14+
/* ref names used in console messages and conflict markers */
1215
const char *ancestor;
1316
const char *branch1;
1417
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;
2521
enum {
2622
MERGE_DIRECTORY_RENAMES_NONE = 0,
2723
MERGE_DIRECTORY_RENAMES_CONFLICT = 1,
2824
MERGE_DIRECTORY_RENAMES_TRUE = 2
2925
} detect_directory_renames;
30-
int detect_renames;
3126
int rename_limit;
3227
int rename_score;
33-
int needed_rename_limit;
3428
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) */
3548
int call_depth;
36-
struct strbuf obuf;
49+
int needed_rename_limit;
3750
struct hashmap current_file_dir_set;
3851
struct string_list df_conflict_file_set;
3952
struct unpack_trees_options unpack_opts;
4053
struct index_state orig_index;
41-
struct repository *repo;
4254
};
4355

4456
void init_merge_options(struct merge_options *opt, struct repository *repo);

0 commit comments

Comments
 (0)