From 89bfeada8785c68491e015c7d7bc16876b16dacc Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 3 Mar 2025 15:12:19 -0400 Subject: [PATCH] recompute: display one of the changed files --- Command/Recompute.hs | 32 +++++++++++++++++++------------- doc/git-annex-recompute.mdwn | 3 ++- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/Command/Recompute.hs b/Command/Recompute.hs index 81fe35cbff..2eda098867 100644 --- a/Command/Recompute.hs +++ b/Command/Recompute.hs @@ -79,18 +79,22 @@ start' o r si file key = Remote.Compute.getComputeState (Remote.remoteStateHandle r) key >>= \case Nothing -> stop - Just state -> - stopUnless (shouldrecompute state) $ - starting "recompute" ai si $ - perform o r file key state + Just state -> shouldrecompute state >>= \case + Nothing -> stop + Just mreason -> starting "recompute" ai si $ do + maybe noop showNote mreason + perform o r file key state where ai = mkActionItem (key, file) shouldrecompute state - | originalOption o = return True - | otherwise = - anyM (inputchanged state) $ - M.toList (Remote.Compute.computeInputs state) + | originalOption o = return (Just Nothing) + | otherwise = firstM (inputchanged state) + (M.toList (Remote.Compute.computeInputs state)) + >>= return . \case + Nothing -> Nothing + Just (inputfile, _) -> Just $ Just $ + QuotedPath inputfile <> " changed" inputchanged state (inputfile, inputkey) = do -- Note that the paths from the remote state are not to be @@ -109,11 +113,13 @@ start' o r si file key = Just (sha, _, _) -> sha /= inputgitsha Nothing -> inputfilemissing Nothing -> return inputfilemissing - - -- When an input file is missing, go ahead and recompute. This way, - -- the user will see the computation fail, with an error message that - -- explains the problem. - inputfilemissing = True + where + -- When an input file is missing, go ahead and recompute. + -- This way, the user will see the computation fail, + -- with an error message that explains the problem. + -- Or, if the input file is only optionally used by the + -- computation, it might succeed. + inputfilemissing = True perform :: RecomputeOptions -> Remote -> OsPath -> Key -> Remote.Compute.ComputeState -> CommandPerform perform o r file origkey origstate = do diff --git a/doc/git-annex-recompute.mdwn b/doc/git-annex-recompute.mdwn index fb895aa75c..0f8dd56901 100644 --- a/doc/git-annex-recompute.mdwn +++ b/doc/git-annex-recompute.mdwn @@ -15,7 +15,8 @@ By default, this only recomputes files whose input files have changed. The new contents of the input files are used to re-run the computation. When the output of the computation is different, the computed file is -updated with the new content. +updated with the new content. The updated file is written to the worktree, +but is not staged, in order to avoid overwriting any staged changes. # OPTIONS