Skip to content

Commit 31fba9d

Browse files
pcloudsgitster
authored andcommitted
diff-parseopt: convert --[src|dst]-prefix
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d877418 commit 31fba9d

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

diff.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5255,6 +5255,12 @@ static void prep_parse_options(struct diff_options *options)
52555255
N_("do not munge pathnames and use NULs as output field terminators in --raw or --numstat"),
52565256
0),
52575257
OPT__ABBREV(&options->abbrev),
5258+
OPT_STRING_F(0, "src-prefix", &options->a_prefix, N_("<prefix>"),
5259+
N_("show the given source prefix instead of \"a/\""),
5260+
PARSE_OPT_NONEG),
5261+
OPT_STRING_F(0, "dst-prefix", &options->b_prefix, N_("<prefix>"),
5262+
N_("show the given source prefix instead of \"b/\""),
5263+
PARSE_OPT_NONEG),
52585264
OPT_CALLBACK_F(0, "output-indicator-new",
52595265
&options->output_indicators[OUTPUT_INDICATOR_NEW],
52605266
N_("<char>"),
@@ -5449,20 +5455,12 @@ int diff_opt_parse(struct diff_options *options,
54495455
}
54505456

54515457
/* misc options */
5452-
else if ((argcount = parse_long_opt("src-prefix", av, &optarg))) {
5453-
options->a_prefix = optarg;
5454-
return argcount;
5455-
}
54565458
else if ((argcount = parse_long_opt("line-prefix", av, &optarg))) {
54575459
options->line_prefix = optarg;
54585460
options->line_prefix_length = strlen(options->line_prefix);
54595461
graph_setup_line_prefix(options);
54605462
return argcount;
54615463
}
5462-
else if ((argcount = parse_long_opt("dst-prefix", av, &optarg))) {
5463-
options->b_prefix = optarg;
5464-
return argcount;
5465-
}
54665464
else if (!strcmp(arg, "--no-prefix"))
54675465
options->a_prefix = options->b_prefix = "";
54685466
else if (opt_arg(arg, '\0', "inter-hunk-context",

parse-options.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ struct option {
136136
#define OPT_BOOL_F(s, l, v, h, f) OPT_SET_INT_F(s, l, v, h, 1, f)
137137
#define OPT_CALLBACK_F(s, l, v, a, h, f, cb) \
138138
{ OPTION_CALLBACK, (s), (l), (v), (a), (h), (f), (cb) }
139+
#define OPT_STRING_F(s, l, v, a, h, f) { OPTION_STRING, (s), (l), (v), (a), (h), (f) }
139140

140141
#define OPT_END() { OPTION_END }
141142
#define OPT_ARGUMENT(l, h) { OPTION_ARGUMENT, 0, (l), NULL, NULL, \
@@ -157,7 +158,7 @@ struct option {
157158
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), N_("n"), (h) }
158159
#define OPT_MAGNITUDE(s, l, v, h) { OPTION_MAGNITUDE, (s), (l), (v), \
159160
N_("n"), (h), PARSE_OPT_NONEG }
160-
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
161+
#define OPT_STRING(s, l, v, a, h) OPT_STRING_F(s, l, v, a, h, 0)
161162
#define OPT_STRING_LIST(s, l, v, a, h) \
162163
{ OPTION_CALLBACK, (s), (l), (v), (a), \
163164
(h), 0, &parse_opt_string_list }

0 commit comments

Comments
 (0)