Thread (12 messages) 12 messages, 3 authors, 2023-08-08
STALE1062d

[PATCH] branch: disallow --no-{all,remotes}

From: René Scharfe <hidden>
Date: 2023-07-21 12:42:30
Subsystem: the rest · Maintainer: Linus Torvalds

Since 171edcbb49 (git-branch: introduce missing long forms for the
options, 2011-08-28) git branch accepts --no-all and --no-remotes, but
fails in both cases, reporting "fatal: filter_refs: invalid type".
Disallow the options --all and --remotes to be negated in the first
place.

Suggested-by: Junio C Hamano <redacted>
Signed-off-by: René Scharfe <redacted>
---
 builtin/branch.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/builtin/branch.c b/builtin/branch.c
index a27bc0a3df..1bfd85f4d8 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -720,8 +720,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		OPT_STRING('u', "set-upstream-to", &new_upstream, N_("upstream"), N_("change the upstream info")),
 		OPT_BOOL(0, "unset-upstream", &unset_upstream, N_("unset the upstream info")),
 		OPT__COLOR(&branch_use_color, N_("use colored output")),
-		OPT_SET_INT('r', "remotes",     &filter.kind, N_("act on remote-tracking branches"),
-			FILTER_REFS_REMOTES),
+		OPT_SET_INT_F('r', "remotes", &filter.kind,
+			N_("act on remote-tracking branches"),
+			FILTER_REFS_REMOTES,
+			PARSE_OPT_NONEG),
 		OPT_CONTAINS(&filter.with_commit, N_("print only branches that contain the commit")),
 		OPT_NO_CONTAINS(&filter.no_commit, N_("print only branches that don't contain the commit")),
 		OPT_WITH(&filter.with_commit, N_("print only branches that contain the commit")),
@@ -729,8 +731,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
 		OPT__ABBREV(&filter.abbrev),

 		OPT_GROUP(N_("Specific git-branch actions:")),
-		OPT_SET_INT('a', "all", &filter.kind, N_("list both remote-tracking and local branches"),
-			FILTER_REFS_REMOTES | FILTER_REFS_BRANCHES),
+		OPT_SET_INT_F('a', "all", &filter.kind,
+			N_("list both remote-tracking and local branches"),
+			FILTER_REFS_REMOTES | FILTER_REFS_BRANCHES,
+			PARSE_OPT_NONEG),
 		OPT_BIT('d', "delete", &delete, N_("delete fully merged branch"), 1),
 		OPT_BIT('D', NULL, &delete, N_("delete branch (even if not merged)"), 2),
 		OPT_BIT('m', "move", &rename, N_("move/rename a branch and its reflog"), 1),
--
2.41.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help