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

Function changeToWorkingCopy

commands/commands.go:346–365  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

344}
345
346func changeToWorkingCopy() {
347 workingDir := cfg.LocalWorkingDir()
348 cwd, err := tools.Getwd()
349 if err != nil {
350 ExitWithError(errors.Wrap(
351 err, tr.Tr.Get("Could not determine current working directory")))
352 }
353 cwd, err = tools.CanonicalizeSystemPath(cwd)
354 if err != nil {
355 ExitWithError(errors.Wrap(
356 err, tr.Tr.Get("Could not canonicalize current working directory")))
357 }
358
359 // If the current working directory is not within the repository's
360 // working directory, then let's change directories accordingly. This
361 // should only occur if GIT_WORK_TREE is set.
362 if !(strings.HasPrefix(cwd, workingDir) && (cwd == workingDir || (len(cwd) > len(workingDir) && cwd[len(workingDir)] == os.PathSeparator))) {
363 os.Chdir(workingDir)
364 }
365}
366
367func canonicalizeEnvironment() {
368 vars := []string{"GIT_INDEX_FILE", "GIT_OBJECT_DIRECTORY", "GIT_DIR", "GIT_WORK_TREE", "GIT_COMMON_DIR"}

Callers 2

setupRepositoryFunction · 0.85
setupWorkingCopyFunction · 0.85

Calls 6

GetwdFunction · 0.92
WrapFunction · 0.92
CanonicalizeSystemPathFunction · 0.92
ExitWithErrorFunction · 0.85
LocalWorkingDirMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected