]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: use die_for_incompatible_opt3() for - -graph/--reverse/--walk-reflogs
authorRené Scharfe <l.s.r@web.de>
Wed, 6 Dec 2023 11:51:57 +0000 (12:51 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 8 Dec 2023 22:40:44 +0000 (07:40 +0900)
The revision option --reverse is incompatible with --walk-reflogs and
--graph is incompatible with both --reverse and --walk-reflogs.  So they
are all incompatible with each other.

Use the function for checking three mutually incompatible options,
die_for_incompatible_opt3(), to perform this check in one place and
without repetition.  This is shorter and clearer.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 00d5c29bfce18a1d4a5f5d701a593596ccd65783..34bd386a81f96a39acbd54f3fa2112330218b1c2 100644 (file)
@@ -3036,8 +3036,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                revs->grep_filter.ignore_locale = 1;
        compile_grep_patterns(&revs->grep_filter);
 
-       if (revs->reverse && revs->reflog_info)
-               die(_("options '%s' and '%s' cannot be used together"), "--reverse", "--walk-reflogs");
        if (revs->reflog_info && revs->limited)
                die("cannot combine --walk-reflogs with history-limiting options");
        if (revs->rewrite_parents && revs->children.name)
@@ -3048,11 +3046,10 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
        /*
         * Limitations on the graph functionality
         */
-       if (revs->reverse && revs->graph)
-               die(_("options '%s' and '%s' cannot be used together"), "--reverse", "--graph");
+       die_for_incompatible_opt3(!!revs->graph, "--graph",
+                                 !!revs->reverse, "--reverse",
+                                 !!revs->reflog_info, "--walk-reflogs");
 
-       if (revs->reflog_info && revs->graph)
-               die(_("options '%s' and '%s' cannot be used together"), "--walk-reflogs", "--graph");
        if (revs->no_walk && revs->graph)
                die(_("options '%s' and '%s' cannot be used together"), "--no-walk", "--graph");
        if (!revs->reflog_info && revs->grep_filter.use_reflog_filter)