summaryrefslogtreecommitdiffstats
path: root/project.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-03-11 23:24:01 -0500
committerMike Frysinger <vapier@google.com>2021-03-12 05:28:06 +0000
commita3794e9c6f2b05f7801b24f4a897a55f750f2b67 (patch)
treedff83291de0b41368725b6e1ecb9d932f60c31a6 /project.py
parent080877e41347b8987977fc8cc3ec90dcd149651a (diff)
downloadgit-repo-a3794e9c6f2b05f7801b24f4a897a55f750f2b67.tar.gz
prune: minor optimization & robustification
If the current project doesn't have any local branches, then there's nothing to prune, so return right away. This avoids running a few git commands when we aren't actually going to use the results, and it avoids checking repository validity. Since we aren't going to do anything in here, no need to check it. Change-Id: Ie9d5c75a954e42807477299f3e5a63a92fac138b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/299742 Reviewed-by: Jonathan Nieder <jrn@google.com> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'project.py')
-rw-r--r--project.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/project.py b/project.py
index 45b6c636..bc385f20 100644
--- a/project.py
+++ b/project.py
@@ -1698,6 +1698,11 @@ class Project(object):
1698 if cb is None or name != cb: 1698 if cb is None or name != cb:
1699 kill.append(name) 1699 kill.append(name)
1700 1700
1701 # Minor optimization: If there's nothing to prune, then don't try to read
1702 # any project state.
1703 if not kill and not cb:
1704 return []
1705
1701 rev = self.GetRevisionId(left) 1706 rev = self.GetRevisionId(left)
1702 if cb is not None \ 1707 if cb is not None \
1703 and not self._revlist(HEAD + '...' + rev) \ 1708 and not self._revlist(HEAD + '...' + rev) \