aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-03-01 13:53:12 +0100
committerMichael Muré <batolettre@gmail.com>2020-03-01 13:53:12 +0100
commiteeeb932b718ed4764df544ce85888461fc1377fb (patch)
treefd014af4507e2d73669ddc39a50aba72e599b64d
parent60bf8e0d6e8b0b7769f0eb34b2506f8e4adbe433 (diff)
downloadgit-bug-eeeb932b718ed4764df544ce85888461fc1377fb.tar.gz
git: fix GetRemote to not break when there is no remotes
-rw-r--r--repository/git.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/repository/git.go b/repository/git.go
index d4560805..1eb3b8b5 100644
--- a/repository/git.go
+++ b/repository/git.go
@@ -197,9 +197,12 @@ func (repo *GitRepo) GetRemotes() (map[string]string, error) {
remotes := make(map[string]string, len(lines))
for _, line := range lines {
+ if strings.TrimSpace(line) == "" {
+ continue
+ }
elements := strings.Fields(line)
if len(elements) != 3 {
- return nil, fmt.Errorf("unexpected output format: %s", line)
+ return nil, fmt.Errorf("git remote: unexpected output format: %s", line)
}
remotes[elements[0]] = elements[1]