summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2011-01-08 15:14:41 -0400
committerGravatar Joey Hess <joey@kitenet.net>2011-01-08 15:14:41 -0400
commit32b0e103909035ad0f25427c57a1ff504aefcada (patch)
tree92bcafa885e1c02795226c7c80c8174576e560ef
parent82fe151f8796c5f0a37565134deb55142fdd1a99 (diff)
unannex: Now skips files whose content is not present, rather than it being an error. This allows gradual conversion from one backend to another by running unannex followed by add in each repository.
-rw-r--r--Command/Unannex.hs8
-rw-r--r--debian/changelog8
-rw-r--r--doc/walkthrough.mdwn13
-rw-r--r--test.hs10
4 files changed, 33 insertions, 6 deletions
diff --git a/Command/Unannex.hs b/Command/Unannex.hs
index 288f9da44..2c60a23bb 100644
--- a/Command/Unannex.hs
+++ b/Command/Unannex.hs
@@ -29,8 +29,12 @@ seek = [withFilesInGit start]
{- The unannex subcommand undoes an add. -}
start :: CommandStartString
start file = isAnnexed file $ \(key, backend) -> do
- showStart "unannex" file
- return $ Just $ perform file key backend
+ ishere <- inAnnex key
+ if ishere
+ then do
+ showStart "unannex" file
+ return $ Just $ perform file key backend
+ else return Nothing
perform :: FilePath -> Key -> Backend -> CommandPerform
perform file key backend = do
diff --git a/debian/changelog b/debian/changelog
index bd986ad24..7ca74f994 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+git-annex (0.17) UNRELEASED; urgency=low
+
+ * unannex: Now skips files whose content is not present, rather than
+ it being an error. This allows gradual conversion from one backend
+ to another by running unannex followed by add in each repository.
+
+ -- Joey Hess <joeyh@debian.org> Sat, 08 Jan 2011 15:04:48 -0400
+
git-annex (0.16) unstable; urgency=low
* git-annex-shell: Avoid exposing any git repo config except for the
diff --git a/doc/walkthrough.mdwn b/doc/walkthrough.mdwn
index 2f868e303..47f05ebcf 100644
--- a/doc/walkthrough.mdwn
+++ b/doc/walkthrough.mdwn
@@ -277,6 +277,19 @@ add something like this to `.gitattributes`:
* annex.backend=SHA1
+## migrating between backends
+
+Perhaps you had been using the WORM backend, but now have configured
+git-annex to use SHA1 for new files. Your old files are still in WORM. How
+to migrate that content? A quick and dirty way is to use the unannex
+subcommand, which removes a file from git-annex's control, followed by
+a re-add of the file, to put it in the new backend.
+
+ # git annex unannex my_cool_big_file
+ unannex my_cool_big_file ok
+ # git annex add my_cool_big_file
+ add my_cool_big_file (checksum ...) ok
+
## unused data
It's possible for data to accumulate in the annex that no files point to
diff --git a/test.hs b/test.hs
index ea1e0728e..35085cc37 100644
--- a/test.hs
+++ b/test.hs
@@ -16,6 +16,7 @@ import Data.List
import System.IO.Error
import System.Posix.Env
import qualified Control.Exception.Extensible as E
+import Control.Exception (throw)
import qualified GitRepo as Git
import qualified Locations
@@ -87,10 +88,11 @@ test_unannex :: Test
test_unannex = "git-annex unannex" ~: TestList [nocopy, withcopy]
where
nocopy = "no content" ~: intmpclonerepo $ do
- r <- git_annex "unannex" ["-q", annexedfile]
- not r @? "unannex incorrectly succeeded with no copy"
- unannexed annexedfile
+ annexed_notpresent annexedfile
+ git_annex "unannex" ["-q", annexedfile] @? "unannex failed with no copy"
+ annexed_notpresent annexedfile
withcopy = "with content" ~: intmpcopyrepo $ do
+ annexed_present annexedfile
git_annex "unannex" ["-q", annexedfile] @? "unannex failed"
unannexed annexedfile
git_annex "unannex" ["-q", annexedfile] @? "unannex failed on non-annexed file"
@@ -280,7 +282,7 @@ indir dir a = do
(E.try (a)::IO (Either E.SomeException ()))
case r of
Right () -> return ()
- Left e -> error $ show e
+ Left e -> throw e
setuprepo :: FilePath -> IO FilePath
setuprepo dir = do