aboutsummaryrefslogtreecommitdiff
path: root/object
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-29 17:21:26 +0000
committerGravatar Runxi Yu2026-03-29 17:48:35 +0000
commitd0505e1e9ada529331e964664afe6effad8c3140 (patch)
tree3ea89dee8ced6980dee76e7e3c35716e98838ad7 /object
parentobject/signed: Add docs (diff)
signatureNo signature
object/signed/commit: Fix whitespace
Diffstat (limited to 'object')
-rw-r--r--object/signed/commit/integration_test.go4
-rw-r--r--object/signed/commit/parse.go3
-rw-r--r--object/signed/commit/unit_test.go4
3 files changed, 11 insertions, 0 deletions
diff --git a/object/signed/commit/integration_test.go b/object/signed/commit/integration_test.go
index 2a8d6a4c..82b34b14 100644
--- a/object/signed/commit/integration_test.go
+++ b/object/signed/commit/integration_test.go
@@ -21,6 +21,7 @@ func setupSSHSignedCommit(
testRepo := testgit.NewRepo(t, testgit.RepoOptions{ObjectFormat: algo})
signDir := t.TempDir()
+
signRoot, err := os.OpenRoot(signDir)
if err != nil {
t.Fatalf("os.OpenRoot(%q): %v", signDir, err)
@@ -40,6 +41,7 @@ func setupSSHSignedCommit(
"-C", "runxiyu@umich.edu",
"-f", privateKeyPath,
) //#nosec G204
+
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("ssh-keygen generate failed: %v\n%s", err, out)
@@ -102,6 +104,7 @@ func TestSSHSignedCommitIntegration(t *testing.T) {
"-s", signaturePath,
) //#nosec G204
cmd.Stdin = bytes.NewReader(payload)
+
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("ssh-keygen verify failed: %v\n%s", err, out)
@@ -126,6 +129,7 @@ func TestSSHSignedCommitIntegrationRejectsTamperedPayload(t *testing.T) {
"-s", signaturePath,
) //#nosec G204
cmd.Stdin = bytes.NewReader(payload)
+
out, err := cmd.CombinedOutput()
if err == nil {
t.Fatalf("ssh-keygen verify unexpectedly succeeded:\n%s", out)
diff --git a/object/signed/commit/parse.go b/object/signed/commit/parse.go
index 1714327f..fa498093 100644
--- a/object/signed/commit/parse.go
+++ b/object/signed/commit/parse.go
@@ -25,6 +25,7 @@ func Parse(body []byte) (*Commit, error) {
rel := bytes.IndexByte(body[i:], '\n')
next := len(body)
+
lineEnd := len(body)
if rel >= 0 {
lineEnd = i + rel
@@ -63,6 +64,7 @@ func Parse(body []byte) (*Commit, error) {
for i < len(body) {
rel := bytes.IndexByte(body[i:], '\n')
next = len(body)
+
lineEnd = len(body)
if rel >= 0 {
lineEnd = i + rel
@@ -70,6 +72,7 @@ func Parse(body []byte) (*Commit, error) {
}
contStart := i
+
cont := body[contStart:lineEnd]
if len(cont) == 0 || cont[0] != ' ' {
break
diff --git a/object/signed/commit/unit_test.go b/object/signed/commit/unit_test.go
index 6bbd6cd0..88d4fa3b 100644
--- a/object/signed/commit/unit_test.go
+++ b/object/signed/commit/unit_test.go
@@ -40,6 +40,7 @@ func TestParseUpstreamMultiplySignedCommit(t *testing.T) {
}
gotPayload := string(commit.AppendPayload(nil))
+
wantPayload := "" +
"tree 0cfbf08886fca9a91cb753ec8734c84fcbe52c9f\n" +
"parent 9da738312d24ef0a29be2c8c2b6fc5cf7085a293\n" +
@@ -86,6 +87,7 @@ func TestParseUpstreamMultiplySignedCommit(t *testing.T) {
}
gotAlgorithms := commit.Algorithms()
+
wantAlgorithms := []objectid.Algorithm{
objectid.AlgorithmSHA1,
objectid.AlgorithmSHA256,
@@ -111,6 +113,7 @@ func TestParseStripsUnknownGpgsigHeadersFromPayload(t *testing.T) {
}
gotPayload := string(commit.AppendPayload(nil))
+
wantPayload := "" +
"tree deadbeef\n" +
"\n" +
@@ -142,6 +145,7 @@ func TestParseAllowsDuplicateSignatureHeaders(t *testing.T) {
}
gotPayload := string(commit.AppendPayload(nil))
+
wantPayload := "" +
"tree deadbeef\n" +
"\n" +