skip fetch while sync with alternates and --optimized-fetch
diff --git a/git_config.py b/git_config.py
index 0379181..1b75741 100644
--- a/git_config.py
+++ b/git_config.py
@@ -677,7 +677,7 @@
"""True if the remote stores to the tracking ref.
"""
for spec in self.fetch:
- if spec.DestMatches(ref):
+ if spec.SourceMatches(ref):
return True
return False
diff --git a/project.py b/project.py
index 2228234..cb477c9 100644
--- a/project.py
+++ b/project.py
@@ -1163,7 +1163,7 @@
self._UpdateHooks()
self._InitRemote()
- if is_new:
+ if is_new or optimized_fetch:
alt = os.path.join(self.gitdir, 'objects/info/alternates')
try:
fd = open(alt, 'rb')
@@ -1190,6 +1190,7 @@
elif self.manifest.default.sync_c:
current_branch_only = True
+ self.optimized_fetch = optimized_fetch
need_to_fetch = not (optimized_fetch and \
(ID_RE.match(self.revisionExpr) and self._CheckForSha1()))
if (need_to_fetch
@@ -1859,7 +1860,7 @@
if remote.PreConnectFetch():
ssh_proxy = True
- if initial:
+ if initial or self.optimized_fetch:
if alt_dir and 'objects' == os.path.basename(alt_dir):
ref_dir = os.path.dirname(alt_dir)
packed_refs = os.path.join(self.gitdir, 'packed-refs')
@@ -1872,7 +1873,7 @@
for r, ref_id in GitRefs(ref_dir).all.items():
if r not in all_refs:
if r.startswith(R_TAGS) or remote.WritesTo(r):
- all_refs[r] = ref_id
+ all_refs[remote.ToLocal(r)] = ref_id
ids.add(ref_id)
continue
@@ -1953,6 +1954,10 @@
ok = False
for _i in range(2):
+ if alt_dir and self.optimized_fetch:
+ ok = True
+ break
+
gitcmd = GitCommand(self, cmd, bare=True, ssh_proxy=ssh_proxy)
ret = gitcmd.Wait()
if ret == 0: