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

Function processFiles

commands/command_merge_driver.go:49–94  ·  view source on GitHub ↗
(fileSpecifiers map[string]string, program string, outputFile string)

Source from the content-addressed store, hash-verified

47}
48
49func processFiles(fileSpecifiers map[string]string, program string, outputFile string) (int, error) {
50 defer mergeCleanup(fileSpecifiers)
51
52 var exitStatus int
53 formattedMergeProgram := subprocess.FormatPercentSequences(mergeDriverProgram, fileSpecifiers)
54 cmd, err := subprocess.ExecCommand("sh", "-c", formattedMergeProgram)
55 if err != nil {
56 return -1, errors.New(tr.Tr.Get("failed to run merge program %q: %s", formattedMergeProgram, err))
57 }
58 err = cmd.Run()
59 // If it runs but exits nonzero, then that means there's conflicts
60 if err != nil {
61 if exitError, ok := err.(*exec.ExitError); ok {
62 exitStatus = exitError.ProcessState.ExitCode()
63 } else {
64 return -1, errors.New(tr.Tr.Get("failed to run merge program %q: %s", formattedMergeProgram, err))
65 }
66 }
67
68 outputFp, err := os.OpenFile(outputFile, os.O_WRONLY|os.O_CREATE, 0600)
69 if err != nil {
70 return -1, err
71 }
72 defer outputFp.Close()
73
74 filename := fileSpecifiers["D"]
75
76 stat, err := os.Stat(filename)
77 if err != nil {
78 return -1, err
79 }
80
81 inputFp, err := os.OpenFile(filename, os.O_RDONLY|os.O_CREATE, 0600)
82 if err != nil {
83 return -1, err
84 }
85 defer inputFp.Close()
86
87 gf := lfs.NewGitFilter(cfg)
88 _, err = clean(gf, outputFp, inputFp, filename, stat.Size())
89 if err != nil {
90 return -1, err
91 }
92
93 return exitStatus, nil
94}
95
96func mergeCleanup(fileSpecifiers map[string]string) {
97 ids := []string{"A", "O", "B", "D"}

Callers 1

mergeDriverCommandFunction · 0.85

Calls 10

FormatPercentSequencesFunction · 0.92
ExecCommandFunction · 0.92
NewFunction · 0.92
NewGitFilterFunction · 0.92
mergeCleanupFunction · 0.85
cleanFunction · 0.85
SizeMethod · 0.80
GetMethod · 0.65
RunMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected