aboutsummaryrefslogtreecommitdiffstats
path: root/worktree_test.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-02-14 12:35:30 +0100
committerGitHub <noreply@github.com>2019-02-14 12:35:30 +0100
commitdb6c41c156481962abf9a55a324858674c25ab08 (patch)
tree6f1b155a059fd9f623473d61305a81ab5efa596b /worktree_test.go
parent4d8bd13a73d6efd41b6be0b2eba5130c498fae0d (diff)
parentc40fcefddec1d07fb5a06c2173b409f37f7409d1 (diff)
downloadgo-git-db6c41c156481962abf9a55a324858674c25ab08.tar.gz
Merge pull request #1065 from vmarkovtsev/fix-unicodev4.10.0
Remove Unicode normalization in difftree
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 26b7da0..872cd82 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()