MCPcopy Index your code
hub / github.com/git-lfs/git-lfs / GetFilesChanged

Function GetFilesChanged

git/git.go:1566–1604  ·  view source on GitHub ↗

GetFilesChanged returns a list of files which were changed, either between 2 commits, or at a single commit if you only supply one argument and a blank string for the other

(from, to string)

Source from the content-addressed store, hash-verified

1564// commits, or at a single commit if you only supply one argument and a blank
1565// string for the other
1566func GetFilesChanged(from, to string) ([]string, error) {
1567 var files []string
1568 args := []string{
1569 "-c", "core.quotepath=false", // handle special chars in filenames
1570 "diff-tree",
1571 "--no-commit-id",
1572 "--name-only",
1573 "-r",
1574 }
1575
1576 if len(from) > 0 {
1577 args = append(args, from)
1578 }
1579 if len(to) > 0 {
1580 args = append(args, to)
1581 }
1582 args = append(args, "--") // no ambiguous patterns
1583
1584 cmd, err := gitNoLFS(args...)
1585 if err != nil {
1586 return nil, errors.New(tr.Tr.Get("failed to find `git diff-tree`: %v", err))
1587 }
1588 outp, err := cmd.StdoutPipe()
1589 if err != nil {
1590 return nil, errors.New(tr.Tr.Get("failed to call `git diff-tree`: %v", err))
1591 }
1592 if err := cmd.Start(); err != nil {
1593 return nil, errors.New(tr.Tr.Get("failed to start `git diff-tree`: %v", err))
1594 }
1595 scanner := bufio.NewScanner(outp)
1596 for scanner.Scan() {
1597 files = append(files, strings.TrimSpace(scanner.Text()))
1598 }
1599 if err := cmd.Wait(); err != nil {
1600 return nil, errors.New(tr.Tr.Get("`git diff-tree` failed: %v", err))
1601 }
1602
1603 return files, err
1604}
1605
1606// IsFileModified returns whether the filepath specified is modified according
1607// to `git status`. A file is modified if it has uncommitted changes in the

Callers 3

postCheckoutRevChangeFunction · 0.92
postCommitCommandFunction · 0.92
TestGetFilesChangesFunction · 0.85

Calls 7

NewFunction · 0.92
gitNoLFSFunction · 0.85
StdoutPipeMethod · 0.80
GetMethod · 0.65
ScanMethod · 0.65
WaitMethod · 0.65
StartMethod · 0.45

Tested by 1

TestGetFilesChangesFunction · 0.68