MCPcopy Index your code
hub / github.com/go-git/go-git / doAdd

Method doAdd

worktree_status.go:353–391  ·  view source on GitHub ↗
(path string, ignorePattern []gitignore.Pattern, skipStatus bool)

Source from the content-addressed store, hash-verified

351}
352
353func (w *Worktree) doAdd(path string, ignorePattern []gitignore.Pattern, skipStatus bool) (plumbing.Hash, error) {
354 idx, err := w.r.Storer.Index()
355 if err != nil {
356 return plumbing.ZeroHash, err
357 }
358
359 var h plumbing.Hash
360 var added bool
361
362 fi, err := w.Filesystem.Lstat(path)
363
364 // status is required for doAddDirectory
365 var s Status
366 var err2 error
367 if !skipStatus || fi == nil || fi.IsDir() {
368 s, err2 = w.Status()
369 if err2 != nil {
370 return plumbing.ZeroHash, err2
371 }
372 }
373
374 path = filepath.Clean(path)
375
376 if err != nil || !fi.IsDir() {
377 added, h, err = w.doAddFile(idx, s, path, ignorePattern)
378 } else {
379 added, err = w.doAddDirectory(idx, s, path, ignorePattern)
380 }
381
382 if err != nil {
383 return h, err
384 }
385
386 if !added {
387 return h, nil
388 }
389
390 return h, w.r.Storer.SetIndex(idx)
391}
392
393// AddGlob adds all paths, matching pattern, to the index. If pattern matches a
394// directory path, all directory contents are added to the index recursively. No

Callers 2

AddMethod · 0.95
AddWithOptionsMethod · 0.95

Calls 8

StatusMethod · 0.95
doAddFileMethod · 0.95
doAddDirectoryMethod · 0.95
CleanMethod · 0.80
IndexMethod · 0.65
IsDirMethod · 0.65
SetIndexMethod · 0.65
LstatMethod · 0.45

Tested by

no test coverage detected