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

Function lsFilesCommand

commands/command_ls_files.go:37–180  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

35}
36
37func lsFilesCommand(cmd *cobra.Command, args []string) {
38 setupRepository()
39
40 var ref string
41 var includeRef string
42 var scanRange = false
43 if len(args) > 0 {
44 if lsFilesScanAll {
45 Exit(tr.Tr.Get("Cannot use --all with explicit reference"))
46 } else if args[0] == "--all" {
47 // Since --all is a valid argument to "git rev-parse",
48 // if we try to give it to git.ResolveRef below, we'll
49 // get an unexpected result.
50 //
51 // So, let's check early that the caller invoked the
52 // command correctly.
53 Exit(tr.Tr.Get("Did you mean `git lfs ls-files --all --` ?"))
54 }
55
56 ref = args[0]
57 if len(args) > 1 {
58 if lsFilesScanDeleted {
59 Exit(tr.Tr.Get("Cannot use --deleted with reference range"))
60 }
61 includeRef = args[1]
62 scanRange = true
63 }
64 } else {
65 fullref, err := git.CurrentRef()
66 if err != nil {
67 ref, err = git.EmptyTree()
68 if err != nil {
69 ExitWithError(errors.Wrap(
70 err, tr.Tr.Get("Could not read empty Git tree object")))
71 }
72 } else {
73 ref = fullref.Sha
74 }
75 }
76
77 showOidLen := 10
78 if longOIDs {
79 showOidLen = 64
80 }
81
82 seen := make(map[string]struct{})
83 var items []lsFilesObject
84
85 gitscanner := lfs.NewGitScanner(cfg, func(p *lfs.WrappedPointer, err error) {
86 if err != nil {
87 Exit(tr.Tr.Get("Could not scan for Git LFS tree: %s", err))
88 return
89 }
90
91 if p.Size == 0 {
92 return
93 }
94

Callers

nothing calls this directly

Calls 15

ScanIndexMethod · 0.95
ScanAllMethod · 0.95
ScanRefWithDeletedMethod · 0.95
ScanRefRangeMethod · 0.95
ScanTreeMethod · 0.95
CurrentRefFunction · 0.92
EmptyTreeFunction · 0.92
WrapFunction · 0.92
NewGitScannerFunction · 0.92
FormatBytesFunction · 0.92
setupRepositoryFunction · 0.85
ExitFunction · 0.85

Tested by

no test coverage detected