Skip to content

Commit d7ebdf5

Browse files
Kaushik LingarkarLUCI
authored andcommitted
init: add --manifest-upstream-branch
When a sha1 is provided to '--manifest-branch', the ref which is expected to contain that sha1 can be provided using the new '--manifest-upstream-branch' option. This is useful with '--current-branch' to avoid having to sync all heads and tags, or with a commit that comes from a non-head/tag ref (like a Gerrit change ref). Change-Id: I46a3e255ca69ed9e809039e58b0c163e02af94ef Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/436717 Reviewed-by: Josip Sokcevic <[email protected]> Commit-Queue: Kaushik Lingarkar <[email protected]> Tested-by: Kaushik Lingarkar <[email protected]>
1 parent fabab4e commit d7ebdf5

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

man/repo-init.1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.\" DO NOT MODIFY THIS FILE! It was generated by help2man.
2-
.TH REPO "1" "October 2022" "repo init" "Repo Manual"
2+
.TH REPO "1" "September 2024" "repo init" "Repo Manual"
33
.SH NAME
44
repo \- repo init - manual page for repo init
55
.SH SYNOPSIS
@@ -28,6 +28,11 @@ manifest repository location
2828
\fB\-b\fR REVISION, \fB\-\-manifest\-branch\fR=\fI\,REVISION\/\fR
2929
manifest branch or revision (use HEAD for default)
3030
.TP
31+
\fB\-\-manifest\-upstream\-branch\fR=\fI\,BRANCH\/\fR
32+
when a commit is provided to \fB\-\-manifest\-branch\fR, this
33+
is the name of the git ref in which the commit can be
34+
found
35+
.TP
3136
\fB\-m\fR NAME.xml, \fB\-\-manifest\-name\fR=\fI\,NAME\/\fR.xml
3237
initial manifest file
3338
.TP
@@ -163,6 +168,10 @@ The optional \fB\-b\fR argument can be used to select the manifest branch to che
163168
and use. If no branch is specified, the remote's default branch is used. This is
164169
equivalent to using \fB\-b\fR HEAD.
165170
.PP
171+
The optional \fB\-\-manifest\-upstream\-branch\fR argument can be used when a commit is
172+
provided to \fB\-\-manifest\-branch\fR (or \fB\-b\fR), to specify the name of the git ref in
173+
which the commit can be found.
174+
.PP
166175
The optional \fB\-m\fR argument can be used to specify an alternate manifest to be
167176
used. If no manifest is specified, the manifest default.xml will be used.
168177
.PP

repo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ if not REPO_REV:
124124
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
125125

126126
# increment this whenever we make important changes to this script
127-
VERSION = (2, 45)
127+
VERSION = (2, 48)
128128

129129
# increment this if the MAINTAINER_KEYS block is modified
130130
KEYRING_VERSION = (2, 3)
@@ -282,6 +282,12 @@ def InitParser(parser):
282282
metavar="REVISION",
283283
help="manifest branch or revision (use HEAD for default)",
284284
)
285+
group.add_option(
286+
"--manifest-upstream-branch",
287+
help="when a commit is provided to --manifest-branch, this "
288+
"is the name of the git ref in which the commit can be found",
289+
metavar="BRANCH",
290+
)
285291
group.add_option(
286292
"-m",
287293
"--manifest-name",

subcmds/init.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ class Init(InteractiveCommand, MirrorSafeCommand):
5252
to checkout and use. If no branch is specified, the remote's default
5353
branch is used. This is equivalent to using -b HEAD.
5454
55+
The optional --manifest-upstream-branch argument can be used when a commit is
56+
provided to --manifest-branch (or -b), to specify the name of the git ref in
57+
which the commit can be found.
58+
5559
The optional -m argument can be used to specify an alternate manifest
5660
to be used. If no manifest is specified, the manifest default.xml
5761
will be used.
@@ -135,6 +139,7 @@ def _SyncManifest(self, opt):
135139
# manifest project is special and is created when instantiating the
136140
# manifest which happens before we parse options.
137141
self.manifest.manifestProject.clone_depth = opt.manifest_depth
142+
self.manifest.manifestProject.upstream = opt.manifest_upstream_branch
138143
clone_filter_for_depth = (
139144
"blob:none" if (_REPO_ALLOW_SHALLOW == "0") else None
140145
)
@@ -317,6 +322,12 @@ def ValidateOptions(self, opt, args):
317322
" be used with --standalone-manifest."
318323
)
319324

325+
if opt.manifest_upstream_branch and opt.manifest_branch is None:
326+
self.OptionParser.error(
327+
"--manifest-upstream-branch cannot be used without "
328+
"--manifest-branch."
329+
)
330+
320331
if args:
321332
if opt.manifest_url:
322333
self.OptionParser.error(

0 commit comments

Comments
 (0)