summaryrefslogtreecommitdiff
path: root/Git
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-06 12:43:56 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-06 12:43:56 -0400
commitebb16a8c45f5ec12aff6fd158090d6a36d5590dc (patch)
treedf6630b4844709e8266f330a875857d395c03454 /Git
parentd6a25390ad9006d3c8eeeefd535703626dd09490 (diff)
--in can now refer to files that were located in a repository at some past date. For example, --in="here@{yesterday}"
Diffstat (limited to 'Git')
-rw-r--r--Git/Ref.hs5
-rw-r--r--Git/Types.hs4
2 files changed, 9 insertions, 0 deletions
diff --git a/Git/Ref.hs b/Git/Ref.hs
index 09472930f..88717ce47 100644
--- a/Git/Ref.hs
+++ b/Git/Ref.hs
@@ -11,6 +11,7 @@ import Common
import Git
import Git.Command
import Git.Sha
+import Git.Types
import Data.Char (chr)
@@ -51,6 +52,10 @@ underBase dir r = Ref $ dir ++ "/" ++ show (base r)
fileRef :: FilePath -> Ref
fileRef f = Ref $ ":./" ++ f
+{- Converts a Ref to refer to the content of the Ref on a given date. -}
+dateRef :: Ref -> RefDate -> Ref
+dateRef (Ref r) (RefDate d) = Ref $ r ++ "@" ++ d
+
{- A Ref that can be used to refer to a file in the repository as it
- appears in a given Ref. -}
fileFromRef :: Ref -> FilePath -> Ref
diff --git a/Git/Types.hs b/Git/Types.hs
index e63e93077..d805d8574 100644
--- a/Git/Types.hs
+++ b/Git/Types.hs
@@ -57,6 +57,10 @@ type Branch = Ref
type Sha = Ref
type Tag = Ref
+{- A date in the format described in gitrevisions. Includes the
+ - braces, eg, "{yesterday}" -}
+newtype RefDate = RefDate String
+
{- Types of objects that can be stored in git. -}
data ObjectType = BlobObject | CommitObject | TreeObject
deriving (Eq)