Skip to content

Commit c5630c4

Browse files
rscharfegitster
authored andcommitted
diff: factor out add_diff_options()
Add a function for appending the parseopts member of struct diff_options to a struct option array. Use it in two sites instead of accessing the parseopts member directly. Decoupling callers from diff internals like that allows us to change the latter. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e7e5c6f commit c5630c4

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

builtin/range-diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ int cmd_range_diff(int argc, const char **argv, const char *prefix)
4747

4848
repo_diff_setup(the_repository, &diffopt);
4949

50-
options = parse_options_concat(range_diff_options, diffopt.parseopts);
50+
options = add_diff_options(range_diff_options, &diffopt);
5151
argc = parse_options(argc, argv, prefix, options,
5252
builtin_range_diff_usage, PARSE_OPT_KEEP_DASHDASH);
5353

diff-no-index.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@ int diff_no_index(struct rev_info *revs,
255255
};
256256
struct option *options;
257257

258-
options = parse_options_concat(no_index_options,
259-
revs->diffopt.parseopts);
258+
options = add_diff_options(no_index_options, &revs->diffopt);
260259
argc = parse_options(argc, argv, revs->prefix, options,
261260
diff_no_index_usage, 0);
262261
if (argc != 2) {

diff.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5397,6 +5397,12 @@ static int diff_opt_rotate_to(const struct option *opt, const char *arg, int uns
53975397
return 0;
53985398
}
53995399

5400+
struct option *add_diff_options(const struct option *opts,
5401+
struct diff_options *options)
5402+
{
5403+
return parse_options_concat(opts, options->parseopts);
5404+
}
5405+
54005406
static void prep_parse_options(struct diff_options *options)
54015407
{
54025408
struct option parseopts[] = {

diff.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ int git_diff_ui_config(const char *var, const char *value, void *cb);
539539
#define diff_setup(diffopts) repo_diff_setup(the_repository, diffopts)
540540
#endif
541541
void repo_diff_setup(struct repository *, struct diff_options *);
542+
struct option *add_diff_options(const struct option *, struct diff_options *);
542543
int diff_opt_parse(struct diff_options *, const char **, int, const char *);
543544
void diff_setup_done(struct diff_options *);
544545
int git_config_rename(const char *var, const char *value);

0 commit comments

Comments
 (0)