From 258a3356e6461e0164441bb3a3e202cb9ef889e6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 20 Jul 2016 15:22:55 -0400 Subject: --branch, stage 2 Show branch:file that is being operated on. I had to make ActionItem a type and not a type class because withKeyOptions' passed two different types of values when using the type class, and I could not get the type checker to accept that. --- Git/FilePath.hs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Git') 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) -- cgit v1.2.3