From d30414bb5331d91784c536d30e22c2ccb8126b7a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 15 Sep 2025 10:23:20 -0400 Subject: forall: fix crash with no command When callback= is used, optparse does not automatically initialize The destination when a dest= is not specified. Refine the test to allow dest= options when callback= is used even when it seems like it is otherwise redundant. Bug: b/436611422 Change-Id: I5185f95cb857ca6d37357cac77fb117a83db9c0c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/509861 Tested-by: Mike Frysinger Commit-Queue: Mike Frysinger Reviewed-by: Gavin Mak --- subcmds/forall.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'subcmds/forall.py') diff --git a/subcmds/forall.py b/subcmds/forall.py index 4bae46af..57a41fc1 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py @@ -133,7 +133,7 @@ without iterating through the remaining projects. @staticmethod def _cmd_option(option, _opt_str, _value, parser): - setattr(parser.values, option.dest or "command", list(parser.rargs)) + setattr(parser.values, option.dest, list(parser.rargs)) while parser.rargs: del parser.rargs[0] @@ -161,6 +161,7 @@ without iterating through the remaining projects. p.add_option( "-c", "--command", + dest="command", help="command (and arguments) to execute", action="callback", callback=self._cmd_option, -- cgit v1.2.3-54-g00ecf