Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
diff-parseopt: convert --[no-]follow
author
Nguyễn Thái Ngọc Duy
<pclouds@gmail.com>
Tue, 5 Mar 2019 12:30:16 +0000
(19:30 +0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 6 Mar 2019 23:02:22 +0000
(08:02 +0900)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4f99f29
)
diff --git
a/diff.c
b/diff.c
index 689dc116840cd85017817b9d2c78d5d1fec69f3f..ad813ea418a3a8f5bd9f572f2a3cc248c1ddd885 100644
(file)
--- a/
diff.c
+++ b/
diff.c
@@
-4986,6
+4986,21
@@
static int diff_opt_find_renames(const struct option *opt,
return 0;
}
return 0;
}
+static int diff_opt_follow(const struct option *opt,
+ const char *arg, int unset)
+{
+ struct diff_options *options = opt->value;
+
+ BUG_ON_OPT_ARG(arg);
+ if (unset) {
+ options->flags.follow_renames = 0;
+ options->flags.default_follow_renames = 0;
+ } else {
+ options->flags.follow_renames = 1;
+ }
+ return 0;
+}
+
static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
const struct option *opt,
const char *arg, int unset)
static enum parse_opt_result diff_opt_output(struct parse_opt_ctx_t *ctx,
const struct option *opt,
const char *arg, int unset)
@@
-5172,6
+5187,9
@@
static void prep_parse_options(struct diff_options *options)
0, PARSE_OPT_NONEG),
OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
N_("use empty blobs as rename source")),
0, PARSE_OPT_NONEG),
OPT_BOOL(0, "rename-empty", &options->flags.rename_empty,
N_("use empty blobs as rename source")),
+ OPT_CALLBACK_F(0, "follow", options, NULL,
+ N_("continue listing the history of a file beyond renames"),
+ PARSE_OPT_NOARG, diff_opt_follow),
OPT_GROUP(N_("Diff algorithm options")),
OPT_BIT(0, "minimal", &options->xdl_opts,
OPT_GROUP(N_("Diff algorithm options")),
OPT_BIT(0, "minimal", &options->xdl_opts,
@@
-5250,12
+5268,7
@@
int diff_opt_parse(struct diff_options *options,
return ac;
/* flags options */
return ac;
/* flags options */
- if (!strcmp(arg, "--follow"))
- options->flags.follow_renames = 1;
- else if (!strcmp(arg, "--no-follow")) {
- options->flags.follow_renames = 0;
- options->flags.default_follow_renames = 0;
- } else if (skip_to_optional_arg_default(arg, "--color", &arg, "always")) {
+ if (skip_to_optional_arg_default(arg, "--color", &arg, "always")) {
int value = git_config_colorbool(NULL, arg);
if (value < 0)
return error("option `color' expects \"always\", \"auto\", or \"never\"");
int value = git_config_colorbool(NULL, arg);
if (value < 0)
return error("option `color' expects \"always\", \"auto\", or \"never\"");