mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
92304bff00
commit
23882b33fe
4
repo
4
repo
@ -289,8 +289,8 @@ def GetParser(gitc_init=False):
|
|||||||
group = parser.add_option_group('Manifest options')
|
group = parser.add_option_group('Manifest options')
|
||||||
group.add_option('-u', '--manifest-url',
|
group.add_option('-u', '--manifest-url',
|
||||||
help='manifest repository location', metavar='URL')
|
help='manifest repository location', metavar='URL')
|
||||||
group.add_option('-b', '--manifest-branch',
|
group.add_option('-b', '--manifest-branch', metavar='REVISION',
|
||||||
help='manifest branch or revision', metavar='REVISION')
|
help='manifest branch or revision (use HEAD for default)')
|
||||||
group.add_option('-m', '--manifest-name',
|
group.add_option('-m', '--manifest-name',
|
||||||
help='initial manifest file', metavar='NAME.xml')
|
help='initial manifest file', metavar='NAME.xml')
|
||||||
cbr_opts = ['--current-branch']
|
cbr_opts = ['--current-branch']
|
||||||
|
@ -48,7 +48,7 @@ argument.
|
|||||||
|
|
||||||
The optional -b argument can be used to select the manifest branch
|
The optional -b argument can be used to select the manifest branch
|
||||||
to checkout and use. If no branch is specified, the remote's default
|
to checkout and use. If no branch is specified, the remote's default
|
||||||
branch is used.
|
branch is used. This is equivalent to using -b HEAD.
|
||||||
|
|
||||||
The optional -m argument can be used to specify an alternate manifest
|
The optional -m argument can be used to specify an alternate manifest
|
||||||
to be used. If no manifest is specified, the manifest default.xml
|
to be used. If no manifest is specified, the manifest default.xml
|
||||||
@ -94,9 +94,8 @@ to update the working directory files.
|
|||||||
g.add_option('-u', '--manifest-url',
|
g.add_option('-u', '--manifest-url',
|
||||||
dest='manifest_url',
|
dest='manifest_url',
|
||||||
help='manifest repository location', metavar='URL')
|
help='manifest repository location', metavar='URL')
|
||||||
g.add_option('-b', '--manifest-branch',
|
g.add_option('-b', '--manifest-branch', metavar='REVISION',
|
||||||
dest='manifest_branch',
|
help='manifest branch or revision (use HEAD for default)')
|
||||||
help='manifest branch or revision', metavar='REVISION')
|
|
||||||
cbr_opts = ['--current-branch']
|
cbr_opts = ['--current-branch']
|
||||||
# The gitc-init subcommand allocates -c itself, but a lot of init users
|
# The gitc-init subcommand allocates -c itself, but a lot of init users
|
||||||
# want -c, so try to satisfy both as best we can.
|
# want -c, so try to satisfy both as best we can.
|
||||||
@ -232,6 +231,11 @@ to update the working directory files.
|
|||||||
r.Save()
|
r.Save()
|
||||||
|
|
||||||
if opt.manifest_branch:
|
if opt.manifest_branch:
|
||||||
|
if opt.manifest_branch == 'HEAD':
|
||||||
|
opt.manifest_branch = m.ResolveRemoteHead()
|
||||||
|
if opt.manifest_branch is None:
|
||||||
|
print('fatal: unable to resolve HEAD', file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
m.revisionExpr = opt.manifest_branch
|
m.revisionExpr = opt.manifest_branch
|
||||||
else:
|
else:
|
||||||
if is_new:
|
if is_new:
|
||||||
|
Loading…
Reference in New Issue
Block a user