diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-02-25 16:43:30 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-25 16:43:30 -0800 |
commit | 845d6030f81da3bb43bd24a78ef8c441a441c5d5 (patch) | |
tree | 8f53740bbf5e31f6a002bc6166c897417e58696e /diff.c | |
parent | Merge branch 'mt/checkout-index-corner-cases' (diff) | |
parent | diff: --{rotate,skip}-to=<path> (diff) | |
download | tgif-845d6030f81da3bb43bd24a78ef8c441a441c5d5.tar.xz |
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>
Diffstat (limited to 'diff.c')
-rw-r--r-- | diff.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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(); |