mirror of
https://gerrit.googlesource.com/git-repo
synced 2025-01-02 16:14:25 +00:00
Avoid unnecessary git symbolic-ref calls during repo sync
If the m/BRANCH ref is already pointing at the value set in the manifest there is no reason to set it again. Leave it alone, thus saving a full fork+exec call. Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
parent
c12c360f89
commit
0f3dd233ec
14
git_refs.py
14
git_refs.py
@ -31,8 +31,7 @@ class GitRefs(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def all(self):
|
def all(self):
|
||||||
if self._phyref is None or self._NeedUpdate():
|
self._EnsureLoaded()
|
||||||
self._LoadAll()
|
|
||||||
return self._phyref
|
return self._phyref
|
||||||
|
|
||||||
def get(self, name):
|
def get(self, name):
|
||||||
@ -52,6 +51,17 @@ class GitRefs(object):
|
|||||||
if name in self._mtime:
|
if name in self._mtime:
|
||||||
del self._mtime[name]
|
del self._mtime[name]
|
||||||
|
|
||||||
|
def symref(self, name):
|
||||||
|
try:
|
||||||
|
self._EnsureLoaded()
|
||||||
|
return self._symref[name]
|
||||||
|
except KeyError:
|
||||||
|
return ''
|
||||||
|
|
||||||
|
def _EnsureLoaded(self):
|
||||||
|
if self._phyref is None or self._NeedUpdate():
|
||||||
|
self._LoadAll()
|
||||||
|
|
||||||
def _NeedUpdate(self):
|
def _NeedUpdate(self):
|
||||||
for name, mtime in self._mtime.iteritems():
|
for name, mtime in self._mtime.iteritems():
|
||||||
try:
|
try:
|
||||||
|
@ -997,13 +997,16 @@ class Project(object):
|
|||||||
if self.manifest.branch:
|
if self.manifest.branch:
|
||||||
msg = 'manifest set to %s' % self.revision
|
msg = 'manifest set to %s' % self.revision
|
||||||
ref = R_M + self.manifest.branch
|
ref = R_M + self.manifest.branch
|
||||||
|
cur = self.bare_ref.symref(ref)
|
||||||
|
|
||||||
if IsId(self.revision):
|
if IsId(self.revision):
|
||||||
|
if cur != '' or self.bare_ref.get(ref) != self.revision:
|
||||||
dst = self.revision + '^0'
|
dst = self.revision + '^0'
|
||||||
self.bare_git.UpdateRef(ref, dst, message = msg, detach = True)
|
self.bare_git.UpdateRef(ref, dst, message = msg, detach = True)
|
||||||
else:
|
else:
|
||||||
remote = self.GetRemote(self.remote.name)
|
remote = self.GetRemote(self.remote.name)
|
||||||
dst = remote.ToLocal(self.revision)
|
dst = remote.ToLocal(self.revision)
|
||||||
|
if cur != dst:
|
||||||
self.bare_git.symbolic_ref('-m', msg, ref, dst)
|
self.bare_git.symbolic_ref('-m', msg, ref, dst)
|
||||||
|
|
||||||
def _InitMirrorHead(self):
|
def _InitMirrorHead(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user