Skip to content

Instantly share code, notes, and snippets.

@resuscv
Created January 16, 2013 23:33
Show Gist options
  • Save resuscv/4552036 to your computer and use it in GitHub Desktop.
Save resuscv/4552036 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
#
# Script to test git-annex direct mode.
sudo rm -rf test{1,2,3}
D=`pwd`
mkdir test1
(cd test1; git init; git annex init "test1"; date > test.file; git annex add test.file; git commit -m "Initial commit";)
(git clone test1 test2; cd test2; git annex init "test2";)
(git clone test1 test3; cd test3; git annex init "test3"; git annex direct)
(cd test1; git remote add test2 ${D}/test2; git remote add test3 ${D}/test3)
(cd test2; git remote rename origin test1; git remote add test3 ${D}/test3)
(cd test3; git remote rename origin test1; git remote add test2 ${D}/test2)
(cd test1; git annex whereis test.file;)
(cd test2; git annex whereis test.file;)
(cd test3; git annex whereis test.file;)
(cd test2; git annex get test.file;)
(cd test3; git annex get test.file;)
(cd test1; git annex whereis test.file;)
(cd test2; git annex whereis test.file;)
(cd test3; git annex whereis test.file;)
(cd test3; git annex sync;) ; (cd test2; git annex sync;) ; (cd test1; git annex sync;)
(cd test3; git annex sync;) ; (cd test2; git annex sync;) ; (cd test1; git annex sync;)
(cd test3; git annex sync;) ; (cd test2; git annex sync;) ; (cd test1; git annex sync;)
(cd test1; git annex whereis test.file;); (cd test2; git annex whereis test.file;); (cd test3; git annex whereis test.file;)
(cd test3; git annex drop test.file;)
(cd test2; git annex drop test.file;)
# Problem 1:
# Try making some of these repositories available:
# ... -- test2
# ... -- test3
# This should be able to find the test2 and test3 repos. They are local...
(cd test1; git annex drop test.file;)
# Problem 2:
# Apparently the file is now available
# whereis test.file (2 copies)
# ... -- here (test1)
# ... -- test2
# but we dropped it in test2...
(cd test1; git annex sync; git annex whereis test.file;)
# SCARY bug
# whereis test.file (2 copies)
# ... -- test1
# ... -- here (test2)
# but we dropped this file previously!
(cd test2; git annex whereis test.file;)
# existence test
[ -f test1/test.file ] || echo "doesn't exist in test1"
[ -f test2/test.file ] || echo "doesn't exist in test2"
## END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment