summaryrefslogtreecommitdiff
path: root/Annex/Branch.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Annex/Branch.hs')
-rw-r--r--Annex/Branch.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/Annex/Branch.hs b/Annex/Branch.hs
index 7cd86c581..7411e7010 100644
--- a/Annex/Branch.hs
+++ b/Annex/Branch.hs
@@ -38,6 +38,7 @@ import Annex.Index
import qualified Git
import qualified Git.Command
import qualified Git.Ref
+import qualified Git.RefLog
import qualified Git.Sha
import qualified Git.Branch
import qualified Git.UnionMerge
@@ -205,7 +206,13 @@ getRaw :: FilePath -> Annex String
getRaw = getRef fullname
getHistorical :: RefDate -> FilePath -> Annex String
-getHistorical date = getRef (Git.Ref.dateRef fullname date)
+getHistorical date file =
+ -- This check avoids some ugly error messages when the reflog
+ -- is empty.
+ ifM (null <$> inRepo (Git.RefLog.get' [Param "-n1"] fullname))
+ ( error ("No reflog for " ++ fromRef fullname)
+ , getRef (Git.Ref.dateRef fullname date) file
+ )
getRef :: Ref -> FilePath -> Annex String
getRef ref file = withIndex $ decodeBS <$> catFile ref file