diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-07-19 22:04:46 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-19 22:04:46 +0200 |
commit | 8738a04708b91683d5804b4c648c871fdeb87f82 (patch) | |
tree | 017b15080dee8bd64026c9358d832e61d12674d5 /plumbing/format/config/encoder.go | |
parent | 595dfe6e53a038da4949263ea2d9a7a0020c48b7 (diff) | |
parent | 4a7e7cddc0e4f88085b263693c87635254de7f35 (diff) | |
download | go-git-8738a04708b91683d5804b4c648c871fdeb87f82.tar.gz |
Merge pull request #493 from src-d/windows
*: several windows support fixes
Diffstat (limited to 'plumbing/format/config/encoder.go')
-rw-r--r-- | plumbing/format/config/encoder.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plumbing/format/config/encoder.go b/plumbing/format/config/encoder.go index 88bdf65..6d17a5a 100644 --- a/plumbing/format/config/encoder.go +++ b/plumbing/format/config/encoder.go @@ -3,6 +3,7 @@ package config import ( "fmt" "io" + "strings" ) // An Encoder writes config files to an output stream. @@ -61,7 +62,12 @@ func (e *Encoder) encodeSubsection(sectionName string, s *Subsection) error { func (e *Encoder) encodeOptions(opts Options) error { for _, o := range opts { - if err := e.printf("\t%s = %s\n", o.Key, o.Value); err != nil { + pattern := "\t%s = %s\n" + if strings.Index(o.Value, "\\") != -1 { + pattern = "\t%s = %q\n" + } + + if err := e.printf(pattern, o.Key, o.Value); err != nil { return err } } |