diff options
-rw-r--r-- | command.py | 3 | ||||
-rw-r--r-- | git_command.py | 42 | ||||
-rw-r--r-- | git_config.py | 4 | ||||
-rw-r--r-- | project.py | 8 | ||||
-rw-r--r-- | subcmds/upload.py | 5 |
5 files changed, 33 insertions, 29 deletions
@@ -320,7 +320,8 @@ class Command(object): | |||
320 | for arg in args: | 320 | for arg in args: |
321 | # We have to filter by manifest groups in case the requested project is | 321 | # We have to filter by manifest groups in case the requested project is |
322 | # checked out multiple times or differently based on them. | 322 | # checked out multiple times or differently based on them. |
323 | projects = [project for project in manifest.GetProjectsWithName( | 323 | projects = [project |
324 | for project in manifest.GetProjectsWithName( | ||
324 | arg, all_manifests=all_manifests) | 325 | arg, all_manifests=all_manifests) |
325 | if project.MatchesGroups(groups)] | 326 | if project.MatchesGroups(groups)] |
326 | 327 | ||
diff --git a/git_command.py b/git_command.py index 3a3bb34d..d4d4bed4 100644 --- a/git_command.py +++ b/git_command.py | |||
@@ -159,12 +159,12 @@ def git_require(min_version, fail=False, msg=''): | |||
159 | 159 | ||
160 | 160 | ||
161 | def _build_env( | 161 | def _build_env( |
162 | _kwargs_only=(), | 162 | _kwargs_only=(), |
163 | bare: Optional[bool] = False, | 163 | bare: Optional[bool] = False, |
164 | disable_editor: Optional[bool] = False, | 164 | disable_editor: Optional[bool] = False, |
165 | ssh_proxy: Optional[Any] = None, | 165 | ssh_proxy: Optional[Any] = None, |
166 | gitdir: Optional[str] = None, | 166 | gitdir: Optional[str] = None, |
167 | objdir: Optional[str] = None | 167 | objdir: Optional[str] = None |
168 | ): | 168 | ): |
169 | """Constucts an env dict for command execution.""" | 169 | """Constucts an env dict for command execution.""" |
170 | 170 | ||
@@ -194,8 +194,7 @@ def _build_env( | |||
194 | env['GIT_OBJECT_DIRECTORY'] = objdir | 194 | env['GIT_OBJECT_DIRECTORY'] = objdir |
195 | 195 | ||
196 | alt_objects = os.path.join(gitdir, 'objects') if gitdir else None | 196 | alt_objects = os.path.join(gitdir, 'objects') if gitdir else None |
197 | if (alt_objects and | 197 | if alt_objects and os.path.realpath(alt_objects) != os.path.realpath(objdir): |
198 | os.path.realpath(alt_objects) != os.path.realpath(objdir)): | ||
199 | # Allow git to search the original place in case of local or unique refs | 198 | # Allow git to search the original place in case of local or unique refs |
200 | # that git will attempt to resolve even if we aren't fetching them. | 199 | # that git will attempt to resolve even if we aren't fetching them. |
201 | env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects | 200 | env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects |
@@ -236,11 +235,11 @@ class GitCommand(object): | |||
236 | gitdir = gitdir.replace('\\', '/') | 235 | gitdir = gitdir.replace('\\', '/') |
237 | 236 | ||
238 | env = _build_env( | 237 | env = _build_env( |
239 | disable_editor=disable_editor, | 238 | disable_editor=disable_editor, |
240 | ssh_proxy=ssh_proxy, | 239 | ssh_proxy=ssh_proxy, |
241 | objdir=objdir, | 240 | objdir=objdir, |
242 | gitdir=gitdir, | 241 | gitdir=gitdir, |
243 | bare=bare, | 242 | bare=bare, |
244 | ) | 243 | ) |
245 | 244 | ||
246 | command = [GIT] | 245 | command = [GIT] |
@@ -279,7 +278,8 @@ class GitCommand(object): | |||
279 | if 'GIT_OBJECT_DIRECTORY' in env: | 278 | if 'GIT_OBJECT_DIRECTORY' in env: |
280 | dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY'] | 279 | dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY'] |
281 | if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env: | 280 | if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env: |
282 | dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] | 281 | dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % ( |
282 | env['GIT_ALTERNATE_OBJECT_DIRECTORIES']) | ||
283 | 283 | ||
284 | dbg += ': ' | 284 | dbg += ': ' |
285 | dbg += ' '.join(command) | 285 | dbg += ' '.join(command) |
@@ -295,13 +295,13 @@ class GitCommand(object): | |||
295 | with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg): | 295 | with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg): |
296 | try: | 296 | try: |
297 | p = subprocess.Popen(command, | 297 | p = subprocess.Popen(command, |
298 | cwd=cwd, | 298 | cwd=cwd, |
299 | env=env, | 299 | env=env, |
300 | encoding='utf-8', | 300 | encoding='utf-8', |
301 | errors='backslashreplace', | 301 | errors='backslashreplace', |
302 | stdin=stdin, | 302 | stdin=stdin, |
303 | stdout=stdout, | 303 | stdout=stdout, |
304 | stderr=stderr) | 304 | stderr=stderr) |
305 | except Exception as e: | 305 | except Exception as e: |
306 | raise GitError('%s: %s' % (command[1], e)) | 306 | raise GitError('%s: %s' % (command[1], e)) |
307 | 307 | ||
diff --git a/git_config.py b/git_config.py index af1a1015..029beb4d 100644 --- a/git_config.py +++ b/git_config.py | |||
@@ -188,7 +188,7 @@ class GitConfig(object): | |||
188 | if v in ('false', 'no'): | 188 | if v in ('false', 'no'): |
189 | return False | 189 | return False |
190 | print(f"warning: expected {name} to represent a boolean, got {v} instead", | 190 | print(f"warning: expected {name} to represent a boolean, got {v} instead", |
191 | file=sys.stderr) | 191 | file=sys.stderr) |
192 | return None | 192 | return None |
193 | 193 | ||
194 | def SetBoolean(self, name, value): | 194 | def SetBoolean(self, name, value): |
@@ -197,7 +197,7 @@ class GitConfig(object): | |||
197 | value = 'true' if value else 'false' | 197 | value = 'true' if value else 'false' |
198 | self.SetString(name, value) | 198 | self.SetString(name, value) |
199 | 199 | ||
200 | def GetString(self, name: str, all_keys: bool = False) -> Union[str, None]: | 200 | def GetString(self, name: str, all_keys: bool = False) -> Union[str, None]: |
201 | """Get the first value for a key, or None if it is not defined. | 201 | """Get the first value for a key, or None if it is not defined. |
202 | 202 | ||
203 | This configuration file is used first, if the key is not | 203 | This configuration file is used first, if the key is not |
@@ -54,6 +54,7 @@ class SyncNetworkHalfResult(NamedTuple): | |||
54 | # commit already present. | 54 | # commit already present. |
55 | remote_fetched: bool | 55 | remote_fetched: bool |
56 | 56 | ||
57 | |||
57 | # Maximum sleep time allowed during retries. | 58 | # Maximum sleep time allowed during retries. |
58 | MAXIMUM_RETRY_SLEEP_SEC = 3600.0 | 59 | MAXIMUM_RETRY_SLEEP_SEC = 3600.0 |
59 | # +-10% random jitter is added to each Fetches retry sleep duration. | 60 | # +-10% random jitter is added to each Fetches retry sleep duration. |
@@ -63,6 +64,7 @@ RETRY_JITTER_PERCENT = 0.1 | |||
63 | # TODO(vapier): Remove knob once behavior is verified. | 64 | # TODO(vapier): Remove knob once behavior is verified. |
64 | _ALTERNATES = os.environ.get('REPO_USE_ALTERNATES') == '1' | 65 | _ALTERNATES = os.environ.get('REPO_USE_ALTERNATES') == '1' |
65 | 66 | ||
67 | |||
66 | def _lwrite(path, content): | 68 | def _lwrite(path, content): |
67 | lock = '%s.lock' % path | 69 | lock = '%s.lock' % path |
68 | 70 | ||
@@ -3415,6 +3417,7 @@ class RepoProject(MetaProject): | |||
3415 | except OSError: | 3417 | except OSError: |
3416 | return 0 | 3418 | return 0 |
3417 | 3419 | ||
3420 | |||
3418 | class ManifestProject(MetaProject): | 3421 | class ManifestProject(MetaProject): |
3419 | """The MetaProject for manifests.""" | 3422 | """The MetaProject for manifests.""" |
3420 | 3423 | ||
@@ -3845,11 +3848,12 @@ class ManifestProject(MetaProject): | |||
3845 | self.config.SetBoolean('repo.superproject', use_superproject) | 3848 | self.config.SetBoolean('repo.superproject', use_superproject) |
3846 | 3849 | ||
3847 | if not standalone_manifest: | 3850 | if not standalone_manifest: |
3848 | if not self.Sync_NetworkHalf( | 3851 | success = self.Sync_NetworkHalf( |
3849 | is_new=is_new, quiet=not verbose, verbose=verbose, | 3852 | is_new=is_new, quiet=not verbose, verbose=verbose, |
3850 | clone_bundle=clone_bundle, current_branch_only=current_branch_only, | 3853 | clone_bundle=clone_bundle, current_branch_only=current_branch_only, |
3851 | tags=tags, submodules=submodules, clone_filter=clone_filter, | 3854 | tags=tags, submodules=submodules, clone_filter=clone_filter, |
3852 | partial_clone_exclude=self.manifest.PartialCloneExclude).success: | 3855 | partial_clone_exclude=self.manifest.PartialCloneExclude).success |
3856 | if not success: | ||
3853 | r = self.GetRemote() | 3857 | r = self.GetRemote() |
3854 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) | 3858 | print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr) |
3855 | 3859 | ||
diff --git a/subcmds/upload.py b/subcmds/upload.py index 5b17fb51..dc7e26da 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -615,9 +615,8 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
615 | hook = RepoHook.FromSubcmd( | 615 | hook = RepoHook.FromSubcmd( |
616 | hook_type='pre-upload', manifest=manifest, | 616 | hook_type='pre-upload', manifest=manifest, |
617 | opt=opt, abort_if_user_denies=True) | 617 | opt=opt, abort_if_user_denies=True) |
618 | if not hook.Run( | 618 | if not hook.Run(project_list=pending_proj_names, |
619 | project_list=pending_proj_names, | 619 | worktree_list=pending_worktrees): |
620 | worktree_list=pending_worktrees): | ||
621 | ret = 1 | 620 | ret = 1 |
622 | if ret: | 621 | if ret: |
623 | return ret | 622 | return ret |