diff-parseopt: convert --no-renames|--[no--rename-empty
For --rename-empty, see 90d43b0768 (teach diffcore-rename to optionally ignore empty content - 2012-03-22) for more information. 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
Feb 21, 2019 at 18:16 UTC
cdc43eb0b871992b42cff02ea9fe818c812c6dca
2 files changed
+9
-7
Documentation/diff-options.txt
+3
@@ -392,6 +392,9 @@ endif::git-format-patch[]
392
Turn off rename detection, even when the configuration
393
file gives the default to do so.
394
395
+--[no-]rename-empty::
396
+ Whether to use empty blobs as rename source.
397
+
398
ifndef::git-format-patch[]
399
--check::
400
Warn if changes introduce conflict markers or whitespace errors.
diff.c
+6
-7
@@ -5087,6 +5087,11 @@ static void prep_parse_options(struct diff_options *options)
5087
diff_opt_find_copies),
5088
OPT_BOOL(0, "find-copies-harder", &options->flags.find_copies_harder,
5089
N_("use unmodified files as source to find copies")),
5090
+ OPT_SET_INT_F(0, "no-renames", &options->detect_rename,
5091
+ N_("disable rename detection"),
5092
+ 0, PARSE_OPT_NONEG),
5093
+ OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
5094
+ N_("use empty blobs as rename source")),
5095
5096
OPT_GROUP(N_("Diff other options")),
5097
{ OPTION_CALLBACK, 0, "output", options, N_("<file>"),
@@ -5121,13 +5126,7 @@ int diff_opt_parse(struct diff_options *options,
5126
return ac;
5127
5128
/* renames options */
5124
- if (!strcmp(arg, "--no-renames"))
5125
- options->detect_rename = 0;
5126
- else if (!strcmp(arg, "--rename-empty"))
5127
- options->flags.rename_empty = 1;
5128
- else if (!strcmp(arg, "--no-rename-empty"))
5129
- options->flags.rename_empty = 0;
5130
- else if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
5129
+ if (skip_to_optional_arg_default(arg, "--relative", &arg, NULL)) {
5130
options->flags.relative_name = 1;
5131
if (arg)
5132
options->prefix = arg;