Permalink
Browse files

Created a second function called gitflow_test_clean_working_tree() th…

…at returns error codes instead of dies.

Rewrote gitflow_require_clean_working_tree() in terms of that.
  • Loading branch information...
1 parent 49c7d02 commit 62345d54f3bed5bbdd26ec9d2d5275a450c533f8 @nvie committed Jan 29, 2010
Showing with 14 additions and 2 deletions.
  1. +14 −2 git-flow
View
@@ -84,11 +84,23 @@ main() {
cmd_$SUBACTION "$@"
}
-gitflow_require_clean_working_tree() {
+gitflow_test_clean_working_tree() {
if ! git diff --no-ext-diff --ignore-submodules --quiet --exit-code; then
+ return 1
+ elif ! git diff-index --cached --quiet --ignore-submodules HEAD --; then
+ return 2
+ else
+ return 0
+ fi
+}
+
+gitflow_require_clean_working_tree() {
+ gitflow_test_clean_working_tree
+ result=$?
+ if [ $result -eq 1 ]; then
die "Working tree contains unstaged changes. Aborting ..."
fi
- if ! git diff-index --cached --quiet --ignore-submodules HEAD --; then
+ if [ $result -eq 2 ]; then
die "Index contains uncommited changes. Aborting ..."
fi
}

0 comments on commit 62345d5

Please sign in to comment.