[PATCH] show-branch: disallow --no-{date,topo}-order
- From
René Scharfe <l.s.r@web.de>
- Date
- Jul 21, 2023, 12:41 UTC
- Message-ID
- <417cab57-2952-9687-d8cb-72f5661a673f@web.de>
- In-Reply-To
- <xmqqo7k9fa5x.fsf@gitster.g>
Since 57343652a5 (show-branch: migrate to parse-options API, 2009-05-21) git show-branch has accepted --no-date-order and --no-topo-order, but both mean the same as --topo-order. That's because they are defined using OPT_SET_INT, which sets the value to 0 for negated options, and the value of REV_SORT_IN_GRAPH_ORDER happens to be 0 as well.
Ordering chronologically or topologically is not a binary choice in principle; we could add e.g. an option to sort alphabetically. So negating a sort order option makes no sense conceptually. Forbid it.
Suggested-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: René Scharfe <l.s.r@web.de> --- builtin/show-branch.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 99b3f4a09a..587d231dae 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -671,17 +671,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_BOOL(0, "sparse", &sparse, N_("show merges reachable from only one tip")), - 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"), -- 2.41.0