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

Function newSingleCheckout

commands/pull.go:25–46  ·  view source on GitHub ↗

Handles the process of checking out a single file, and updating the git index. Note that the current working directory will be changed to the root of the working tree, unless no work tree exists (e.g., the repository is bare and GIT_WORK_TREE is not defined), in which case Run() is a no-op.

(gitEnv config.Environment, remote string)

Source from the content-addressed store, hash-verified

23// of the working tree, unless no work tree exists (e.g., the repository
24// is bare and GIT_WORK_TREE is not defined), in which case Run() is a no-op.
25func newSingleCheckout(gitEnv config.Environment, remote string) abstractCheckout {
26 clean, ok := gitEnv.Get("filter.lfs.clean")
27 if !ok || len(clean) == 0 {
28 return &noOpCheckout{remote: remote}
29 }
30
31 workingDir := cfg.LocalWorkingDir()
32 hasWorkTree := workingDir != ""
33 if hasWorkTree {
34 if err := os.Chdir(workingDir); err != nil {
35 FullError(errors.Wrap(err, tr.Tr.Get("Checkout error trying to change directory: %s", workingDir)))
36 hasWorkTree = false
37 }
38 }
39
40 return &singleCheckout{
41 gitIndexer: &gitIndexer{},
42 hasWorkTree: hasWorkTree,
43 manifest: nil,
44 remote: remote,
45 }
46}
47
48type abstractCheckout interface {
49 Manifest() tq.Manifest

Callers 3

checkoutCommandFunction · 0.85
checkoutConflictFunction · 0.85
pullFunction · 0.85

Calls 4

WrapFunction · 0.92
FullErrorFunction · 0.85
LocalWorkingDirMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected