dvcs-autosync+git is broken by design
dieter at plaetinck.be
Sun Mar 4 17:35:36 CET 2012
1) there was a typo in the original script, i also made various improvements. such as the ability to safely ignore missing files
2) git rm --cached also needs -f flag. you want to make sure the file is removed from the index once you get a delete inotify event. without this flag you can get something like:
% git rm --cached foobar
error: 'foobar' has staged content different from both the file and the HEAD
(use -f to force removal)
new script: http://pastie.org/3519502
save as git-add-atomic
use a config like:
statuscmd = git status | grep -iq "nothing to commit"
addcmd = git add-atomic --ignore-missing %s
rmcmd = git rm --cached -f %s
modifycmd = git add-atomic --ignore-missing %s
movecmd = git rm --cached -f %s
git add-atomic --ignore-missing %s
# TODO: add -A behavior to add-atomic. I don't need this because i'm never editing files when autosync starts, though.
startupcmd = git add -A
commitcmd = git commit -m "Autocommit"
pushcmd = git push
pullcmd = git pull
remoteurlcmd = git config --get remote.origin.url
it's a bit clunky because it can sleep up to 20 seconds, that logic is a bit dumb, but that happens rarely anyway.
(in fact, i've done tests doing 'git add' on a file that's being written to but was unable to get git add to error out.
but anyway, the maintainer said it can happen as git expects the file not to change, so i trust him on that. maybe i wasn't writing fast enough or the flushing wasn't quick enough, i used cat /dev/urandom >> somefile)
this seems to work okay so far in my 'notes' repo.
More information about the vcs-home