]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/parse-options-show-branch'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Jul 2023 22:26:37 +0000 (15:26 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Jul 2023 22:26:37 +0000 (15:26 -0700)
Command line parser fixes.

* jc/parse-options-show-branch:
  show-branch: reject --[no-](topo|date)-order
  show-branch: --no-sparse should give dense output

1  2 
builtin/show-branch.c

diff --combined builtin/show-branch.c
index a86b3c7677b606bc859231e9f1c6a0817218158d,b574afb7c35cb53b7f8f6f2e18e37a05866ef432..b01ec761d2596c6a524994b99e1ef0aa719735d2
@@@ -1,4 -1,4 +1,4 @@@
 -#include "cache.h"
 +#include "builtin.h"
  #include "config.h"
  #include "environment.h"
  #include "gettext.h"
@@@ -6,6 -6,7 +6,6 @@@
  #include "hex.h"
  #include "pretty.h"
  #include "refs.h"
 -#include "builtin.h"
  #include "color.h"
  #include "strvec.h"
  #include "object-name.h"
@@@ -14,7 -15,6 +14,7 @@@
  #include "dir.h"
  #include "commit-slab.h"
  #include "date.h"
 +#include "wildmatch.h"
  
  static const char* show_branch_usage[] = {
      N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
@@@ -559,8 -559,7 +559,8 @@@ static void append_one_rev(const char *
        die("bad sha1 reference %s", av);
  }
  
 -static int git_show_branch_config(const char *var, const char *value, void *cb)
 +static int git_show_branch_config(const char *var, const char *value,
 +                                const struct config_context *ctx, void *cb)
  {
        if (!strcmp(var, "showbranch.default")) {
                if (!value)
                return 0;
        }
  
 -      return git_color_default_config(var, value, cb);
 +      if (git_color_config(var, value, cb) < 0)
 +              return -1;
 +
 +      return git_default_config(var, value, ctx, cb);
  }
  
  static int omit_in_dense(struct commit *commit, struct commit **rev, int n)
@@@ -649,7 -645,7 +649,7 @@@ int cmd_show_branch(int ac, const char 
        int with_current_branch = 0;
        int head_at = -1;
        int topics = 0;
-       int dense = 1;
+       int sparse = 0;
        const char *reflog_base = NULL;
        struct option builtin_show_branch_options[] = {
                OPT_BOOL('a', "all", &all_heads,
                         N_("show possible merge bases")),
                OPT_BOOL(0, "independent", &independent,
                            N_("show refs unreachable from any other ref")),
-               OPT_SET_INT(0, "topo-order", &sort_order,
-                           N_("show commits in topological order"),
-                           REV_SORT_IN_GRAPH_ORDER),
+               OPT_SET_INT_F(0, "topo-order", &sort_order,
+                             N_("show commits in topological order"),
+                             REV_SORT_IN_GRAPH_ORDER, PARSE_OPT_NONEG),
                OPT_BOOL(0, "topics", &topics,
                         N_("show only commits not on the first branch")),
-               OPT_SET_INT(0, "sparse", &dense,
-                           N_("show merges reachable from only one tip"), 0),
-               OPT_SET_INT(0, "date-order", &sort_order,
-                           N_("topologically sort, maintaining date order "
-                              "where possible"),
-                           REV_SORT_BY_COMMIT_DATE),
+               OPT_SET_INT(0, "sparse", &sparse,
+                           N_("show merges reachable from only one tip"), 1),
+               OPT_SET_INT_F(0, "date-order", &sort_order,
+                             N_("topologically sort, maintaining date order "
+                                "where possible"),
+                             REV_SORT_BY_COMMIT_DATE, PARSE_OPT_NONEG),
                OPT_CALLBACK_F('g', "reflog", &reflog_base, N_("<n>[,<base>]"),
                            N_("show <n> most recent ref-log entries starting at "
                               "base"),
                            !is_merge_point &&
                            (this_flag & (1u << REV_SHIFT)))
                                continue;
-                       if (dense && is_merge &&
+                       if (!sparse && is_merge &&
                            omit_in_dense(commit, rev, num_rev))
                                continue;
                        for (i = 0; i < num_rev; i++) {