aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-08-17 11:17:46 +0200
committerGitHub <noreply@github.com>2018-08-17 11:17:46 +0200
commit7b6c1266556f59ac436fada3fa6106d4a84f9b56 (patch)
treef2f9226dc9436848c4b4855f65d91bd89dc987da /plumbing
parentba0f659cbf9982846de731cca426ce2498601130 (diff)
parent39954f2d9310204cc586715def7f075296a21d4c (diff)
downloadgo-git-7b6c1266556f59ac436fada3fa6106d4a84f9b56.tar.gz
Merge pull request #920 from vancluever/f-add-commit-signkeyv4.6.0
git: Add ability to PGP sign commits
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/object/commit.go14
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
}
}