summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
authorJason Chang <jasonnc@google.com>2023-05-23 13:06:55 -0700
committerJason Chang <jasonnc@google.com>2023-05-25 22:37:04 +0000
commit17833322d9e0c650310e55f806d5e3545c265c2a (patch)
tree67cd339bede0227bd43bd1e6fb9cc66fcb83d6b4 /subcmds/init.py
parent04cba4add52b11a27d09d73c2cbfebcd67a1f2cc (diff)
downloadgit-repo-17833322d9e0c650310e55f806d5e3545c265c2a.tar.gz
Add envar to replace shallow clones with partial
An investigation go/git-repo-shallow shows a number of problems when doing a shallow git fetch/clone. This change introduces an environment variable REPO_ALLOW_SHALLOW. When this environment variable is set to 1 during a repo init or repo sync all shallow git fetch commands are replaced with partial fetch commands. Any shallow repository needing update is unshallowed. This behavior continues until a subsequent repo sync command is run with REPO_ALLOW_SHALLOW set to 1. Bug: b/274340522 Change-Id: I1c3188270629359e52449788897d9d4988ebf280 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/374754 Reviewed-by: Josip Sokcevic <sokcevic@google.com> Tested-by: Jason Chang <jasonnc@google.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 9946466d..6d7fd857 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -20,6 +20,8 @@ from command import InteractiveCommand, MirrorSafeCommand
20from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD 20from git_command import git_require, MIN_GIT_VERSION_SOFT, MIN_GIT_VERSION_HARD
21from wrapper import Wrapper 21from wrapper import Wrapper
22 22
23_REPO_ALLOW_SHALLOW = os.environ.get("REPO_ALLOW_SHALLOW")
24
23 25
24class Init(InteractiveCommand, MirrorSafeCommand): 26class Init(InteractiveCommand, MirrorSafeCommand):
25 COMMON = True 27 COMMON = True
@@ -125,6 +127,9 @@ to update the working directory files.
125 # manifest project is special and is created when instantiating the 127 # manifest project is special and is created when instantiating the
126 # manifest which happens before we parse options. 128 # manifest which happens before we parse options.
127 self.manifest.manifestProject.clone_depth = opt.manifest_depth 129 self.manifest.manifestProject.clone_depth = opt.manifest_depth
130 clone_filter_for_depth = (
131 "blob:none" if (_REPO_ALLOW_SHALLOW == "0") else None
132 )
128 if not self.manifest.manifestProject.Sync( 133 if not self.manifest.manifestProject.Sync(
129 manifest_url=opt.manifest_url, 134 manifest_url=opt.manifest_url,
130 manifest_branch=opt.manifest_branch, 135 manifest_branch=opt.manifest_branch,
@@ -140,6 +145,7 @@ to update the working directory files.
140 partial_clone=opt.partial_clone, 145 partial_clone=opt.partial_clone,
141 clone_filter=opt.clone_filter, 146 clone_filter=opt.clone_filter,
142 partial_clone_exclude=opt.partial_clone_exclude, 147 partial_clone_exclude=opt.partial_clone_exclude,
148 clone_filter_for_depth=clone_filter_for_depth,
143 clone_bundle=opt.clone_bundle, 149 clone_bundle=opt.clone_bundle,
144 git_lfs=opt.git_lfs, 150 git_lfs=opt.git_lfs,
145 use_superproject=opt.use_superproject, 151 use_superproject=opt.use_superproject,