diff --git a/CHANGELOG b/CHANGELOG index 2c856674ff..6e7e0cf4c1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -20,6 +20,9 @@ git-annex (8.20200720.2) UNRELEASED; urgency=medium * Slightly sped up the linux standalone bundle. * importfeed: Fix reversion that caused some '.' in filenames to be replaced with '_' + * Avoid complaining that a file with "is beyond a symbolic link" + when the filepath is absolute and the symlink in question is not + actually inside the git repository. -- Joey Hess Tue, 21 Jul 2020 12:58:30 -0400 diff --git a/CmdLine/Seek.hs b/CmdLine/Seek.hs index 88a3c61212..1e8731e029 100644 --- a/CmdLine/Seek.hs +++ b/CmdLine/Seek.hs @@ -445,11 +445,12 @@ workTreeItems' (AllowHidden allowhidden) ww ps = case ww of where runcheck = do currbranch <- getCurrentBranch + stopattop <- prepviasymlink ps' <- flip filterM ps $ \p -> do relf <- liftIO $ relPathCwdToFile p ifM (not <$> (exists p <||> hidden currbranch relf)) ( prob (p ++ " not found") - , ifM (viasymlink (upFrom relf)) + , ifM (viasymlink stopattop (upFrom relf)) ( prob (p ++ " is beyond a symbolic link") , return True ) @@ -460,12 +461,25 @@ workTreeItems' (AllowHidden allowhidden) ww ps = case ww of exists p = isJust <$> liftIO (catchMaybeIO $ getSymbolicLinkStatus p) - viasymlink Nothing = return False - viasymlink (Just p) = - ifM (liftIO $ isSymbolicLink <$> getSymbolicLinkStatus p) - ( return True - , viasymlink (upFrom p) - ) + prepviasymlink = do + repotopst <- inRepo $ + maybe + (pure Nothing) + (catchMaybeIO . R.getSymbolicLinkStatus) + . Git.repoWorkTree + return $ \st -> case repotopst of + Nothing -> False + Just tst -> fileID st == fileID tst + && deviceID st == deviceID tst + + viasymlink _ Nothing = return False + viasymlink stopattop (Just p) = do + st <- liftIO $ getSymbolicLinkStatus p + if stopattop st + then return False + else if isSymbolicLink st + then return True + else viasymlink stopattop (upFrom p) hidden currbranch f | allowhidden = isJust diff --git a/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo.mdwn b/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo.mdwn index 3b4d06838b..f639a543dd 100644 --- a/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo.mdwn +++ b/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo.mdwn @@ -77,3 +77,5 @@ caller's side, but since it looks like an unintended consequence of [[!meta author=kyle]] [[!tag projects/datalad]] + +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo/comment_3_9ac6e3436ab4866993ebf4e469b13636._comment b/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo/comment_3_9ac6e3436ab4866993ebf4e469b13636._comment new file mode 100644 index 0000000000..64ff44e454 --- /dev/null +++ b/doc/bugs/__39__Beyond_symbolic__39___link_error_when_link_is_upstream_of_repo/comment_3_9ac6e3436ab4866993ebf4e469b13636._comment @@ -0,0 +1,12 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 3""" + date="2020-08-06T22:29:49Z" + content=""" +AFAICS, git does something like cache the stat of the directory at the top +of the working tree, and uses that to know which part to check for symlinks. +There's a lstat cache in the relevant code anyway. + +Ok, implemented it that way in git-annex, which I was able to do w/o doing +any more work per file than comparing a dev and an inode. +"""]]