prevent git-annex log with read-only unmerged git-annex branches

It would display incomplete information, which would differ from the
information displayed with write access. So refuse to display anything.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2021-12-27 15:44:15 -04:00
parent 23a485498f
commit 058193adc6
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -1,6 +1,6 @@
{- git-annex command {- git-annex command
- -
- Copyright 2012, 2016 Joey Hess <id@joeyh.name> - Copyright 2012-2021 Joey Hess <id@joeyh.name>
- -
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
@ -82,15 +82,16 @@ optParser desc = LogOptions
mkpassthru n v = [Param ("--" ++ n), Param v] mkpassthru n v = [Param ("--" ++ n), Param v]
seek :: LogOptions -> CommandSeek seek :: LogOptions -> CommandSeek
seek o = do seek o = ifM (null <$> Annex.Branch.getUnmergedRefs)
( do
m <- Remote.uuidDescriptions m <- Remote.uuidDescriptions
zone <- liftIO getCurrentTimeZone zone <- liftIO getCurrentTimeZone
let outputter = mkOutputter m zone o let outputter = mkOutputter m zone o
let seeker = AnnexedFileSeeker let seeker = AnnexedFileSeeker
{ startAction = start o outputter { startAction = start o outputter
, checkContentPresent = Nothing , checkContentPresent = Nothing
-- the way this uses the location log would not be helped -- the way this uses the location log would not be
-- by precaching the current value -- helped by precaching the current value
, usesLocationLog = False , usesLocationLog = False
} }
case (logFiles o, allOption o) of case (logFiles o, allOption o) of
@ -98,6 +99,8 @@ seek o = do
=<< workTreeItems ww fs =<< workTreeItems ww fs
([], True) -> commandAction (startAll o outputter) ([], True) -> commandAction (startAll o outputter)
(_, True) -> giveup "Cannot specify both files and --all" (_, True) -> giveup "Cannot specify both files and --all"
, giveup "This repository is read-only, and there are unmerged git-annex branches, which prevents displaying location log changes. (Set annex.merge-annex-branches to false to ignore the unmerged git-annex branches.)"
)
where where
ww = WarnUnmatchLsFiles ww = WarnUnmatchLsFiles