diff options
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 } } |