Merge branch 'jk/init-core-worktree-at-root'
[gitweb.git] / builtin / show-branch.c
index 270e39c6c1b0855181a19b12739425035db9ad1d..e69fb7c489885ad2466397a8a25c34d87eff9ce9 100644 (file)
@@ -6,8 +6,11 @@
 #include "parse-options.h"
 
 static const char* show_branch_usage[] = {
-    N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order] [--current] [--color[=<when>] | --no-color] [--sparse] [--more=<n> | --list | --independent | --merge-base] [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"),
-    N_("git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]"),
+    N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
+       "               [--current] [--color[=<when>] | --no-color] [--sparse]\n"
+       "               [--more=<n> | --list | --independent | --merge-base]\n"
+       "               [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"),
+    N_("git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]"),
     NULL
 };
 
@@ -715,7 +718,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
        }
 
        /* If nothing is specified, show all branches by default */
-       if (ac + all_heads + all_remotes == 0)
+       if (ac <= topics && all_heads + all_remotes == 0)
                all_heads = 1;
 
        if (reflog) {
@@ -782,13 +785,13 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                }
                free(ref);
        }
-       else if (all_heads + all_remotes)
-               snarf_refs(all_heads, all_remotes);
        else {
                while (0 < ac) {
                        append_one_rev(*av);
                        ac--; av++;
                }
+               if (all_heads + all_remotes)
+                       snarf_refs(all_heads, all_remotes);
        }
 
        head_p = resolve_ref_unsafe("HEAD", RESOLVE_REF_READING,