log: Support --key, as well as --branch and --unused

--all remains a special case, since it is more efficient and displays in a
nicer order.

Sponsored-by: the NIH-funded NICEMAN (ReproNim TR&D3) project
This commit is contained in:
Joey Hess 2025-01-03 15:45:42 -04:00
parent e77934b920
commit 0815c82bb1
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 27 additions and 14 deletions

View file

@ -2,6 +2,7 @@ git-annex (10.20250103) UNRELEASED; urgency=medium
* Improve handing of ssh connection problems during
remote annex.uuid discovery.
* log: Support --key, as well as --branch and --unused.
-- Joey Hess <id@joeyh.name> Fri, 03 Jan 2025 14:30:38 -0400

View file

@ -46,7 +46,7 @@ cmd = withAnnexOptions [jsonOptions, annexedMatchingOptions] $
data LogOptions = LogOptions
{ logFiles :: CmdParams
, allOption :: Bool
, keyOptions :: Maybe KeyOptions
, sizesOfOption :: Maybe (DeferredParse UUID)
, sizesOption :: Bool
, totalSizesOption :: Bool
@ -62,11 +62,7 @@ data LogOptions = LogOptions
optParser :: CmdParamsDesc -> Parser LogOptions
optParser desc = LogOptions
<$> cmdParams desc
<*> switch
( long "all"
<> short 'A'
<> help "display location log changes to all files"
)
<*> optional parseKeyOptions
<*> optional ((parseUUIDOption <$> strOption
( long "sizesof"
<> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID)
@ -138,22 +134,24 @@ seek o = ifM (null <$> Annex.Branch.getUnmergedRefs)
zone <- liftIO getCurrentTimeZone
outputter <- mkOutputter m zone o <$> jsonOutputEnabled
let seeker = AnnexedFileSeeker
{ startAction = const $ start o outputter
{ startAction = const $ \si file key ->
start o outputter (si, key, mkActionItem (file, key))
, 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
case (logFiles o, keyOptions o) of
([], Just WantAllKeys) ->
commandAction (startAll o outputter)
(fs, ko) -> withKeyOptions ko False
seeker (commandAction . start o outputter)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww fs
([], True) -> commandAction (startAll o outputter)
(_, True) -> giveup "Cannot specify both files and --all"
start :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> SeekInput -> RawFilePath -> Key -> CommandStart
start o outputter si file key = do
start :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> (SeekInput, Key, ActionItem) -> CommandStart
start o outputter (si, key, ai) = do
(changes, cleanup) <- getKeyLog key (passthruOptions o)
let ai = mkActionItem (file, key)
showLogIncremental (outputter ai si) changes
void $ liftIO cleanup
stop

View file

@ -38,6 +38,18 @@ false, information may not have been committed to the branch yet.
In this mode, the names of files are not available and keys are displayed
instead.
* `--key=keyname`
Displays the location log for the specified key.
* `--branch=ref`
Displays the location log for the files in the specified branch or treeish.
* `--unused`
Displays the location log for files found by last run of git-annex unused.
* `--sizesof=repository`
Displays a history of the total size of the annexed files in a repository

View file

@ -13,3 +13,5 @@ In my case -- doing archaeology on AFNI's test data in [https://github.com/afni/
[[!meta author=yoh]]
[[!tag projects/repronim]]
> [[done]] --[[Joey]]