summaryrefslogtreecommitdiffstats
path: root/git_config.py
diff options
context:
space:
mode:
authorJosef Malmström <josef.malmstrom@arm.com>2026-05-04 14:11:46 +0200
committergerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2026-05-13 00:00:27 -0700
commit003f0407fc5a301105a457f5ddc9773f1224cc97 (patch)
tree34b3f9612ab576b02293a67f6b1893587723324e /git_config.py
parent1db50e49fb7f99a61f7a3ceee3e1f6289208e249 (diff)
downloadgit-repo-003f0407fc5a301105a457f5ddc9773f1224cc97.tar.gz
Fix missing `None` check in Remote.Save
This code was causing an exception in cases where `pushUrl` was set but `projectname` was not. This can happen when `pushUrl` is set for the manifest repo which does not have a `projectname`. For example: repo init --manifest-url ssh://url.to/my/manifest cd .repo/manifests git config remote.origin.pushurl ssh://url.to/my/manifest repo init --manifest-url ssh://url.to/my/manifest --repo-rev main The last `repo init` invocation causes an error. Change-Id: Ibb68c8446880cfbac22feee595d1fd1b678c7ade Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/579162 Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Josef Malmstrom <Josef.Malmstrom@arm.com> Tested-by: Josef Malmstrom <Josef.Malmstrom@arm.com> Reviewed-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'git_config.py')
-rw-r--r--git_config.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/git_config.py b/git_config.py
index d2c88514b..9b3188f1e 100644
--- a/git_config.py
+++ b/git_config.py
@@ -724,7 +724,10 @@ class Remote:
724 def Save(self): 724 def Save(self):
725 """Save this remote to the configuration.""" 725 """Save this remote to the configuration."""
726 self._Set("url", self.url) 726 self._Set("url", self.url)
727 if self.pushUrl is not None: 727 # projectname is initialized for projects listed in the manifest, but
728 # not for others (e.g. the manifest project). This class is used for
729 # all of them.
730 if self.pushUrl is not None and self.projectname is not None:
728 self._Set("pushurl", self.pushUrl + "/" + self.projectname) 731 self._Set("pushurl", self.pushUrl + "/" + self.projectname)
729 else: 732 else:
730 self._Set("pushurl", self.pushUrl) 733 self._Set("pushurl", self.pushUrl)