MCPcopy Create free account
hub / github.com/go-git/go-git / windowsValidPath

Function windowsValidPath

worktree.go:467–489  ·  view source on GitHub ↗
(part string)

Source from the content-addressed store, hash-verified

465}
466
467func windowsValidPath(part string) bool {
468 if len(part) > 3 && strings.EqualFold(part[:4], GitDirName) {
469 // For historical reasons, file names that end in spaces or periods are
470 // automatically trimmed. Therefore, `.git . . ./` is a valid way to refer
471 // to `.git/`.
472 if windowsPathReplacer.Replace(part[4:]) == "" {
473 return false
474 }
475
476 // For yet other historical reasons, NTFS supports so-called "Alternate Data
477 // Streams", i.e. metadata associated with a given file, referred to via
478 // `<filename>:<stream-name>:<stream-type>`. There exists a default stream
479 // type for directories, allowing `.git/` to be accessed via
480 // `.git::$INDEX_ALLOCATION/`.
481 //
482 // For performance reasons, _all_ Alternate Data Streams of `.git/` are
483 // forbidden, not just `::$INDEX_ALLOCATION`.
484 if len(part) > 4 && part[4:5] == ":" {
485 return false
486 }
487 }
488 return true
489}
490
491func (w *Worktree) validChange(ch merkletrie.Change) error {
492 action, err := ch.Action()

Callers 2

validPathFunction · 0.85
TestWindowsValidPathFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestWindowsValidPathFunction · 0.68