diff options
| author | Joanna Wang <jojwang@google.com> | 2022-12-08 17:46:28 -0500 |
|---|---|---|
| committer | Joanna Wang <jojwang@google.com> | 2022-12-09 14:25:15 +0000 |
| commit | 0e4f1e7fba4770908235e136c5ed0a540854651e (patch) | |
| tree | c3eb6353851271730e5a3355fc70fbdb0a5fb346 /git_superproject.py | |
| parent | e81528649236ec9fb5983191767a96dc30acff54 (diff) | |
| download | git-repo-0e4f1e7fba4770908235e136c5ed0a540854651e.tar.gz | |
Use --negotiation-tip in superproject fetches.
Bug: b/260645739
Change-Id: Ib0cdbb13f130b91ab14df9c60a510f1e27cca8e0
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/354354
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Joanna Wang <jojwang@google.com>
Diffstat (limited to 'git_superproject.py')
| -rw-r--r-- | git_superproject.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/git_superproject.py b/git_superproject.py index 8b6bbcf9..7a4ca16b 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
| @@ -31,7 +31,7 @@ from typing import NamedTuple | |||
| 31 | 31 | ||
| 32 | from git_command import git_require, GitCommand | 32 | from git_command import git_require, GitCommand |
| 33 | from git_config import RepoConfig | 33 | from git_config import RepoConfig |
| 34 | from git_refs import R_HEADS | 34 | from git_refs import R_HEADS, GitRefs |
| 35 | 35 | ||
| 36 | _SUPERPROJECT_GIT_NAME = 'superproject.git' | 36 | _SUPERPROJECT_GIT_NAME = 'superproject.git' |
| 37 | _SUPERPROJECT_MANIFEST_NAME = 'superproject_override.xml' | 37 | _SUPERPROJECT_MANIFEST_NAME = 'superproject_override.xml' |
| @@ -181,6 +181,16 @@ class Superproject(object): | |||
| 181 | return False | 181 | return False |
| 182 | cmd = ['fetch', self._remote_url, '--depth', '1', '--force', '--no-tags', | 182 | cmd = ['fetch', self._remote_url, '--depth', '1', '--force', '--no-tags', |
| 183 | '--filter', 'blob:none'] | 183 | '--filter', 'blob:none'] |
| 184 | |||
| 185 | # Check if there is a local ref that we can pass to --negotiation-tip. | ||
| 186 | # If this is the first fetch, it does not exist yet. | ||
| 187 | # We use --negotiation-tip to speed up the fetch. Superproject branches do | ||
| 188 | # not share commits. So this lets git know it only needs to send commits | ||
| 189 | # reachable from the specified local refs. | ||
| 190 | rev_commit = GitRefs(self._work_git).get(f'refs/heads/{self.revision}') | ||
| 191 | if rev_commit: | ||
| 192 | cmd.extend(['--negotiation-tip', rev_commit]) | ||
| 193 | |||
| 184 | if self._branch: | 194 | if self._branch: |
| 185 | cmd += [self._branch + ':' + self._branch] | 195 | cmd += [self._branch + ':' + self._branch] |
| 186 | p = GitCommand(None, | 196 | p = GitCommand(None, |
