summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-07-20 15:22:55 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-07-20 15:23:43 -0400
commit258a3356e6461e0164441bb3a3e202cb9ef889e6 (patch)
treef198f34aaedeffb1af624f918a214527b066175a /Git
parente97cd57e1ac72d5a240852704ebaf92716fcad94 (diff)
--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.
Diffstat (limited to 'Git')
-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)