Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Unified Diff: git_cl.py

Issue 896453002: Disallow applying patches when git tree is dirty (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: add comments Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698