Skip to content

Commit

Permalink
Created a second function called gitflow_test_clean_working_tree() th…
Browse files Browse the repository at this point in the history
…at returns error codes instead of dies.

Rewrote gitflow_require_clean_working_tree() in terms of that.
  • Loading branch information
nvie committed Jan 29, 2010
1 parent 49c7d02 commit 62345d5
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions git-flow
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 62345d5

Please sign in to comment.