Permalink
Browse files

Try to prevent tmpfile collisions and clean up after ourselves.

  • Loading branch information...
1 parent 25a3942 commit 41f7933625d8c88dd9a56f7c1221e17f3a6745cc Brian Donovan committed Oct 8, 2009
Showing with 9 additions and 1 deletion.
  1. +9 −1 bin/git-review
View
10 bin/git-review
@@ -32,17 +32,25 @@ good() {
#git stuff
GIT=`which git`
+GIT_OUTPUT_FILE="/tmp/git_output$$"
+
git() {
if [ "$verbose" = true ]; then
echo -e "+ ${GREEN}git $@${NO_COLOR}"
fi
if [ "$run" = true ]; then
- $GIT $@ 2>&1 | tee /dev/tty > /tmp/git_output
+ $GIT $@ 2>&1 | tee /dev/tty > $GIT_OUTPUT_FILE
return ${PIPESTATUS[0]}
fi
}
+trap _cleanup_git_output EXIT
+
+_cleanup_git_output() {
+ rm -f $GIT_OUTPUT_FILE
+}
+
no_changes () {
$GIT diff-index --quiet --cached HEAD -- &&
$GIT diff-files --quiet

0 comments on commit 41f7933

Please sign in to comment.