diff options
author | Joey Hess <joey@kitenet.net> | 2012-06-06 14:26:15 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-06-06 14:26:15 -0400 |
commit | 91db54076964979b6c50bd7efd0b895c4d416978 (patch) | |
tree | 7ba67f302dac7ef03b2cef906ab08bb88c0f8967 /Git/FilePath.hs | |
parent | 993e6459a38817a9062aafae7552a668c2db7a31 (diff) |
add support for staging other types of blobs, like symlinks, into the index
Also added a utility TopFilePath type, which could stand to be used more
widely.
Diffstat (limited to 'Git/FilePath.hs')
-rw-r--r-- | Git/FilePath.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/Git/FilePath.hs b/Git/FilePath.hs new file mode 100644 index 000000000..6344353d6 --- /dev/null +++ b/Git/FilePath.hs @@ -0,0 +1,34 @@ +{- git FilePath library + - + - Different git commands use different types of FilePaths to refer to + - files in the repository. Some commands use paths relative to the + - top of the repository even when run in a subdirectory. Adding some + - types helps keep that straight. + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Git.FilePath ( + TopFilePath, + getTopFilePath, + toTopFilePath, + asTopFilePath, +) where + +import Common +import Git + +{- A FilePath, relative to the top of the git repository. -} +newtype TopFilePath = TopFilePath { getTopFilePath :: FilePath } + +{- The input FilePath can be absolute, or relative to the CWD. -} +toTopFilePath :: FilePath -> Git.Repo -> IO TopFilePath +toTopFilePath file repo = TopFilePath <$> + relPathDirToFile (repoPath repo) <$> absPath file + +{- The input FilePath must already be relative to the top of the git + - repository -} +asTopFilePath :: FilePath -> TopFilePath +asTopFilePath file = TopFilePath file |