[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
Loading
Please register or sign in to comment