(c *C)
| 507 | } |
| 508 | |
| 509 | func (s *WorktreeSuite) TestFilenameNormalization(c *C) { |
| 510 | if runtime.GOOS == "windows" { |
| 511 | c.Skip("windows paths may contain non utf-8 sequences") |
| 512 | } |
| 513 | |
| 514 | url, clean := s.TemporalDir() |
| 515 | defer clean() |
| 516 | |
| 517 | path := fixtures.Basic().ByTag("worktree").One().Worktree().Root() |
| 518 | |
| 519 | server, err := PlainClone(url, false, &CloneOptions{ |
| 520 | URL: path, |
| 521 | }) |
| 522 | c.Assert(err, IsNil) |
| 523 | |
| 524 | filename := "페" |
| 525 | |
| 526 | w, err := server.Worktree() |
| 527 | c.Assert(err, IsNil) |
| 528 | |
| 529 | writeFile := func(path string) { |
| 530 | err := util.WriteFile(w.Filesystem, path, []byte("foo"), 0755) |
| 531 | c.Assert(err, IsNil) |
| 532 | } |
| 533 | |
| 534 | writeFile(filename) |
| 535 | origHash, err := w.Add(filename) |
| 536 | c.Assert(err, IsNil) |
| 537 | _, err = w.Commit("foo", &CommitOptions{Author: defaultSignature()}) |
| 538 | c.Assert(err, IsNil) |
| 539 | |
| 540 | r, err := Clone(memory.NewStorage(), memfs.New(), &CloneOptions{ |
| 541 | URL: url, |
| 542 | }) |
| 543 | c.Assert(err, IsNil) |
| 544 | |
| 545 | w, err = r.Worktree() |
| 546 | c.Assert(err, IsNil) |
| 547 | |
| 548 | status, err := w.Status() |
| 549 | c.Assert(err, IsNil) |
| 550 | c.Assert(status.IsClean(), Equals, true) |
| 551 | |
| 552 | err = w.Filesystem.Remove(filename) |
| 553 | c.Assert(err, IsNil) |
| 554 | |
| 555 | modFilename := norm.NFKD.String(filename) |
| 556 | writeFile(modFilename) |
| 557 | |
| 558 | _, err = w.Add(filename) |
| 559 | c.Assert(err, IsNil) |
| 560 | modHash, err := w.Add(modFilename) |
| 561 | c.Assert(err, IsNil) |
| 562 | // At this point we've got two files with the same content. |
| 563 | // Hence their hashes must be the same. |
| 564 | c.Assert(origHash == modHash, Equals, true) |
| 565 | |
| 566 | status, err = w.Status() |
nothing calls this directly
no test coverage detected