From a3794e9c6f2b05f7801b24f4a897a55f750f2b67 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 11 Mar 2021 23:24:01 -0500 Subject: [PATCH] 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 Tested-by: Mike Frysinger --- project.py | 5 +++++ 1 file changed, 5 insertions(+) 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): if cb is None or name != cb: kill.append(name) + # Minor optimization: If there's nothing to prune, then don't try to read + # any project state. + if not kill and not cb: + return [] + rev = self.GetRevisionId(left) if cb is not None \ and not self._revlist(HEAD + '...' + rev) \