presubmit: use git diff -U0 for CheckPatchFormatted()

git cl format uses `git diff -U0` when it has to find the files
and ranges to format. Similarly, CiderG generates diffs with
-U0 and run presubmits for the checks.

However, the scm.py:GenerateDiff(), which CheckPatchFormatted() uses,
doesn't specify -U and it defaults to -U3.

This CL updates CheckPatchFormatted() to pass -U0 to
scm.py:GenerateDiff() so that Presubmit and git cl format are
always given diffs generated with -U0.

Bug: 386840832
Change-Id: I19479ab139b7dba8ba4e5e5fed89eca4d2e66412
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6952890
Auto-Submit: Scott Lee <ddoman@chromium.org>
Commit-Queue: Brian Ryner <bryner@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Reviewed-by: Brian Ryner <bryner@google.com>
This commit is contained in:
Scott Lee
2025-09-16 09:50:19 -07:00
committed by LUCI CQ
parent 9d7425377e
commit 927f7dad38
3 changed files with 7 additions and 3 deletions

View File

@@ -1060,7 +1060,8 @@ class _GitDiffCache(_DiffCache):
full_move=True,
branch=self._upstream,
branch_head=self._end_commit,
allow_prefix=True)
allow_prefix=True,
context=0)
# Compute a single diff for all files and parse the output; with git
# this is much faster than computing one diff for each file.
self._diffs_by_file = _parse_unified_diff(unified_diff)