From 59d66243ab57890cbbe7fdc0a7c7c78c24702b95 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 18 Feb 2014 20:32:00 -0400 Subject: view: preserve toplevel dotfiles --- Annex/View.hs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Annex/View.hs b/Annex/View.hs index b5d4ca227..eb3254e8e 100644 --- a/Annex/View.hs +++ b/Annex/View.hs @@ -17,11 +17,13 @@ import qualified Git.LsFiles import Git.UpdateIndex import Git.Sha import Git.HashObject +import Git.Types import qualified Backend import Annex.Index import Annex.Link import Logs.MetaData import Logs.View +import Utility.FileMode import qualified Data.Set as S import System.Path.WildMatch @@ -259,14 +261,27 @@ applyView' mkfileview view = do void $ stopUpdateIndex uh void clean where - go uh hasher f Nothing = noop -- TODO dotfiles go uh hasher f (Just (k, _)) = do metadata <- getCurrentMetaData k forM_ (fileViews view mkfileview f metadata) $ \fv -> do - linktarget <- inRepo $ gitAnnexLink fv k - sha <- hashSymlink' hasher linktarget - liftIO . Git.UpdateIndex.streamUpdateIndex' uh - =<< inRepo (Git.UpdateIndex.stageSymlink fv sha) + stagesymlink uh hasher fv =<< inRepo (gitAnnexLink fv k) + go uh hasher f Nothing + | "." `isPrefixOf` f = do + s <- liftIO $ getSymbolicLinkStatus f + if isSymbolicLink s + then stagesymlink uh hasher f =<< liftIO (readSymbolicLink f) + else do + sha <- liftIO $ Git.HashObject.hashFile hasher f + let blobtype = if isExecutable (fileMode s) + then ExecutableBlob + else FileBlob + liftIO . Git.UpdateIndex.streamUpdateIndex' uh + =<< inRepo (Git.UpdateIndex.stageFile sha blobtype f) + | otherwise = noop + stagesymlink uh hasher f linktarget = do + sha <- hashSymlink' hasher linktarget + liftIO . Git.UpdateIndex.streamUpdateIndex' uh + =<< inRepo (Git.UpdateIndex.stageSymlink f sha) {- Applies a view to the reference branch, generating a new branch - for the View. -- cgit v1.2.3