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 * Improve handing of ssh connection problems during
remote annex.uuid discovery. 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 -- 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 data LogOptions = LogOptions
{ logFiles :: CmdParams { logFiles :: CmdParams
, allOption :: Bool , keyOptions :: Maybe KeyOptions
, sizesOfOption :: Maybe (DeferredParse UUID) , sizesOfOption :: Maybe (DeferredParse UUID)
, sizesOption :: Bool , sizesOption :: Bool
, totalSizesOption :: Bool , totalSizesOption :: Bool
@ -62,11 +62,7 @@ data LogOptions = LogOptions
optParser :: CmdParamsDesc -> Parser LogOptions optParser :: CmdParamsDesc -> Parser LogOptions
optParser desc = LogOptions optParser desc = LogOptions
<$> cmdParams desc <$> cmdParams desc
<*> switch <*> optional parseKeyOptions
( long "all"
<> short 'A'
<> help "display location log changes to all files"
)
<*> optional ((parseUUIDOption <$> strOption <*> optional ((parseUUIDOption <$> strOption
( long "sizesof" ( long "sizesof"
<> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID) <> metavar (paramRemote `paramOr` paramDesc `paramOr` paramUUID)
@ -138,22 +134,24 @@ seek o = ifM (null <$> Annex.Branch.getUnmergedRefs)
zone <- liftIO getCurrentTimeZone zone <- liftIO getCurrentTimeZone
outputter <- mkOutputter m zone o <$> jsonOutputEnabled outputter <- mkOutputter m zone o <$> jsonOutputEnabled
let seeker = AnnexedFileSeeker let seeker = AnnexedFileSeeker
{ startAction = const $ start o outputter { startAction = const $ \si file key ->
start o outputter (si, key, mkActionItem (file, key))
, checkContentPresent = Nothing , checkContentPresent = Nothing
-- the way this uses the location log would not be -- the way this uses the location log would not be
-- helped by precaching the current value -- helped by precaching the current value
, usesLocationLog = False , usesLocationLog = False
} }
case (logFiles o, allOption o) of case (logFiles o, keyOptions o) of
(fs, False) -> withFilesInGitAnnex ww seeker ([], Just WantAllKeys) ->
commandAction (startAll o outputter)
(fs, ko) -> withKeyOptions ko False
seeker (commandAction . start o outputter)
(withFilesInGitAnnex ww seeker)
=<< workTreeItems ww fs =<< 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 :: LogOptions -> (ActionItem -> SeekInput -> Outputter) -> (SeekInput, Key, ActionItem) -> CommandStart
start o outputter si file key = do start o outputter (si, key, ai) = do
(changes, cleanup) <- getKeyLog key (passthruOptions o) (changes, cleanup) <- getKeyLog key (passthruOptions o)
let ai = mkActionItem (file, key)
showLogIncremental (outputter ai si) changes showLogIncremental (outputter ai si) changes
void $ liftIO cleanup void $ liftIO cleanup
stop 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 In this mode, the names of files are not available and keys are displayed
instead. 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` * `--sizesof=repository`
Displays a history of the total size of the annexed files in a 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]] [[!meta author=yoh]]
[[!tag projects/repronim]] [[!tag projects/repronim]]
> [[done]] --[[Joey]]