From 40a3fc47225c8f2d69bb71a693610f3693368c24 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Mon, 29 Apr 2024 21:56:58 +0000 Subject: [PATCH] Use get_config to look up whether a branch is dormant get_config is implemented by caching git config --list -z, rather than shelling out for every key one-by-one. This reduces git map-branches time on my machine from 1.2s to 0.6s. Change-Id: I999f4b893d248c2f71a36ec0f2594e0cdf08a248 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5498461 Commit-Queue: David Benjamin Reviewed-by: Gavin Mak --- git_map_branches.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/git_map_branches.py b/git_map_branches.py index fbf6092bc6..8b792f34ce 100755 --- a/git_map_branches.py +++ b/git_map_branches.py @@ -31,7 +31,7 @@ import sys from git_common import current_branch, upstream, tags, get_branches_info from git_common import get_git_version, MIN_UPSTREAM_TRACK_GIT_VERSION, hash_one -from git_common import run +from git_common import get_config, run import setup_color @@ -220,11 +220,7 @@ class BranchMapper(object): if '/' in branch: return False - is_dormant = run('config', - '--get', - 'branch.{}.dormant'.format(branch), - accepted_retcodes=[0, 1]) - return is_dormant == 'true' + return get_config(f'branch.{branch}.dormant') == 'true' def __append_branch(self, branch, output, depth=0): """Recurses through the tree structure and appends an OutputLine to the