summaryrefslogtreecommitdiff
path: root/Annex/View.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-02-18 20:32:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-02-18 20:32:00 -0400
commit59d66243ab57890cbbe7fdc0a7c7c78c24702b95 (patch)
tree2bb88f2cecece4fbe315bf97cfcc932167a5ed23 /Annex/View.hs
parent18fe5ebbb5aef07aa2ab5d621dd44b0788862a07 (diff)
view: preserve toplevel dotfiles
Diffstat (limited to 'Annex/View.hs')
-rw-r--r--Annex/View.hs25
1 files 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.