From d7ebdf56be6095338ea37bd4b52533c5bd7774e7 Mon Sep 17 00:00:00 2001 From: Kaushik Lingarkar Date: Thu, 5 Sep 2024 15:34:48 -0700 Subject: 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 Commit-Queue: Kaushik Lingarkar Tested-by: Kaushik Lingarkar --- subcmds/init.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'subcmds/init.py') 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 to checkout and use. If no branch is specified, the remote's default branch is used. This is equivalent to using -b HEAD. +The optional --manifest-upstream-branch argument can be used when a commit is +provided to --manifest-branch (or -b), to specify the name of the git ref in +which the commit can be found. + The optional -m argument can be used to specify an alternate manifest to be used. If no manifest is specified, the manifest default.xml will be used. @@ -135,6 +139,7 @@ to update the working directory files. # manifest project is special and is created when instantiating the # manifest which happens before we parse options. self.manifest.manifestProject.clone_depth = opt.manifest_depth + self.manifest.manifestProject.upstream = opt.manifest_upstream_branch clone_filter_for_depth = ( "blob:none" if (_REPO_ALLOW_SHALLOW == "0") else None ) @@ -317,6 +322,12 @@ to update the working directory files. " be used with --standalone-manifest." ) + if opt.manifest_upstream_branch and opt.manifest_branch is None: + self.OptionParser.error( + "--manifest-upstream-branch cannot be used without " + "--manifest-branch." + ) + if args: if opt.manifest_url: self.OptionParser.error( -- cgit v1.2.3-54-g00ecf