aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/merkletrie/difftree_test.go23
-rw-r--r--utils/merkletrie/noder/path.go10
-rw-r--r--utils/merkletrie/noder/path_test.go8
3 files changed, 31 insertions, 10 deletions
diff --git a/utils/merkletrie/difftree_test.go b/utils/merkletrie/difftree_test.go
index ab0eb57..ac86145 100644
--- a/utils/merkletrie/difftree_test.go
+++ b/utils/merkletrie/difftree_test.go
@@ -475,8 +475,29 @@ func (s *DiffTreeSuite) TestIssue275(c *C) {
})
}
+func (s *DiffTreeSuite) TestIssue1057(c *C) {
+ p1 := "TestAppWithUnicodéPath"
+ p2 := "TestAppWithUnicodéPath"
+ c.Assert(p1 == p2, Equals, false)
+ do(c, []diffTreeTest{
+ {
+ fmt.Sprintf("(%s(x.go<1>))", p1),
+ fmt.Sprintf("(%s(x.go<1>) %s(x.go<1>))", p1, p2),
+ fmt.Sprintf("+%s/x.go", p2),
+ },
+ })
+ // swap p1 with p2
+ do(c, []diffTreeTest{
+ {
+ fmt.Sprintf("(%s(x.go<1>))", p2),
+ fmt.Sprintf("(%s(x.go<1>) %s(x.go<1>))", p1, p2),
+ fmt.Sprintf("+%s/x.go", p1),
+ },
+ })
+}
+
func (s *DiffTreeSuite) TestCancel(c *C) {
- t := diffTreeTest{"()", "(a<> b<1> c() d<> e<2> f())", "+a +b +d +e"}
+ t := diffTreeTest{"()", "(a<> b<1> c() d<> e<2> f())", "+a +b +d +e"}
comment := Commentf("\n%s", "test cancel:")
a, err := fsnoder.New(t.from)
diff --git a/utils/merkletrie/noder/path.go b/utils/merkletrie/noder/path.go
index e9c905c..1c7ef54 100644
--- a/utils/merkletrie/noder/path.go
+++ b/utils/merkletrie/noder/path.go
@@ -3,8 +3,6 @@ package noder
import (
"bytes"
"strings"
-
- "golang.org/x/text/unicode/norm"
)
// Path values represent a noder and its ancestors. The root goes first
@@ -80,11 +78,9 @@ func (p Path) Compare(other Path) int {
case i == len(p):
return -1
default:
- form := norm.Form(norm.NFC)
- this := form.String(p[i].Name())
- that := form.String(other[i].Name())
-
- cmp := strings.Compare(this, that)
+ // We do *not* normalize Unicode here. CGit doesn't.
+ // https://github.com/src-d/go-git/issues/1057
+ cmp := strings.Compare(p[i].Name(), other[i].Name())
if cmp != 0 {
return cmp
}
diff --git a/utils/merkletrie/noder/path_test.go b/utils/merkletrie/noder/path_test.go
index be25444..f49f028 100644
--- a/utils/merkletrie/noder/path_test.go
+++ b/utils/merkletrie/noder/path_test.go
@@ -156,6 +156,10 @@ func (s *PathSuite) TestCompareMixedDepths(c *C) {
func (s *PathSuite) TestCompareNormalization(c *C) {
p1 := Path([]Noder{&noderMock{name: norm.Form(norm.NFKC).String("페")}})
p2 := Path([]Noder{&noderMock{name: norm.Form(norm.NFKD).String("페")}})
- c.Assert(p1.Compare(p2), Equals, 0)
- c.Assert(p2.Compare(p1), Equals, 0)
+ c.Assert(p1.Compare(p2), Equals, 1)
+ c.Assert(p2.Compare(p1), Equals, -1)
+ p1 = Path([]Noder{&noderMock{name: "TestAppWithUnicodéPath"}})
+ p2 = Path([]Noder{&noderMock{name: "TestAppWithUnicodéPath"}})
+ c.Assert(p1.Compare(p2), Equals, -1)
+ c.Assert(p2.Compare(p1), Equals, 1)
}