MCPcopy
hub / github.com/git-lfs/git-lfs / RewriteLocalPathAsURL

Function RewriteLocalPathAsURL

git/git.go:618–644  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

616}
617
618func RewriteLocalPathAsURL(path string) string {
619 var slash string
620 if abs, err := filepath.Abs(path); err == nil {
621 // Required for Windows paths to work.
622 if !strings.HasPrefix(abs, "/") {
623 slash = "/"
624 }
625 path = abs
626 }
627
628 var gitpath string
629 if filepath.Base(path) == ".git" {
630 gitpath = path
631 path = filepath.Dir(path)
632 } else {
633 gitpath = filepath.Join(path, ".git")
634 }
635
636 if _, err := os.Stat(gitpath); err == nil {
637 path = gitpath
638 } else if _, err := os.Stat(path); err != nil {
639 // Not a local path. We check down here because we perform
640 // canonicalization by stripping off the .git above.
641 return path
642 }
643 return fmt.Sprintf("file://%s%s", slash, filepath.ToSlash(path))
644}
645
646func UpdateIndexFromStdin() (*subprocess.Cmd, error) {
647 return git("update-index", "-q", "--refresh", "--stdin")

Callers 3

EndpointFromLocalPathFunction · 0.92
SetValidRemoteMethod · 0.92
SetValidPushRemoteMethod · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected