From 75c02fe4cb5a22135e292c3083220e1f3d4cb349 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 5 Feb 2020 00:01:59 -0500 Subject: init: handle -c conflicts with gitc-init We keep getting requests for init to support -c. This conflicts with gitc-init which allocates -c for its own use. Lets make this dynamic so we keep it with "init" but omit it for "gitc-init". Bug: https://crbug.com/gerrit/10200 Change-Id: Ibf69c2bbeff638e28e63cb08926fea0c622258db (cherry picked from commit 66098f707a1a3f352aac4c4bb2c4f88da070ca2a) Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/253392 Tested-by: Mike Frysinger Reviewed-by: Mike Frysinger --- subcmds/gitc_init.py | 2 +- subcmds/init.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/subcmds/gitc_init.py b/subcmds/gitc_init.py index df7b2587..378f9236 100644 --- a/subcmds/gitc_init.py +++ b/subcmds/gitc_init.py @@ -50,7 +50,7 @@ use for this GITC client. """ def _Options(self, p): - super(GitcInit, self)._Options(p) + super(GitcInit, self)._Options(p, gitc_init=True) g = p.add_option_group('GITC options') g.add_option('-f', '--manifest-file', dest='manifest_file', diff --git a/subcmds/init.py b/subcmds/init.py index 3e2c9d70..f4229f62 100644 --- a/subcmds/init.py +++ b/subcmds/init.py @@ -81,7 +81,7 @@ manifest, a subsequent `repo sync` (or `repo sync -d`) is necessary to update the working directory files. """ - def _Options(self, p): + def _Options(self, p, gitc_init=False): # Logging g = p.add_option_group('Logging options') g.add_option('-q', '--quiet', @@ -96,7 +96,12 @@ to update the working directory files. g.add_option('-b', '--manifest-branch', dest='manifest_branch', help='manifest branch or revision', metavar='REVISION') - g.add_option('-c', '--current-branch', + cbr_opts = ['--current-branch'] + # The gitc-init subcommand allocates -c itself, but a lot of init users + # want -c, so try to satisfy both as best we can. + if gitc_init: + cbr_opts += ['-c'] + g.add_option(*cbr_opts, dest='current_branch_only', action='store_true', help='fetch only current manifest branch from server') g.add_option('-m', '--manifest-name', -- cgit v1.2.3-54-g00ecf