(c *C)
| 563 | } |
| 564 | |
| 565 | func (s *WorktreeSuite) TestFilenameNormalization(c *C) { |
| 566 | if runtime.GOOS == "windows" { |
| 567 | c.Skip("windows paths may contain non utf-8 sequences") |
| 568 | } |
| 569 | |
| 570 | url := c.MkDir() |
| 571 | |
| 572 | path := fixtures.Basic().ByTag("worktree").One().Worktree().Root() |
| 573 | |
| 574 | server, err := PlainClone(url, false, &CloneOptions{ |
| 575 | URL: path, |
| 576 | }) |
| 577 | c.Assert(err, IsNil) |
| 578 | |
| 579 | filename := "페" |
| 580 | |
| 581 | w, err := server.Worktree() |
| 582 | c.Assert(err, IsNil) |
| 583 | |
| 584 | writeFile := func(path string) { |
| 585 | err := util.WriteFile(w.Filesystem, path, []byte("foo"), 0755) |
| 586 | c.Assert(err, IsNil) |
| 587 | } |
| 588 | |
| 589 | writeFile(filename) |
| 590 | origHash, err := w.Add(filename) |
| 591 | c.Assert(err, IsNil) |
| 592 | _, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()}) |
| 593 | c.Assert(err, IsNil) |
| 594 | |
| 595 | r, err := Clone(memory.NewStorage(), memfs.New(), &CloneOptions{ |
| 596 | URL: url, |
| 597 | }) |
| 598 | c.Assert(err, IsNil) |
| 599 | |
| 600 | w, err = r.Worktree() |
| 601 | c.Assert(err, IsNil) |
| 602 | |
| 603 | status, err := w.Status() |
| 604 | c.Assert(err, IsNil) |
| 605 | c.Assert(status.IsClean(), Equals, true) |
| 606 | |
| 607 | err = w.Filesystem.Remove(filename) |
| 608 | c.Assert(err, IsNil) |
| 609 | |
| 610 | modFilename := norm.NFKD.String(filename) |
| 611 | writeFile(modFilename) |
| 612 | |
| 613 | _, err = w.Add(filename) |
| 614 | c.Assert(err, IsNil) |
| 615 | modHash, err := w.Add(modFilename) |
| 616 | c.Assert(err, IsNil) |
| 617 | // At this point we've got two files with the same content. |
| 618 | // Hence their hashes must be the same. |
| 619 | c.Assert(origHash == modHash, Equals, true) |
| 620 | |
| 621 | status, err = w.Status() |
| 622 | c.Assert(err, IsNil) |
nothing calls this directly
no test coverage detected