Page MenuHomePhabricator

[git-clang-format] Add --diffstat parameter
AcceptedPublic

Authored by roligugus on Jul 22 2020, 5:31 PM.

Details

Summary

[git-clang-format][PR46815] Add diffstat functionality

Adding a --diffstat parameter to git-clang-format that essentially uses git diff --stat, i.e. lists the files needing
formatting. This is useful for CI integration or manual usage where one wants to list the files not properly formatted.

I use it for the Suricata project's github action (CI) integration that verifies proper formatting of a pull request
according to project guidelines where it's very helpful to say which files are not properly formatted. I find the list
of files much more useful than e.g. showing the diff in this case using git-clang-format --diff.

An alternative would be to take an additional parameter to diff, e.g. git-clang-format --diff --stat

The goal is not to provide the whole git diff --stat=... parameter functionality, just plain git diff --stat.

Diff Detail

Event Timeline

roligugus created this revision.Jul 22 2020, 5:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 22 2020, 5:31 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
roligugus added a project: Restricted Project.Jul 22 2020, 5:56 PM
roligugus marked an inline comment as done.
roligugus added inline comments.
clang/tools/clang-format/git-clang-format
101

As mentioned in the description, an alternative would be to add a --stat parameter and hand that to print_diff(). E.g. user would call it then with git-clang-format --diff --stat.

Would result in less code duplication of print_diff() vs print_diffstat().

This looks fine to me, but I haven't worked on this part of code myself, so probably others who have can provide better review.

aheejin resigned from this revision.Aug 8 2020, 2:28 AM
JakeMerdichAMD added a subscriber: JakeMerdichAMD.

Reviving this since it looks perfectly fine to me (from my limited commit history in git-clang-format :P), is useful, and there's no good reason for it to be stalled.

I'll wait a day or two to see if there's any objections, then accept it.

JakeMerdichAMD accepted this revision.Aug 23 2020, 3:40 PM
This revision is now accepted and ready to land.Aug 23 2020, 3:40 PM