From f88282ccc2f20e0f0498901a796eb82a5640daf9 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Tue, 28 Sep 2021 15:59:40 -0400 Subject: [PATCH] git_config: update error handling with no config file Now that _do throws an exception when `git` fails, update the logic that tries to read config files but the file doesn't exist. Bug: b/192664812 Change-Id: I6417ecd70891b8f2d5f2bdb819f91df69ac4b70c Test: `repo upload` no longer crashes when .repo/config doesn't exist Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319295 Reviewed-by: Jack Neus Tested-by: Mike Frysinger --- git_config.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/git_config.py b/git_config.py index bc70d160..3cd09391 100644 --- a/git_config.py +++ b/git_config.py @@ -371,9 +371,10 @@ class GitConfig(object): """ c = {} - d = self._do('--null', '--list') - if d is None: + if not os.path.exists(self.file): return c + + d = self._do('--null', '--list') for line in d.rstrip('\0').split('\0'): if '\n' in line: key, val = line.split('\n', 1)