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
This commit is contained in:
sbc@chromium.org
2015-04-09 19:29:40 +00:00
parent 4126556b4a
commit 71437c0ba5
6 changed files with 52 additions and 31 deletions

View File

@@ -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 @@ def main(args):
'-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