MCPcopy Create free account
hub / github.com/sinclairtarget/git-who / GetRoot

Function GetRoot

internal/git/git.go:154–180  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

152}
153
154func GetRoot() (_ string, err error) {
155 defer func() {
156 if err != nil {
157 err = fmt.Errorf("failed to get Git root directory: %w", err)
158 }
159 }()
160
161 ctx, cancel := context.WithCancel(context.Background())
162 defer cancel()
163
164 subprocess, err := cmd.RunRevParseTopLevel(ctx)
165 if err != nil {
166 return "", err
167 }
168
169 root, err := subprocess.StdoutText()
170 if err != nil {
171 return "", err
172 }
173
174 err = subprocess.Wait()
175 if err != nil {
176 return "", err
177 }
178
179 return root, nil
180}
181
182// Returns all paths in the working tree under the given pathspecs.
183func WorkingTreeFiles(pathspecs []string) (_ map[string]bool, err error) {

Callers 5

HistFunction · 0.92
TreeFunction · 0.92
TableFunction · 0.92
ParseFunction · 0.92
DumpFunction · 0.92

Calls 3

RunRevParseTopLevelFunction · 0.92
StdoutTextMethod · 0.80
WaitMethod · 0.80

Tested by

no test coverage detected