diff --git a/diff_cover/git_diff.py b/diff_cover/git_diff.py index 871e5cec..92c743c5 100644 --- a/diff_cover/git_diff.py +++ b/diff_cover/git_diff.py @@ -27,8 +27,10 @@ def diff_committed(self, compare_branch='origin/master'): to stderr. """ return execute([ - 'git', '-c', 'diff.mnemonicprefix=no', 'diff', - "{branch}...HEAD".format(branch=compare_branch), + 'git', + '-c', 'diff.mnemonicprefix=no', + '-c', 'diff.noprefix=no', + 'diff', '{branch}...HEAD'.format(branch=compare_branch), '--no-color', '--no-ext-diff' ])[0] @@ -41,8 +43,14 @@ def diff_unstaged(self): Raises a `GitDiffError` if `git diff` outputs anything to stderr. """ - return execute(['git', '-c', 'diff.mnemonicprefix=no', 'diff', - '--no-color', '--no-ext-diff'])[0] + return execute([ + 'git', + '-c', 'diff.mnemonicprefix=no', + '-c', 'diff.noprefix=no', + 'diff', + '--no-color', + '--no-ext-diff' + ])[0] def diff_staged(self): """ @@ -52,5 +60,12 @@ def diff_staged(self): Raises a `GitDiffError` if `git diff` outputs anything to stderr. """ - return execute(['git', '-c', 'diff.mnemonicprefix=no', 'diff', - '--cached', '--no-color', '--no-ext-diff'])[0] + return execute([ + 'git', + '-c', 'diff.mnemonicprefix=no', + '-c', 'diff.noprefix=no', + 'diff', + '--cached', + '--no-color', + '--no-ext-diff' + ])[0] diff --git a/diff_cover/tests/test_git_diff.py b/diff_cover/tests/test_git_diff.py index dca5cde3..55128ebe 100644 --- a/diff_cover/tests/test_git_diff.py +++ b/diff_cover/tests/test_git_diff.py @@ -27,8 +27,9 @@ def test_diff_committed(self): self.assertEqual(output, 'test output') # Expect that the correct command was executed - expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff', - 'origin/master...HEAD', '--no-color', '--no-ext-diff'] + expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c', + 'diff.noprefix=no', 'diff', 'origin/master...HEAD', + '--no-color', '--no-ext-diff'] self.subprocess.Popen.assert_called_with( expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE ) @@ -41,8 +42,8 @@ def test_diff_unstaged(self): self.assertEqual(output, 'test output') # Expect that the correct command was executed - expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff', - '--no-color', '--no-ext-diff'] + expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c', + 'diff.noprefix=no', 'diff', '--no-color', '--no-ext-diff'] self.subprocess.Popen.assert_called_with( expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE ) @@ -55,8 +56,9 @@ def test_diff_staged(self): self.assertEqual(output, 'test output') # Expect that the correct command was executed - expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff', '--cached', - '--no-color', '--no-ext-diff'] + expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c', + 'diff.noprefix=no', 'diff', '--cached', '--no-color', + '--no-ext-diff'] self.subprocess.Popen.assert_called_with( expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE ) @@ -71,8 +73,9 @@ def test_diff_committed_compare_branch(self): self.assertEqual(output, 'test output') # Expect that the correct command was executed - expected = ['git', '-c', 'diff.mnemonicprefix=no', 'diff', - 'release...HEAD', '--no-color', '--no-ext-diff'] + expected = ['git', '-c', 'diff.mnemonicprefix=no', '-c', + 'diff.noprefix=no', 'diff', 'release...HEAD', '--no-color', + '--no-ext-diff'] self.subprocess.Popen.assert_called_with( expected, stdout=self.subprocess.PIPE, stderr=self.subprocess.PIPE ) diff --git a/diff_cover/tests/test_integration.py b/diff_cover/tests/test_integration.py index 5b0f7653..f0a2df34 100644 --- a/diff_cover/tests/test_integration.py +++ b/diff_cover/tests/test_integration.py @@ -166,7 +166,8 @@ def _set_git_diff_output(self, stdout, stderr, returncode=0): a phony directory. """ def patch_diff(command, **kwargs): - if command[0:4] == ['git', '-c', 'diff.mnemonicprefix=no', 'diff']: + if command[0:6] == ['git', '-c', 'diff.mnemonicprefix=no', '-c', + 'diff.noprefix=no', 'diff']: mock = Mock() mock.communicate.return_value = (stdout, stderr) mock.returncode = returncode