Commits

Stefan Saasen  committed e5a6e74

Set the git directory consistently

  • Participants
  • Parent commits 42d9bb5

Comments (0)

Files changed (2)

File src/Git/Remote.hs

 clone url =
     case parseRemote $ C.pack url of
         Just remote -> let gitRepoName = repositoryName remote
-                       in clone' (GitRepository gitRepoName gitRepoName) remote
+                       in clone' (GitRepository gitRepoName (gitRepoName </> ".git")) remote
         _           -> putStrLn $ "Invalid URL" ++ url
 
 

File src/Git/Store/ObjectStore.hs

 
 readHead :: GitRepository -> IO ObjectId
 readHead GitRepository{..}  = do
-    ref <- C.readFile (getGitDirectory </> ".git" </> "HEAD")
+    ref <- C.readFile (getGitDirectory </> "HEAD")
     -- TODO check if valid HEAD
     let unwrappedRef = C.unpack $ strip $ head $ tail $ C.split ':' ref
-    obj <- C.readFile (getGitDirectory </> ".git" </> unwrappedRef)
+    obj <- C.readFile (getGitDirectory </> unwrappedRef)
     return $ C.unpack $ strip obj
   where strip = C.takeWhile (not . isSpace) . C.dropWhile isSpace
 
     writeFile (dir </> name) (sha ++ "\n")
 
 pathForPack :: GitRepository -> FilePath
-pathForPack GitRepository{..} = getGitDirectory </> ".git" </> "objects" </> "pack"
+pathForPack GitRepository{..} = getGitDirectory </> "objects" </> "pack"
 
 pathForObject :: String -> String -> (FilePath, String)
 pathForObject repoName sha | length sha == 40 = (repoName </> ".git" </> "objects" </> pre, rest)
 -- sha1 $ header ++ content
 readObject :: GitRepository -> ObjectId -> IO (Maybe Object)
 readObject GitRepository{..} sha = do
-    let (path, name) = pathForObject getGitDirectory sha
+    let (path, name) = pathForObject getName sha
         filename     = path </> name
     exists <- trace ("readObject: " ++ filename) $ doesFileExist filename
     if exists then do