aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--builtin/show-branch.c14
-rwxr-xr-xt/t3202-show-branch.sh9
2 files changed, 16 insertions, 7 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 67f3ef0639..b574afb7c3 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -667,17 +667,17 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
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", &sparse,
N_("show merges reachable from only one tip"), 1),
- OPT_SET_INT(0, "date-order", &sort_order,
- N_("topologically sort, maintaining date order "
- "where possible"),
- REV_SORT_BY_COMMIT_DATE),
+ 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"),
diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh
index ca7c44f0f7..b17f388f56 100755
--- a/t/t3202-show-branch.sh
+++ b/t/t3202-show-branch.sh
@@ -213,6 +213,15 @@ done <<\EOF
--reflog --current
EOF
+# unnegatable options
+for opt in topo-order date-order reflog
+do
+ test_expect_success "show-branch --no-$opt (should fail)" '
+ test_must_fail git show-branch --no-$opt 2>err &&
+ grep "unknown option .no-$opt." err
+ '
+done
+
test_expect_success 'error descriptions on non-existent branch' '
cat >expect <<-EOF &&
error: No branch named '\''non-existent'\'.'