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

Unified Diff: git_cl.py

Issue 18966004: Default to using --3way when using `git cl patch` with git >= 1.7.12 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: rebase for r210503 Created 7 years, 5 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 2ed721e83f4e26ac8f1819504032edbd58b73e15..9ea856fa41aea869429693586d08e31f4ef0e05f 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -8,6 +8,7 @@
"""A git-command for integrating reviews on Rietveld."""
import difflib
+from distutils.version import LooseVersion
import json
import logging
import optparse
@@ -88,6 +89,13 @@ def RunGitWithCode(args):
return 1, ''
+def IsGitVersionAtLeast(min_version):
+ PREFIX='git version '
+ version = RunGit(['--version']).strip()
+ return (version.startswith(PREFIX) and
+ LooseVersion(version[len(PREFIX):]) >= LooseVersion(min_version))
+
+
def usage(more):
def hook(fn):
fn.usage_more = more
@@ -1714,7 +1722,8 @@ def CMDpatch(parser, args):
parser.add_option('-f', action='store_true', dest='force',
help='with -b, clobber any existing branch')
parser.add_option('--reject', action='store_true', dest='reject',
- help='allow failed patches and spew .rej files')
+ help='failed patches spew .rej files rather than '
+ 'attempting a 3-way merge')
parser.add_option('-n', '--no-commit', action='store_true', dest='nocommit',
help="don't commit after patch applies")
(options, args) = parser.parse_args(args)
@@ -1776,6 +1785,8 @@ def CMDpatch(parser, args):
cmd = ['git', 'apply', '--index', '-p0']
if options.reject:
cmd.append('--reject')
+ elif IsGitVersionAtLeast('1.7.12'):
+ cmd.append('--3way')
try:
subprocess2.check_call(cmd, env=env,
stdin=patch_data, stdout=subprocess2.VOID)
« 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