diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/config.go | 2 | ||||
-rw-r--r-- | config/config_test.go | 24 |
2 files changed, 26 insertions, 0 deletions
diff --git a/config/config.go b/config/config.go index 6d41c15..26acd58 100644 --- a/config/config.go +++ b/config/config.go @@ -252,6 +252,7 @@ const ( extensionsSection = "extensions" fetchKey = "fetch" urlKey = "url" + pushurlKey = "pushurl" bareKey = "bare" worktreeKey = "worktree" commentCharKey = "commentChar" @@ -633,6 +634,7 @@ func (c *RemoteConfig) unmarshal(s *format.Subsection) error { c.Name = c.raw.Name c.URLs = append([]string(nil), c.raw.Options.GetAll(urlKey)...) + c.URLs = append([]string(nil), c.raw.Options.GetAll(pushurlKey)...) c.Fetch = fetch c.Mirror = c.raw.Options.Get(mirrorKey) == "true" diff --git a/config/config_test.go b/config/config_test.go index 7e9483f..6f011e0 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -371,3 +371,27 @@ func (s *ConfigSuite) TestRemoveUrlOptions(c *C) { } c.Assert(err, IsNil) } + +func (s *ConfigSuite) TestUnmarshalRemotes(c *C) { + input := []byte(`[core] + bare = true + worktree = foo + custom = ignored +[user] + name = John Doe + email = john@example.com +[remote "origin"] + url = https://git.sr.ht/~mcepl/go-git + pushurl = git@git.sr.ht:~mcepl/go-git.git + fetch = +refs/heads/*:refs/remotes/origin/* + mirror = true +`) + + cfg := NewConfig() + err := cfg.Unmarshal(input) + c.Assert(err, IsNil) + + c.Assert(cfg.Remotes["origin"].URLs[0], Equals, "https://git.sr.ht/~mcepl/go-git") + c.Assert(cfg.Remotes["origin"].URLs[1], Equals, "git@git.sr.ht:~mcepl/go-git.git") +} + |