Skip to content

Instantly share code, notes, and snippets.

Created August 9, 2013 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/6197019 to your computer and use it in GitHub Desktop.
Save anonymous/6197019 to your computer and use it in GitHub Desktop.
#!/bin/bash
A=`mktemp -d`
B=`mktemp -d`
GIT_HOOK=post-receive
set -e
cd $A
git init
git annex init a
# make a commit so we can clone
echo dummy > dummy
git annex add dummy
git commit -m "initial commit"
cd $B
git clone $A .
git annex init b
git remote add a $A
cd $A
git remote add b $B
echo "1st file" > file1
git annex add file1
git annex sync
cd $B
git annex merge
if [ -h file1 ]; then
echo file1 exists after manual 'git annex merge'
else
echo file1 does not exist after manual 'git annex merge'
fi
cat > .git/hooks/$GIT_HOOK <<END
#!/bin/sh
git annex merge
END
chmod +x .git/hooks/$GIT_HOOK
cd $A
echo "2nd file" > file2
git annex add file2
git annex sync
cd $B
if [ -h file2 ]; then
echo file2 exists after 'git annex merge' in $GIT_HOOK
else
echo file2 does not exist after 'git annex merge' in $GIT_HOOK
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment