summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2016-01-13 14:19:31 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2016-01-13 14:19:31 -0400
commit0271693312df2134693562396bd6dd77b32c5e63 (patch)
tree79a0df32d6c4818a2b075b5656f08480c98e2415
parent13b601854be937d9cf242850e73f6d094487511b (diff)
avoid hard linking object from other repository when annex.thin is set
This is simpler and less expensive than checking if the src file has a link count >= 2, and also is unlocked.
-rw-r--r--Remote/Git.hs9
-rw-r--r--doc/todo/smudge.mdwn8
2 files changed, 7 insertions, 10 deletions
diff --git a/Remote/Git.hs b/Remote/Git.hs
index 5b7dec309..a377fd38c 100644
--- a/Remote/Git.hs
+++ b/Remote/Git.hs
@@ -672,7 +672,12 @@ commitOnCleanup r a = go `after` a
toCommand shellparams
wantHardLink :: Annex Bool
-wantHardLink = (annexHardLink <$> Annex.getGitConfig) <&&> (not <$> isDirect)
+wantHardLink = (annexHardLink <$> Annex.getGitConfig)
+ -- Not direct mode files because they can be modified at any time.
+ <&&> (not <$> isDirect)
+ -- Not unlocked files that are hard linked in the work tree,
+ -- because they can be modified at any time.
+ <&&> (not <$> annexThin <$> Annex.getGitConfig)
-- Copies from src to dest, updating a meter. If the copy finishes
-- successfully, calls a final check action, which must also succeed, or
@@ -694,7 +699,7 @@ mkCopier remotewanthardlink rsyncparams = do
#ifndef mingw32_HOST_OS
localwanthardlink <- wantHardLink
let linker = \src dest -> createLink src dest >> return True
- ifM (pure (remotewanthardlink || localwanthardlink))
+ ifM (pure (remotewanthardlink || localwanthardlink) <&&> not <$> isDirect)
( return $ \src dest p check ->
ifM (liftIO (catchBoolIO (linker src dest)))
( return (True, Verified)
diff --git a/doc/todo/smudge.mdwn b/doc/todo/smudge.mdwn
index 5f3d521bf..2178154ee 100644
--- a/doc/todo/smudge.mdwn
+++ b/doc/todo/smudge.mdwn
@@ -2,14 +2,6 @@ git-annex should use smudge/clean filters.
### implementation todo list
-* Interaction with shared clones. Should avoid hard linking from/to a
- object in a shared clone if either repository has the object unlocked
- with a hard link in place.
- (And should avoid unlocking an object with a hard link if it's hard
- linked to a shared clone, but that's already accomplished because it
- avoids unlocking an object if it's hard linked at all)
- **release blocker**
-
* Reconcile staged changes into the associated files database, whenever
the database is queried. This is needed to handle eg:
git add largefile