summaryrefslogtreecommitdiff
path: root/Annex
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-03-26 11:15:15 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-03-26 11:15:15 -0400
commit6244ee2a9d1a2509d68bf55d71c2f43e5009501f (patch)
treea67d31aae272e075410dd222b618dfab609b0d11 /Annex
parent4b803e23360b89187a1af7af023fda05e42c8d62 (diff)
Improve error message when --in @date is used and there is no reflog for the git-annex branch.
Diffstat (limited to 'Annex')
-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