diff --git a/checkout.py b/checkout.py index 4a5900009..685d2f781 100644 --- a/checkout.py +++ b/checkout.py @@ -301,7 +301,7 @@ class GitCheckout(CheckoutBase): if errors: raise PatchApplicationFailed(errors, verbose) found_files = self._check_output_git( - ['diff', '--ignore-submodules', + ['-c', 'core.quotePath=false', 'diff', '--ignore-submodules', '--name-only', '--staged']).splitlines(False) if sorted(patches.filenames) != sorted(found_files): extra_files = sorted(set(found_files) - set(patches.filenames)) diff --git a/gclient_scm.py b/gclient_scm.py index 20115f61a..d4c9c41ef 100644 --- a/gclient_scm.py +++ b/gclient_scm.py @@ -270,12 +270,19 @@ class GitWrapper(SCMWrapper): # time-stamp of the currently checked out revision. return self._Capture(['log', '-n', '1', '--format=%ai']) + def _GetDiffFilenames(self, base): + """Returns the names of files modified since base.""" + return self._Capture( + # Filter to remove base if it is None. + filter(bool, ['-c', 'core.quotePath=false', 'diff', '--name-only', base]) + ).split() + def diff(self, options, _args, _file_list): try: merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])] except subprocess2.CalledProcessError: merge_base = [] - self._Run(['diff'] + merge_base, options) + self._Run(['-c', 'core.quotePath=false', 'diff'] + merge_base, options) def pack(self, _options, _args, _file_list): """Generates a patch file which can be applied to the root of the @@ -360,7 +367,6 @@ class GitWrapper(SCMWrapper): self.Print('FAILED to break lock: %s: %s' % (to_break, ex)) raise - def update(self, options, args, file_list): """Runs git to update or transparently checkout the working copy. @@ -628,8 +634,7 @@ class GitWrapper(SCMWrapper): raise gclient_utils.Error(switch_error) else: # case 3 - the default case - rebase_files = self._Capture( - ['diff', upstream_branch, '--name-only']).split() + rebase_files = self._GetDiffFilenames(upstream_branch) if verbose: self.Print('Trying fast-forward merge to branch : %s' % upstream_branch) try: @@ -733,7 +738,6 @@ class GitWrapper(SCMWrapper): return self._Capture(['rev-parse', '--verify', 'HEAD']) - def revert(self, options, _args, file_list): """Reverts local modifications. @@ -767,7 +771,7 @@ class GitWrapper(SCMWrapper): return self.update(options, [], file_list) if file_list is not None: - files = self._Capture(['diff', deps_revision, '--name-only']).split() + files = self._GetDiffFilenames(deps_revision) self._Scrub(deps_revision, options) self._Run(['clean', '-f', '-d'], options) @@ -792,10 +796,11 @@ class GitWrapper(SCMWrapper): merge_base = [self._Capture(['merge-base', 'HEAD', self.remote])] except subprocess2.CalledProcessError: merge_base = [] - self._Run(['diff', '--name-status'] + merge_base, options, - stdout=self.out_fh, always=options.verbose) + self._Run( + ['-c', 'core.quotePath=false', 'diff', '--name-status'] + merge_base, + options, stdout=self.out_fh, always=options.verbose) if file_list is not None: - files = self._Capture(['diff', '--name-only'] + merge_base).split() + files = self._GetDiffFilenames(merge_base[0] if merge_base else None) file_list.extend([os.path.join(self.checkout_path, f) for f in files]) def GetUsableRev(self, rev, options): @@ -960,7 +965,7 @@ class GitWrapper(SCMWrapper): branch=None, printed_path=False, merge=False): """Attempt to rebase onto either upstream or, if specified, newbase.""" if files is not None: - files.extend(self._Capture(['diff', upstream, '--name-only']).split()) + files.extend(self._GetDiffFilenames(upstream)) revision = upstream if newbase: revision = newbase diff --git a/git_cl.py b/git_cl.py index b83a053b7..92cac9bd3 100755 --- a/git_cl.py +++ b/git_cl.py @@ -5885,7 +5885,8 @@ def CMDowners(parser, args): def BuildGitDiffCmd(diff_type, upstream_commit, args): """Generates a diff command.""" # Generate diff for the current branch's changes. - diff_cmd = ['diff', '--no-ext-diff', '--no-prefix', diff_type, + diff_cmd = ['-c', 'core.quotePath=false', 'diff', + '--no-ext-diff', '--no-prefix', diff_type, upstream_commit, '--'] if args: diff --git a/git_upstream_diff.py b/git_upstream_diff.py index 72acb3766..6e07c6d33 100755 --- a/git_upstream_diff.py +++ b/git_upstream_diff.py @@ -34,7 +34,8 @@ def main(args): print 'fatal: No upstream configured for branch \'%s\'' % opts.branch return 1 - cmd = [git.GIT_EXE, 'diff', '--patience', '-C', '-C'] + cmd = [git.GIT_EXE, '-c', 'core.quotePath=false', + 'diff', '--patience', '-C', '-C'] if opts.wordwise: cmd += ['--word-diff=color', r'--word-diff-regex=(\w+|[^[:space:]])'] cmd += [git.get_or_create_merge_base(opts.branch, par)] diff --git a/scm.py b/scm.py index 232fcb953..6baf1085a 100644 --- a/scm.py +++ b/scm.py @@ -277,7 +277,8 @@ class GIT(object): files, usually in the prospect to apply the patch for a try job.""" if not branch: branch = GIT.GetUpstreamBranch(cwd) - command = ['diff', '-p', '--no-color', '--no-prefix', '--no-ext-diff', + command = ['-c', 'core.quotePath=false', 'diff', + '-p', '--no-color', '--no-prefix', '--no-ext-diff', branch + "..." + branch_head] if full_move: command.append('--no-renames') @@ -300,7 +301,8 @@ class GIT(object): """Returns the list of modified files between two branches.""" if not branch: branch = GIT.GetUpstreamBranch(cwd) - command = ['diff', '--name-only', branch + "..." + branch_head] + command = ['-c', 'core.quotePath=false', 'diff', + '--name-only', branch + "..." + branch_head] return GIT.Capture(command, cwd=cwd).splitlines(False) @staticmethod diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py index 5c6bf4cef..71b5f54a4 100755 --- a/tests/gclient_scm_test.py +++ b/tests/gclient_scm_test.py @@ -340,7 +340,7 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): scm.status(options, self.args, file_list) self.assertEquals(file_list, [file_path]) self.checkstdout( - ('\n________ running \'git diff --name-status ' + ('\n________ running \'git -c core.quotePath=false diff --name-status ' '069c602044c5388d2d15c3f875b057c852003458\' in \'%s\'\nM\ta\n') % join(self.root_dir, '.')) @@ -360,7 +360,7 @@ class ManagedGitWrapperTestCase(BaseGitWrapperTestCase): expected_file_list = [join(self.base_path, x) for x in ['a', 'b']] self.assertEquals(sorted(file_list), expected_file_list) self.checkstdout( - ('\n________ running \'git diff --name-status ' + ('\n________ running \'git -c core.quotePath=false diff --name-status ' '069c602044c5388d2d15c3f875b057c852003458\' in \'%s\'\nM\ta\nM\tb\n') % join(self.root_dir, '.'))