Skip to content
Snippets Groups Projects
Commit 5354c3d6 authored by David Greenaway's avatar David Greenaway Committed by CQ bot account: commit-bot@chromium.org
Browse files

[fx][format-code] Avoid reformatting unmodified files.

format-code's default mode of `--git` current determines which files
have been modified by using `git diff-index`. `diff-index`, however,
returns not only files that have been modified since the base commit,
but also files that don't have the expected modified time on disk. (For
example, any file that has been touch'ed). This leads to more files
being formatted than expected, such as in workflows such as the
following:

  sed -i -e s/foo/bar/ *.cc
  fx format-code

which will result in all C++ files being formatted, and not just those
modified.

This patch updates format-code to simply use `git diff <BASE_COMMIT>`.
When a base commit is provided, git diff returns (i) committed results;
(ii) staged results; and (iii) files modified in the working directory.
This should match the current behaviour of `fx format-code --git`.

Change-Id: Ie3bcac4322bd2cc4ba64b0f440fae5d76ff94b33
parent 740736b2
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment