[PATCH] show-branch: disallow --no-{date,topo}-order

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Signed-off-by: René Scharfe <l.s.r@xxxxxx>
---
 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux