Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index 4edb6a0af8e1ee834f7f8305e92e435a3c1f9cee..eaafa01398df6c8bbd8473dcfa304e2b0f131855 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -2401,6 +2401,9 @@ def CMDpatch(parser, args): |
| return 1 |
| issue_arg = args[0] |
| + if is_dirty_git_tree('patch'): |
| + return 1 |
| + |
| # TODO(maruel): Use apply_issue.py |
| # TODO(ukai): use gerrit-cherry-pick for gerrit repository? |
| @@ -2464,6 +2467,7 @@ def PatchIssue(issue_arg, reject, nocommit, directory): |
| subprocess2.check_call(cmd, env=GetNoGitPagerEnv(), |
| stdin=patch_data, stdout=subprocess2.VOID) |
| except subprocess2.CalledProcessError: |
| + RunGit(['reset', '--hard']) |
|
Sam Clegg
2015/02/02 17:43:18
I find this a little scary. Perhaps skip this and
wychen
2015/02/03 02:33:44
Done.
|
| DieWithError('Failed to apply the patch') |
| # If we had an issue, commit the current state and register the issue. |
| @@ -2769,6 +2773,15 @@ def CMDset_close(parser, args): |
| def CMDdiff(parser, args): |
| """shows differences between local tree and last upload.""" |
| + |
| + # Uncommitted (staged and unstaged) changes will be destroyed by |
| + # "git reset --hard" if there are merging conflicts in PatchIssue(). |
| + # Staged changes would be committed along with the patch from last |
| + # upload, hence counted toward the "last upload" side in the final |
| + # diff output, and this is not what we want. |
| + if is_dirty_git_tree('diff'): |
| + return 1 |
| + |
| cl = Changelist() |
| issue = cl.GetIssue() |
| branch = cl.GetBranch() |