Merge branch 'jc/diffcore-rotate'

"git {diff,log} --{skip,rotate}-to=<path>" allows the user to
discard diff output for early paths or move them to the end of the
output.

* jc/diffcore-rotate:
  diff: --{rotate,skip}-to=<path>
This commit is contained in:
Junio C Hamano
2021-02-25 16:43:30 -08:00
12 changed files with 197 additions and 1 deletions

21
diff.c
View File

@ -5348,6 +5348,19 @@ static int diff_opt_word_diff_regex(const struct option *opt,
return 0;
}
static int diff_opt_rotate_to(const struct option *opt, const char *arg, int unset)
{
struct diff_options *options = opt->value;
BUG_ON_OPT_NEG(unset);
if (!strcmp(opt->long_name, "skip-to"))
options->skip_instead_of_rotate = 1;
else
options->skip_instead_of_rotate = 0;
options->rotate_to = arg;
return 0;
}
static void prep_parse_options(struct diff_options *options)
{
struct option parseopts[] = {
@ -5599,6 +5612,12 @@ static void prep_parse_options(struct diff_options *options)
DIFF_PICKAXE_REGEX, PARSE_OPT_NONEG),
OPT_FILENAME('O', NULL, &options->orderfile,
N_("control the order in which files appear in the output")),
OPT_CALLBACK_F(0, "rotate-to", options, N_("<path>"),
N_("show the change in the specified path first"),
PARSE_OPT_NONEG, diff_opt_rotate_to),
OPT_CALLBACK_F(0, "skip-to", options, N_("<path>"),
N_("skip the output to the specified path"),
PARSE_OPT_NONEG, diff_opt_rotate_to),
OPT_CALLBACK_F(0, "find-object", options, N_("<object-id>"),
N_("look for differences that change the number of occurrences of the specified object"),
PARSE_OPT_NONEG, diff_opt_find_object),
@ -6693,6 +6712,8 @@ void diffcore_std(struct diff_options *options)
diffcore_pickaxe(options);
if (options->orderfile)
diffcore_order(options->orderfile);
if (options->rotate_to)
diffcore_rotate(options);
if (!options->found_follow)
/* See try_to_follow_renames() in tree-diff.c */
diff_resolve_rename_copy();