diff options
| author | Kaushik Lingarkar <kaushik.lingarkar@linaro.org> | 2024-09-05 15:34:48 -0700 |
|---|---|---|
| committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2024-09-26 00:52:28 +0000 |
| commit | d7ebdf56be6095338ea37bd4b52533c5bd7774e7 (patch) | |
| tree | e6db62fd873e70bb0453791a69f8772f9d567a0c | |
| parent | fabab4e24527fca9b6b4a0c64607524b1890c609 (diff) | |
| download | git-repo-d7ebdf56be6095338ea37bd4b52533c5bd7774e7.tar.gz | |
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 <sokcevic@google.com>
Commit-Queue: Kaushik Lingarkar <kaushik.lingarkar@linaro.org>
Tested-by: Kaushik Lingarkar <kaushik.lingarkar@linaro.org>
| -rw-r--r-- | man/repo-init.1 | 11 | ||||
| -rwxr-xr-x | repo | 8 | ||||
| -rw-r--r-- | subcmds/init.py | 11 |
3 files changed, 28 insertions, 2 deletions
diff --git a/man/repo-init.1 b/man/repo-init.1 index cf93de1f..37411752 100644 --- a/man/repo-init.1 +++ b/man/repo-init.1 | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | .\" DO NOT MODIFY THIS FILE! It was generated by help2man. | 1 | .\" 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" |
| 3 | .SH NAME | 3 | .SH NAME |
| 4 | repo \- repo init - manual page for repo init | 4 | repo \- repo init - manual page for repo init |
| 5 | .SH SYNOPSIS | 5 | .SH SYNOPSIS |
| @@ -28,6 +28,11 @@ manifest repository location | |||
| 28 | \fB\-b\fR REVISION, \fB\-\-manifest\-branch\fR=\fI\,REVISION\/\fR | 28 | \fB\-b\fR REVISION, \fB\-\-manifest\-branch\fR=\fI\,REVISION\/\fR |
| 29 | manifest branch or revision (use HEAD for default) | 29 | manifest branch or revision (use HEAD for default) |
| 30 | .TP | 30 | .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 | ||
| 31 | \fB\-m\fR NAME.xml, \fB\-\-manifest\-name\fR=\fI\,NAME\/\fR.xml | 36 | \fB\-m\fR NAME.xml, \fB\-\-manifest\-name\fR=\fI\,NAME\/\fR.xml |
| 32 | initial manifest file | 37 | initial manifest file |
| 33 | .TP | 38 | .TP |
| @@ -163,6 +168,10 @@ The optional \fB\-b\fR argument can be used to select the manifest branch to che | |||
| 163 | and use. If no branch is specified, the remote's default branch is used. This is | 168 | and use. If no branch is specified, the remote's default branch is used. This is |
| 164 | equivalent to using \fB\-b\fR HEAD. | 169 | equivalent to using \fB\-b\fR HEAD. |
| 165 | .PP | 170 | .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 | ||
| 166 | The optional \fB\-m\fR argument can be used to specify an alternate manifest to be | 175 | The optional \fB\-m\fR argument can be used to specify an alternate manifest to be |
| 167 | used. If no manifest is specified, the manifest default.xml will be used. | 176 | used. If no manifest is specified, the manifest default.xml will be used. |
| 168 | .PP | 177 | .PP |
| @@ -124,7 +124,7 @@ if not REPO_REV: | |||
| 124 | BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" | 124 | BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071" |
| 125 | 125 | ||
| 126 | # increment this whenever we make important changes to this script | 126 | # increment this whenever we make important changes to this script |
| 127 | VERSION = (2, 45) | 127 | VERSION = (2, 48) |
| 128 | 128 | ||
| 129 | # increment this if the MAINTAINER_KEYS block is modified | 129 | # increment this if the MAINTAINER_KEYS block is modified |
| 130 | KEYRING_VERSION = (2, 3) | 130 | KEYRING_VERSION = (2, 3) |
| @@ -283,6 +283,12 @@ def InitParser(parser): | |||
| 283 | help="manifest branch or revision (use HEAD for default)", | 283 | help="manifest branch or revision (use HEAD for default)", |
| 284 | ) | 284 | ) |
| 285 | group.add_option( | 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 | ) | ||
| 291 | group.add_option( | ||
| 286 | "-m", | 292 | "-m", |
| 287 | "--manifest-name", | 293 | "--manifest-name", |
| 288 | default="default.xml", | 294 | default="default.xml", |
diff --git a/subcmds/init.py b/subcmds/init.py index 7617bc1f..fb6d3eb5 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
| @@ -52,6 +52,10 @@ The optional -b argument can be used to select the manifest branch | |||
| 52 | to checkout and use. If no branch is specified, the remote's default | 52 | to checkout and use. If no branch is specified, the remote's default |
| 53 | branch is used. This is equivalent to using -b HEAD. | 53 | branch is used. This is equivalent to using -b HEAD. |
| 54 | 54 | ||
| 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 | |||
| 55 | The optional -m argument can be used to specify an alternate manifest | 59 | The optional -m argument can be used to specify an alternate manifest |
| 56 | to be used. If no manifest is specified, the manifest default.xml | 60 | to be used. If no manifest is specified, the manifest default.xml |
| 57 | will be used. | 61 | will be used. |
| @@ -135,6 +139,7 @@ to update the working directory files. | |||
| 135 | # manifest project is special and is created when instantiating the | 139 | # manifest project is special and is created when instantiating the |
| 136 | # manifest which happens before we parse options. | 140 | # manifest which happens before we parse options. |
| 137 | self.manifest.manifestProject.clone_depth = opt.manifest_depth | 141 | self.manifest.manifestProject.clone_depth = opt.manifest_depth |
| 142 | self.manifest.manifestProject.upstream = opt.manifest_upstream_branch | ||
| 138 | clone_filter_for_depth = ( | 143 | clone_filter_for_depth = ( |
| 139 | "blob:none" if (_REPO_ALLOW_SHALLOW == "0") else None | 144 | "blob:none" if (_REPO_ALLOW_SHALLOW == "0") else None |
| 140 | ) | 145 | ) |
| @@ -317,6 +322,12 @@ to update the working directory files. | |||
| 317 | " be used with --standalone-manifest." | 322 | " be used with --standalone-manifest." |
| 318 | ) | 323 | ) |
| 319 | 324 | ||
| 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 | |||
| 320 | if args: | 331 | if args: |
| 321 | if opt.manifest_url: | 332 | if opt.manifest_url: |
| 322 | self.OptionParser.error( | 333 | self.OptionParser.error( |
