aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorVadim Markovtsev <vadim@sourced.tech>2019-02-11 21:13:44 +0100
committerVadim Markovtsev <vadim@sourced.tech>2019-02-11 22:57:16 +0100
commitc40fcefddec1d07fb5a06c2173b409f37f7409d1 (patch)
tree18a8e6da1502054fe49509f4e342398c06f82a95 /worktree_test.go
parentcd64b4d630b6c2d2b3d72e9615e14f9d58bb5787 (diff)
downloadgo-git-c40fcefddec1d07fb5a06c2173b409f37f7409d1.tar.gz
Remove Unicode normalization in difftree
Fixes #1057 Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Diffstat (limited to 'worktree_test.go')
-rw-r--r--worktree_test.go35
1 files changed, 31 insertions, 4 deletions
diff --git a/worktree_test.go b/worktree_test.go
index c714011..5c5aef9 100644
--- a/worktree_test.go
+++ b/worktree_test.go
@@ -365,8 +365,14 @@ func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
w, err := server.Worktree()
c.Assert(err, IsNil)
- util.WriteFile(w.Filesystem, filename, []byte("foo"), 0755)
- _, err = w.Add(filename)
+
+ writeFile := func(path string) {
+ err := util.WriteFile(w.Filesystem, path, []byte("foo"), 0755)
+ c.Assert(err, IsNil)
+ }
+
+ writeFile(filename)
+ origHash, err := w.Add(filename)
c.Assert(err, IsNil)
_, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()})
c.Assert(err, IsNil)
@@ -387,11 +393,32 @@ func (s *WorktreeSuite) TestFilenameNormalization(c *C) {
c.Assert(err, IsNil)
modFilename := norm.Form(norm.NFKD).String(filename)
- util.WriteFile(w.Filesystem, modFilename, []byte("foo"), 0755)
+ writeFile(modFilename)
+
+ _, err = w.Add(filename)
+ c.Assert(err, IsNil)
+ modHash, err := w.Add(modFilename)
+ c.Assert(err, IsNil)
+ // At this point we've got two files with the same content.
+ // Hence their hashes must be the same.
+ c.Assert(origHash == modHash, Equals, true)
+ status, err = w.Status()
+ c.Assert(err, IsNil)
+ // However, their names are different and the work tree is still dirty.
+ c.Assert(status.IsClean(), Equals, false)
+
+ // Revert back the deletion of the first file.
+ writeFile(filename)
_, err = w.Add(filename)
c.Assert(err, IsNil)
- _, err = w.Add(modFilename)
+
+ status, err = w.Status()
+ c.Assert(err, IsNil)
+ // Still dirty - the second file is added.
+ c.Assert(status.IsClean(), Equals, false)
+
+ _, err = w.Remove(modFilename)
c.Assert(err, IsNil)
status, err = w.Status()