]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
Merge branch 'jc/diffcore-rotate'
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index bf2cbf15e776d0405aeaf94828e7d64990889f7d..6956f5e335c235d0a1a2ea6d8b7b8e7b7678deda 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -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();