#!/bin/sh output=$(find . -name '.#*' -print) if [ -n "$output" ]; then echo "unsaved Emacs files:" 1>&2 echo "$output" 1>&2 exit 1 fiHad that kind of problem a few times. :-)
Now what would be really handy are system-wide Git hooks that apply to all repositories, like ~/.gitignore complements .git/info/exclude.
You can use repository templates to apply a hook to all newly cloned or created repositories. That is how apply my standard hooks to all my repositories.
ReplyDeleteWhy don't you put those in your global ~/.gitignore?
ReplyDeleteIf you have set init.templatedir in your global git config, that template will be used for all newly init'd/cloned repositories.
ReplyDeleteYou can install hooks in there so they will be active "globally".
I suggest to adopt this patch, to make it more general (and also catch vim files):
ReplyDelete#!/bin/sh
output=$(find . -name '.#*' -o -name '.*.sw*' -print)
if [ -n "$output" ]; then
echo "unsaved Editor files:" 1>&2
echo "$output" 1>&2
exit 1
fi
Thanks for the idea!
Consider using magit at this point.
ReplyDeletehttp://farm3.static.flickr.com/2642/4050674979_785b349e1b_o.png
http://philjackson.github.com/magit/
http://vimeo.com/2871241
@SEJeff: I don't want to ignore them, I want to be told when I have unsaved work before committing.
ReplyDeleteGreat post Peter. Thought about using magit? We just wrote an article that may be informative. https://blog.mojotech.com/why-you-should-use-magit-git-porcelain-inside-emacs.
ReplyDelete