stop symlink check once the top of the working tree is reached
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. This assumes that inodes remain stable while the command is running. I think they always will, the filesystems where they are unstable change them across mounts. (If inodes were not stable, it would just complain about symlinks in the path that are not inside the working tree.) (On windows, I don't want to assume anything about inodes, they could be random numbers for all I know. But if they were, this would still be ok, as long as windows doesn't have symlinks that are detected by isSymbolicLink. Which seems a fair bet.)
This commit is contained in:
parent
a358eb1faa
commit
506ffea5e6
4 changed files with 38 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue