Skip to content

Commit 8e14304

Browse files
committed
Remove the duplicate directory check
We do already check each candidate if it is a folder before calling the git related functions.
1 parent 5485e98 commit 8e14304

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

internal/servegit/serve.go

-8
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,6 @@ func (s *Serve) handler() http.Handler {
132132

133133
// Checks if git thinks the given path is a valid .git folder for a repository
134134
func isBareRepo(path string) bool {
135-
if fi, err := os.Stat(path); err != nil || !fi.IsDir() {
136-
return false
137-
}
138-
139135
c := exec.Command("git", "--git-dir", path, "rev-parse", "--is-bare-repository")
140136
c.Dir = path
141137
out, err := c.CombinedOutput()
@@ -149,10 +145,6 @@ func isBareRepo(path string) bool {
149145

150146
// Check if git thinks the given path is a proper git checkout
151147
func isGitRepo(path string) bool {
152-
if fi, err := os.Stat(path); err != nil || !fi.IsDir() {
153-
return false
154-
}
155-
156148
// Executing git rev-parse --git-dir in the root of a worktree returns .git
157149
c := exec.Command("git", "rev-parse", "--git-dir")
158150
c.Dir = path

0 commit comments

Comments
 (0)