MCPcopy Index your code
hub / github.com/sinclairtarget/git-who / WorkingTreeFiles

Function WorkingTreeFiles

internal/git/git.go:183–216  ·  view source on GitHub ↗

Returns all paths in the working tree under the given pathspecs.

(pathspecs []string)

Source from the content-addressed store, hash-verified

181
182// Returns all paths in the working tree under the given pathspecs.
183func WorkingTreeFiles(pathspecs []string) (_ map[string]bool, err error) {
184 defer func() {
185 if err != nil {
186 err = fmt.Errorf("error getting tree files: %w", err)
187 }
188 }()
189
190 ctx, cancel := context.WithCancel(context.Background())
191 defer cancel()
192
193 wtreeset := map[string]bool{}
194
195 subprocess, err := cmd.RunLsFiles(ctx, pathspecs)
196 if err != nil {
197 return wtreeset, err
198 }
199
200 lines, finish := subprocess.StdoutNullDelimitedLines()
201 for line := range lines {
202 wtreeset[line] = true
203 }
204
205 err = finish()
206 if err != nil {
207 return wtreeset, err
208 }
209
210 err = subprocess.Wait()
211 if err != nil {
212 return wtreeset, err
213 }
214
215 return wtreeset, nil
216}
217
218// Returns all commits in the input iterator, but for each commit, strips out
219// any file diff not modifying one of the given pathspecs

Callers 1

TreeFunction · 0.92

Calls 3

RunLsFilesFunction · 0.92
WaitMethod · 0.80

Tested by

no test coverage detected