aboutsummaryrefslogtreecommitdiff
path: root/Git/FilePath.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Git/FilePath.hs')
-rw-r--r--Git/FilePath.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/Git/FilePath.hs b/Git/FilePath.hs
index db576fc8e..ffa333107 100644
--- a/Git/FilePath.hs
+++ b/Git/FilePath.hs
@@ -14,6 +14,8 @@
module Git.FilePath (
TopFilePath,
+ BranchFilePath(..),
+ descBranchFilePath,
getTopFilePath,
fromTopFilePath,
toTopFilePath,
@@ -33,6 +35,13 @@ import qualified System.FilePath.Posix
newtype TopFilePath = TopFilePath { getTopFilePath :: FilePath }
deriving (Show, Eq, Ord)
+{- A file in a branch or other treeish. -}
+data BranchFilePath = BranchFilePath Ref TopFilePath
+
+{- Git uses the branch:file form to refer to a BranchFilePath -}
+descBranchFilePath :: BranchFilePath -> String
+descBranchFilePath (BranchFilePath b f) = fromRef b ++ ':' : getTopFilePath f
+
{- Path to a TopFilePath, within the provided git repo. -}
fromTopFilePath :: TopFilePath -> Git.Repo -> FilePath
fromTopFilePath p repo = combine (repoPath repo) (getTopFilePath p)