@@ -24,6 +24,9 @@ import (
2424 "gopkg.in/src-d/go-billy.v4/osfs"
2525)
2626
27+ // GitDirName this is a special folder where all the git stuff is.
28+ const GitDirName = ".git"
29+
2730var (
2831 // ErrBranchExists an error stating the specified branch already exists
2932 ErrBranchExists = errors .New ("branch already exists" )
@@ -113,12 +116,12 @@ func createDotGitFile(worktree, storage billy.Filesystem) error {
113116 path = storage .Root ()
114117 }
115118
116- if path == ".git" {
119+ if path == GitDirName {
117120 // not needed, since the folder is the default place
118121 return nil
119122 }
120123
121- f , err := worktree .Create (".git" )
124+ f , err := worktree .Create (GitDirName )
122125 if err != nil {
123126 return err
124127 }
@@ -214,7 +217,7 @@ func PlainInit(path string, isBare bool) (*Repository, error) {
214217 dot = osfs .New (path )
215218 } else {
216219 wt = osfs .New (path )
217- dot , _ = wt .Chroot (".git" )
220+ dot , _ = wt .Chroot (GitDirName )
218221 }
219222
220223 s , err := filesystem .NewStorage (dot )
@@ -265,7 +268,7 @@ func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem,
265268 var fi os.FileInfo
266269 for {
267270 fs = osfs .New (path )
268- fi , err = fs .Stat (".git" )
271+ fi , err = fs .Stat (GitDirName )
269272 if err == nil {
270273 // no error; stop
271274 break
@@ -288,7 +291,7 @@ func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem,
288291 }
289292
290293 if fi .IsDir () {
291- dot , err = fs .Chroot (".git" )
294+ dot , err = fs .Chroot (GitDirName )
292295 return dot , fs , err
293296 }
294297
@@ -301,7 +304,7 @@ func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem,
301304}
302305
303306func dotGitFileToOSFilesystem (path string , fs billy.Filesystem ) (bfs billy.Filesystem , err error ) {
304- f , err := fs .Open (".git" )
307+ f , err := fs .Open (GitDirName )
305308 if err != nil {
306309 return nil , err
307310 }
0 commit comments