summaryrefslogtreecommitdiff
path: root/Annex/Link.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-12-10 16:06:58 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-12-10 16:06:58 -0400
commit4049c257fa88325f6e5496a59536c2bb6fbee8aa (patch)
treeaa17e5b2006b54b37ce428bcb5ba4d40168f917e /Annex/Link.hs
parentc509e89cc07bf0f252a11e51b14e97a82e037c95 (diff)
always format pointer file with a trailing newline
Before the smudge filter added a trailing newline, but other things that wrote formatPointer to a file did not. also some new pointer staging code to use later
Diffstat (limited to 'Annex/Link.hs')
-rw-r--r--Annex/Link.hs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Annex/Link.hs b/Annex/Link.hs
index f405403f2..61c61b561 100644
--- a/Annex/Link.hs
+++ b/Annex/Link.hs
@@ -110,12 +110,23 @@ hashSymlink' :: Git.HashObject.HashObjectHandle -> LinkTarget -> Annex Sha
hashSymlink' h linktarget = liftIO $ Git.HashObject.hashBlob h $
toInternalGitPath linktarget
-{- Stages a symlink to the annex, using a Sha of its target. -}
+{- Stages a symlink to an annexed object, using a Sha of its target. -}
stageSymlink :: FilePath -> Sha -> Annex ()
stageSymlink file sha =
Annex.Queue.addUpdateIndex =<<
inRepo (Git.UpdateIndex.stageSymlink file sha)
+{- Injects a pointer file content into git, returning its Sha. -}
+hashPointerFile :: Key -> Annex Sha
+hashPointerFile key = inRepo $ Git.HashObject.hashObject BlobObject $
+ formatPointer key
+
+{- Stages a pointer file, using a Sha of its content -}
+stagePointerFile :: FilePath -> Sha -> Annex ()
+stagePointerFile file sha =
+ Annex.Queue.addUpdateIndex =<<
+ inRepo (Git.UpdateIndex.stageFile sha FileBlob file)
+
{- Parses a symlink target or a pointer file to a Key.
- Only looks at the first line, as pointer files can have subsequent
- lines. -}
@@ -138,7 +149,8 @@ parseLinkOrPointer' s = headMaybe (lines (fromInternalGitPath s)) >>= go
| otherwise = Nothing
formatPointer :: Key -> String
-formatPointer k = toInternalGitPath $ pathSeparator:objectDir </> key2file k
+formatPointer k =
+ toInternalGitPath (pathSeparator:objectDir </> key2file k) ++ "\n"
{- Checks if a file is a pointer to a key. -}
isPointerFile :: FilePath -> Annex (Maybe Key)