diff options
author | Joey Hess <joeyh@joeyh.name> | 2015-03-26 11:15:15 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2015-03-26 11:15:15 -0400 |
commit | 6244ee2a9d1a2509d68bf55d71c2f43e5009501f (patch) | |
tree | a67d31aae272e075410dd222b618dfab609b0d11 | |
parent | 4b803e23360b89187a1af7af023fda05e42c8d62 (diff) |
Improve error message when --in @date is used and there is no reflog for the git-annex branch.
-rw-r--r-- | Annex/Branch.hs | 9 | ||||
-rw-r--r-- | Git/RefLog.hs | 17 | ||||
-rw-r--r-- | debian/changelog | 2 | ||||
-rw-r--r-- | doc/bugs/Using_date_matching_options_gives_scary_error_messaes_on_empty_reflog.mdwn | 2 |
4 files changed, 23 insertions, 7 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 diff --git a/Git/RefLog.hs b/Git/RefLog.hs index f3a9dad38..7c20047ad 100644 --- a/Git/RefLog.hs +++ b/Git/RefLog.hs @@ -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 diff --git a/debian/changelog b/debian/changelog index 7add96dac..79810d546 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 diff --git a/doc/bugs/Using_date_matching_options_gives_scary_error_messaes_on_empty_reflog.mdwn b/doc/bugs/Using_date_matching_options_gives_scary_error_messaes_on_empty_reflog.mdwn index 487849f78..006de8300 100644 --- a/doc/bugs/Using_date_matching_options_gives_scary_error_messaes_on_empty_reflog.mdwn +++ b/doc/bugs/Using_date_matching_options_gives_scary_error_messaes_on_empty_reflog.mdwn @@ -31,3 +31,5 @@ git-annex: fd:9: hFlush: resource vanished (Broken pipe) # End of transcript or log. """]] + +> [[fixed|done]] --[[Joey]] |