diff options
author | Mike Frysinger <vapier@google.com> | 2021-09-28 15:59:40 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@google.com> | 2021-09-29 01:02:47 +0000 |
commit | f88282ccc2f20e0f0498901a796eb82a5640daf9 (patch) | |
tree | 72c094254abb46f1f2d3b4c1ebcebfcd6fea8116 | |
parent | 8967a5aec621672ee7acab16aa37efcfa7435ea9 (diff) | |
download | git-repo-f88282ccc2f20e0f0498901a796eb82a5640daf9.tar.gz |
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 <jackneus@google.com>
Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r-- | git_config.py | 5 |
1 files 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): | |||
371 | 371 | ||
372 | """ | 372 | """ |
373 | c = {} | 373 | c = {} |
374 | d = self._do('--null', '--list') | 374 | if not os.path.exists(self.file): |
375 | if d is None: | ||
376 | return c | 375 | return c |
376 | |||
377 | d = self._do('--null', '--list') | ||
377 | for line in d.rstrip('\0').split('\0'): | 378 | for line in d.rstrip('\0').split('\0'): |
378 | if '\n' in line: | 379 | if '\n' in line: |
379 | key, val = line.split('\n', 1) | 380 | key, val = line.split('\n', 1) |