From 17dbd886616f82be2a59c0d02fd93d3d69f2392c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?M=C3=A1ximo=20Cuadros?= <mcuadros@gmail.com>
Date: Mon, 9 Mar 2020 23:08:48 +0100
Subject: [PATCH 1/2] *: add gh actions

---
 .github/workflows/test.yml | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 .github/workflows/test.yml

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 000000000..bf1651ee6
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,18 @@
+on: [push, pull_request]
+name: Test
+jobs:
+  test:
+    strategy:
+      matrix:
+        go-version: [1.12.x, 1.13.x, 1.14.x]
+        platform: [ubuntu-latest, macos-latest, windows-latest]
+    runs-on: ${{ matrix.platform }}
+    steps:
+    - name: Install Go
+      uses: actions/setup-go@v1
+      with:
+        go-version: ${{ matrix.go-version }}
+    - name: Checkout code
+      uses: actions/checkout@v2
+    - name: Test
+      run: go test -v ./...
\ No newline at end of file

From b93d667ece29b26cf120e258703c4b162ab13fbe Mon Sep 17 00:00:00 2001
From: David Symonds <dsymonds@golang.org>
Date: Thu, 21 Nov 2019 09:51:39 +1100
Subject: [PATCH 2/2] plumbing/object: avoid O(N^2) string building when
 decoding commit message

Most commits have relatively small messages, so this was never
noticeable. However, there are some repositories that have
semi-automated messages that can get very large (e.g.
github.com/riscv/riscv-clang and its riscv-trunk branch), on the order
of 109k lines. Changing from string += to using a bytes.Buffer reduces
the time for Commit.Decode for that specific case from 35s to 74ms.

Signed-off-by: David Symonds <dsymonds@golang.org>
---
 plumbing/object/commit.go | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go
index 6b5093405..eb86a0114 100644
--- a/plumbing/object/commit.go
+++ b/plumbing/object/commit.go
@@ -177,6 +177,7 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) {
 
 	var message bool
 	var pgpsig bool
+	var msgbuf bytes.Buffer
 	for {
 		line, err := r.ReadBytes('\n')
 		if err != nil && err != io.EOF {
@@ -221,13 +222,15 @@ func (c *Commit) Decode(o plumbing.EncodedObject) (err error) {
 				pgpsig = true
 			}
 		} else {
-			c.Message += string(line)
+			msgbuf.Write(line)
 		}
 
 		if err == io.EOF {
-			return nil
+			break
 		}
 	}
+	c.Message = msgbuf.String()
+	return nil
 }
 
 // Encode transforms a Commit into a plumbing.EncodedObject.