summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-02-23 15:43:07 -0500
committerMike Frysinger <vapier@google.com>2021-02-25 20:12:51 +0000
commit23882b33feaa0104dcbe372a9fde496cffc2b246 (patch)
tree310fde7df842d1171c91dfbb20176ab6a823e3db /subcmds/init.py
parent92304bff004e05be2e1bfc3f32464d47cbff9c42 (diff)
downloadgit-repo-23882b33feaa0104dcbe372a9fde496cffc2b246.tar.gz
init: support -b HEAD as a shortcut to "the default"
When people switch to non-default branches, they sometimes want to switch back to the default, but don't know the exact name for that branch. Add a -b HEAD shortcut for that. Change-Id: I090230da25f9f5a169608115d483f660f555624f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/297843 Reviewed-by: Michael Mortensen <mmortensen@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index ab0faff3..fc446045 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -48,7 +48,7 @@ argument.
48 48
49The optional -b argument can be used to select the manifest branch 49The optional -b argument can be used to select the manifest branch
50to checkout and use. If no branch is specified, the remote's default 50to checkout and use. If no branch is specified, the remote's default
51branch is used. 51branch is used. This is equivalent to using -b HEAD.
52 52
53The optional -m argument can be used to specify an alternate manifest 53The optional -m argument can be used to specify an alternate manifest
54to be used. If no manifest is specified, the manifest default.xml 54to be used. If no manifest is specified, the manifest default.xml
@@ -94,9 +94,8 @@ to update the working directory files.
94 g.add_option('-u', '--manifest-url', 94 g.add_option('-u', '--manifest-url',
95 dest='manifest_url', 95 dest='manifest_url',
96 help='manifest repository location', metavar='URL') 96 help='manifest repository location', metavar='URL')
97 g.add_option('-b', '--manifest-branch', 97 g.add_option('-b', '--manifest-branch', metavar='REVISION',
98 dest='manifest_branch', 98 help='manifest branch or revision (use HEAD for default)')
99 help='manifest branch or revision', metavar='REVISION')
100 cbr_opts = ['--current-branch'] 99 cbr_opts = ['--current-branch']
101 # The gitc-init subcommand allocates -c itself, but a lot of init users 100 # The gitc-init subcommand allocates -c itself, but a lot of init users
102 # want -c, so try to satisfy both as best we can. 101 # want -c, so try to satisfy both as best we can.
@@ -232,6 +231,11 @@ to update the working directory files.
232 r.Save() 231 r.Save()
233 232
234 if opt.manifest_branch: 233 if opt.manifest_branch:
234 if opt.manifest_branch == 'HEAD':
235 opt.manifest_branch = m.ResolveRemoteHead()
236 if opt.manifest_branch is None:
237 print('fatal: unable to resolve HEAD', file=sys.stderr)
238 sys.exit(1)
235 m.revisionExpr = opt.manifest_branch 239 m.revisionExpr = opt.manifest_branch
236 else: 240 else:
237 if is_new: 241 if is_new: