diff options
author | Chris Marchesi <chrism@vancluevertech.com> | 2018-08-16 17:41:03 -0700 |
---|---|---|
committer | Chris Marchesi <chrism@vancluevertech.com> | 2018-08-16 17:53:22 -0700 |
commit | ec3d2a817d7cf43696a42d8460c7a8957a12a57b (patch) | |
tree | f558dd12bfa141139c981e042b83eca65650a484 | |
parent | a28c2ce44695f13ddf28748958f236afd8e0b544 (diff) | |
download | go-git-ec3d2a817d7cf43696a42d8460c7a8957a12a57b.tar.gz |
plumbing: object, Don't add new line at end of commit signature
The way that commit signatures were being written out was causing an
extra newline to be written at the end of the commit when the message
encoding was already taking care of this. Ultimately, this results in a
corrupt object, rendering the object unverifiable with the signature in
the commit.
Signed-off-by: Chris Marchesi <chrism@vancluevertech.com>
-rw-r--r-- | plumbing/object/commit.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go index b1c0e01..00ae3f1 100644 --- a/plumbing/object/commit.go +++ b/plumbing/object/commit.go @@ -263,18 +263,18 @@ func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) { } if b.PGPSignature != "" && includeSig { - if _, err = fmt.Fprint(w, "\n"+headerpgp); err != nil { + if _, err = fmt.Fprint(w, "\n"+headerpgp+" "); err != nil { return err } - // Split all the signature lines and write with a left padding and - // newline at the end. + // Split all the signature lines and re-write with a left padding and + // newline. Use join for this so it's clear that a newline should not be + // added after this section, as it will be added when the message is + // printed. signature := strings.TrimSuffix(b.PGPSignature, "\n") lines := strings.Split(signature, "\n") - for _, line := range lines { - if _, err = fmt.Fprintf(w, " %s\n", line); err != nil { - return err - } + if _, err = fmt.Fprint(w, strings.Join(lines, "\n ")); err != nil { + return err } } |