diff --git a/gitcred.go b/gitcred.go index ce4745d..6f8d8dc 100644 --- a/gitcred.go +++ b/gitcred.go @@ -118,13 +118,9 @@ func (gc *GitCredential) Unmarshal(r io.Reader) error { func (gc *GitCredential) Marshal(w io.Writer) error { var err error marshal := func(k, v string) { - if err != nil { - return + if err == nil && v != "" { + _, err = fmt.Fprintf(w, "%s=%s\n", k, v) } - if v == "" { - return - } - _, err = fmt.Fprintf(w, "%s=%s\n", k, v) } marshal("protocol", gc.Protocol) marshal("host", gc.Host)