Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2020-09-24 13:01:09 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2020-10-15 14:48:12 +0300
commit658eaa2e301fad2a244301d5fcf268f32e7f4e17 (patch)
treeef50753c7561f1a08031c7a4d89ddecc7fa72176 /internal/git2go
parent831cb43987a98e817ce88d5c0b26ad345c07418b (diff)
git2go: Store conflict contents as bytes
When conflicts occur, it's not necessarily the case that the conflict's contents are valid UTF-8, as conflicting files may have different encodings. But as we're serializing and deserializing those contents as strings, any such encoding issues may get stripped away and cause us to end up with conflict contents which don't really represent the actual conflict. Fix this by using a byte array for conflict contents instead of a string.
Diffstat (limited to 'internal/git2go')
-rw-r--r--internal/git2go/conflicts.go2
-rw-r--r--internal/git2go/conflicts_test.go4
2 files changed, 3 insertions, 3 deletions
diff --git a/internal/git2go/conflicts.go b/internal/git2go/conflicts.go
index 1b2d2658b..79f732be5 100644
--- a/internal/git2go/conflicts.go
+++ b/internal/git2go/conflicts.go
@@ -36,7 +36,7 @@ type Conflict struct {
// Their is the conflict entry of theirs.
Their ConflictEntry `json:"their"`
// Content contains the conflicting merge results.
- Content string `json:"content"`
+ Content []byte `json:"content"`
}
// ConflictsResult contains all conflicts resulting from a merge.
diff --git a/internal/git2go/conflicts_test.go b/internal/git2go/conflicts_test.go
index fe1268445..4061598bf 100644
--- a/internal/git2go/conflicts_test.go
+++ b/internal/git2go/conflicts_test.go
@@ -89,7 +89,7 @@ func TestConflictsResult_Serialization(t *testing.T) {
Ancestor: ConflictEntry{Path: "dir/ancestor", Mode: 0100644},
Our: ConflictEntry{Path: "dir/our", Mode: 0100644},
Their: ConflictEntry{Path: "dir/their", Mode: 0100644},
- Content: "content",
+ Content: []byte("content"),
},
},
}),
@@ -99,7 +99,7 @@ func TestConflictsResult_Serialization(t *testing.T) {
Ancestor: ConflictEntry{Path: "dir/ancestor", Mode: 0100644},
Our: ConflictEntry{Path: "dir/our", Mode: 0100644},
Their: ConflictEntry{Path: "dir/their", Mode: 0100644},
- Content: "content",
+ Content: []byte("content"),
},
},
},