git-squash-branch: handle empty squashes
Error out of the current tree is dirty (previously the dirty
content would be incorporated silently into the newly
squashed branch!).
Review URL: https://codereview.chromium.org/1064933004
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294744 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_squash_branch.py b/git_squash_branch.py
index 83acfa7..33366d2 100755
--- a/git_squash_branch.py
+++ b/git_squash_branch.py
@@ -6,7 +6,7 @@
import argparse
import sys
-from git_common import squash_current_branch
+import git_common
def main(args):
parser = argparse.ArgumentParser()
@@ -14,7 +14,9 @@
'-m', '--message', metavar='<msg>', default='git squash commit.',
help='Use the given <msg> as the first line of the commit message.')
opts = parser.parse_args(args)
- squash_current_branch(opts.message)
+ if git_common.is_dirty_git_tree('squash-branch'):
+ return 1
+ git_common.squash_current_branch(opts.message)
return 0