From 058193adc6858777e42f5e4a9345a3005b9c96b2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 27 Dec 2021 15:44:15 -0400 Subject: [PATCH] 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 --- Command/Log.hs | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Command/Log.hs b/Command/Log.hs index b4d99b5f72..4a87154a76 100644 --- a/Command/Log.hs +++ b/Command/Log.hs @@ -1,6 +1,6 @@ {- git-annex command - - - Copyright 2012, 2016 Joey Hess + - Copyright 2012-2021 Joey Hess - - Licensed under the GNU AGPL version 3 or higher. -} @@ -82,22 +82,25 @@ optParser desc = LogOptions mkpassthru n v = [Param ("--" ++ n), Param v] seek :: LogOptions -> CommandSeek -seek o = do - m <- Remote.uuidDescriptions - zone <- liftIO getCurrentTimeZone - let outputter = mkOutputter m zone o - let seeker = AnnexedFileSeeker - { startAction = start o outputter - , checkContentPresent = Nothing - -- the way this uses the location log would not be helped - -- by precaching the current value - , usesLocationLog = False - } - case (logFiles o, allOption o) of - (fs, False) -> withFilesInGitAnnex ww seeker - =<< workTreeItems ww fs - ([], True) -> commandAction (startAll o outputter) - (_, True) -> giveup "Cannot specify both files and --all" +seek o = ifM (null <$> Annex.Branch.getUnmergedRefs) + ( do + m <- Remote.uuidDescriptions + zone <- liftIO getCurrentTimeZone + let outputter = mkOutputter m zone o + let seeker = AnnexedFileSeeker + { startAction = start o outputter + , checkContentPresent = Nothing + -- the way this uses the location log would not be + -- helped by precaching the current value + , usesLocationLog = False + } + case (logFiles o, allOption o) of + (fs, False) -> withFilesInGitAnnex ww seeker + =<< workTreeItems ww fs + ([], True) -> commandAction (startAll o outputter) + (_, 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 ww = WarnUnmatchLsFiles