make --in=here fast

Use the same optimisation for --in=here as has always been used for --in=.
rather than the slow code path that unncessarily queries the git-annex
branch.

It looks like when "here" got added as an alias for "." back in 2012, I
forgot about this place.

Also sped up some very unlikely ways of referring to the current
repository.

Note that, this could in some rare corner case cause a behavior
change, if the git-annex branch and inAnnex disagree about whether content
is present in the local repository. But --in=. already behaved
that way, and the truth on the ground should win also.
This commit is contained in:
Joey Hess 2019-08-01 00:17:02 -04:00
parent 4ad33e7524
commit d1a0c7b16f
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 15 additions and 7 deletions

View file

@ -1,3 +1,11 @@
git-annex (7.20190731) UNRELEASED; urgency=medium
* Use the same optimisation for --in=here as has always been
used for --in=. rather than the slow code path that unncessarily
queries the git-annex branch.
-- Joey Hess <id@joeyh.name> Thu, 01 Aug 2019 00:11:56 -0400
git-annex (7.20190730) upstream; urgency=medium
* Improved probing when CoW copies can be made between files on the same

View file

@ -110,15 +110,15 @@ matchMagic limitname _ _ Nothing _ =
{- Adds a limit to skip files not believed to be present
- in a specfied repository. Optionally on a prior date. -}
addIn :: String -> Annex ()
addIn s = addLimit =<< mk
addIn s = do
u <- Remote.nameToUUID name
hereu <- getUUID
addLimit $ if u == hereu && null date
then use inhere
else use (inuuid u)
where
(name, date) = separate (== '@') s
mk
| name == "." = if null date
then use inhere
else use . inuuid =<< getUUID
| otherwise = use . inuuid =<< Remote.nameToUUID name
use a = return $ Right $ \notpresent -> checkKey (a notpresent)
use a = Right $ checkKey . a
inuuid u notpresent key
| null date = do
us <- Remote.keyLocations key