Fix git cl format --python when diff.noprefix flag is set

Adding the diff.noprefix flag to .gitconfig broke python
formatting because git diffs were being parsed with regex
that relied on the default git diff prefixs.

This CL fix's this issue by always specifying prefix flags
for git diffs when formatting python.

Bug:846432
Change-Id: Ifde305da9574e6b46455a0237703b7364fac77e4
Reviewed-on: https://chromium-review.googlesource.com/c/1349809
Reviewed-by: Marc-Antoine Ruel <maruel@chromium.org>
Commit-Queue: Marc-Antoine Ruel <maruel@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 06a7c1e..043717b 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -683,7 +683,7 @@
   if len(files) == 0:
     return {}
 
-  # Take diff and find the line ranges where there are changes.
+  # Take the git diff and find the line ranges where there are changes.
   diff_cmd = BuildGitDiffCmd('-U0', upstream_commit, files, allow_prefix=True)
   diff_output = RunGit(diff_cmd)
 
@@ -5322,7 +5322,11 @@
   # Generate diff for the current branch's changes.
   diff_cmd = ['-c', 'core.quotePath=false', 'diff', '--no-ext-diff']
 
-  if not allow_prefix:
+  if allow_prefix:
+    # explicitly setting --src-prefix and --dst-prefix is necessary in the
+    # case that diff.noprefix is set in the user's git config.
+    diff_cmd += ['--src-prefix=a/', '--dst-prefix=b/']
+  else:
     diff_cmd += ['--no-prefix']
 
   diff_cmd += [diff_type, upstream_commit, '--']