From 6244ee2a9d1a2509d68bf55d71c2f43e5009501f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Mar 2015 11:15:15 -0400 Subject: Improve error message when --in @date is used and there is no reflog for the git-annex branch. --- Annex/Branch.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'Annex/Branch.hs') 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 -- cgit v1.2.3