Improve error message when --in @date is used and there is no reflog for the git-annex branch.

This commit is contained in:
Joey Hess 2015-03-26 11:15:15 -04:00
parent f0ff3a08ea
commit 3af4691978
4 changed files with 23 additions and 7 deletions

View file

@ -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

View file

@ -14,9 +14,14 @@ import Git.Sha
{- Gets the reflog for a given branch. -}
get :: Branch -> Repo -> IO [Sha]
get b = mapMaybe extractSha . lines <$$> pipeReadStrict
[ Param "log"
, Param "-g"
, Param "--format=%H"
, Param (fromRef b)
]
get = get' []
get' :: [CommandParam] -> Branch -> Repo -> IO [Sha]
get' ps b = mapMaybe extractSha . lines <$$> pipeReadStrict ps'
where
ps' =
[ Param "log"
, Param "-g"
, Param "--format=%H"
, Param (fromRef b)
] ++ ps

2
debian/changelog vendored
View file

@ -12,6 +12,8 @@ git-annex (5.20150318) UNRELEASED; urgency=medium
* --auto is no longer a global option; only get, drop, and copy
accept it. (Not a behavior change unless you were passing it to a
command that ignored it.)
* Improve error message when --in @date is used and there is no
reflog for the git-annex branch.
-- Joey Hess <id@joeyh.name> Thu, 19 Mar 2015 17:05:32 -0400

View file

@ -31,3 +31,5 @@ git-annex: fd:9: hFlush: resource vanished (Broken pipe)
# End of transcript or log.
"""]]
> [[fixed|done]] --[[Joey]]