diff.c: convert -u|-p|--patch
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Jan 27, 2019 at 07:35 UTC
cc013c224cfc73cf7d29ce4d336749f00c3bf1c7
1 file changed
+8
-2
diff.c
+8
-2
@@ -4870,6 +4870,13 @@ static int parse_objfind_opt(struct diff_options *opt, const char *arg)
4870
static void prep_parse_options(struct diff_options *options)
4871
{
4872
struct option parseopts[] = {
4873
+ OPT_GROUP(N_("Diff output format options")),
4874
+ OPT_BITOP('p', "patch", &options->output_format,
4875
+ N_("generate patch"),
4876
+ DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
4877
+ OPT_BITOP('u', NULL, &options->output_format,
4878
+ N_("generate patch"),
4879
+ DIFF_FORMAT_PATCH, DIFF_FORMAT_NO_OUTPUT),
4880
OPT_END()
4881
};
4882
@@ -4898,8 +4905,7 @@ int diff_opt_parse(struct diff_options *options,
4905
return ac;
4906
4907
/* Output format options */
4901
- if (!strcmp(arg, "-p") || !strcmp(arg, "-u") || !strcmp(arg, "--patch")
4902
- || opt_arg(arg, 'U', "unified", &options->context))
4908
+ if (opt_arg(arg, 'U', "unified", &options->context))
4909
enable_patch_output(&options->output_format);
4910
else if (!strcmp(arg, "--raw"))
4911
options->output_format |= DIFF_FORMAT_RAW;