diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2024-03-19 19:47:48 +0800 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2024-03-19 19:47:48 +0800 |
commit | 4b47032686c52de5bf2324c1b1d4151c5fd6c41b (patch) | |
tree | 85098e25c0a4ad383f267fd59d591346d5e09a17 /Git/Index.hs | |
parent | 34f99f9355c275917ff91539bbdac60a56ad7e17 (diff) | |
parent | 4993eab4a4507d52037ff74c67f6ca04d2401b5e (diff) | |
download | git-repair-4b47032686c52de5bf2324c1b1d4151c5fd6c41b.tar.gz |
Merge tag '1.20230814'
tagging package git-repair version 1.20230814
Diffstat (limited to 'Git/Index.hs')
-rw-r--r-- | Git/Index.hs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/Git/Index.hs b/Git/Index.hs index afd29c2..b55fc04 100644 --- a/Git/Index.hs +++ b/Git/Index.hs @@ -5,6 +5,8 @@ - Licensed under the GNU AGPL version 3 or higher. -} +{-# LANGUAGE OverloadedStrings #-} + module Git.Index where import Common @@ -12,6 +14,8 @@ import Git import Utility.Env import Utility.Env.Set +import qualified System.FilePath.ByteString as P + indexEnv :: String indexEnv = "GIT_INDEX_FILE" @@ -26,8 +30,8 @@ indexEnv = "GIT_INDEX_FILE" - - So, an absolute path is the only safe option for this to return. -} -indexEnvVal :: FilePath -> IO String -indexEnvVal = absPath +indexEnvVal :: RawFilePath -> IO String +indexEnvVal p = fromRawFilePath <$> absPath p {- Forces git to use the specified index file. - @@ -36,7 +40,7 @@ indexEnvVal = absPath - - Warning: Not thread safe. -} -override :: FilePath -> Repo -> IO (IO ()) +override :: RawFilePath -> Repo -> IO (IO ()) override index _r = do res <- getEnv var val <- indexEnvVal index @@ -48,13 +52,13 @@ override index _r = do reset _ = unsetEnv var {- The normal index file. Does not check GIT_INDEX_FILE. -} -indexFile :: Repo -> FilePath -indexFile r = fromRawFilePath (localGitDir r) </> "index" +indexFile :: Repo -> RawFilePath +indexFile r = localGitDir r P.</> "index" {- The index file git will currently use, checking GIT_INDEX_FILE. -} -currentIndexFile :: Repo -> IO FilePath -currentIndexFile r = fromMaybe (indexFile r) <$> getEnv indexEnv +currentIndexFile :: Repo -> IO RawFilePath +currentIndexFile r = maybe (indexFile r) toRawFilePath <$> getEnv indexEnv {- Git locks the index by creating this file. -} -indexFileLock :: FilePath -> FilePath -indexFileLock f = f ++ ".lock" +indexFileLock :: RawFilePath -> RawFilePath +indexFileLock f = f <> ".lock" |