Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add astyle-diff target in Makefile to format modified files only #62111

Merged
merged 1 commit into from Nov 8, 2022

Conversation

BrettDong
Copy link
Member

Summary

None

Purpose of change

make astyle-fast still walks through all source files in the project. That could be slow on systems with slow disk I/O. It would be nice if I can just let AStyle read and format the files that I've changed.

Describe the solution

Add a astyle-diff Makefile targets that only format files modified. The list of edited files is generated by git diff --name-only.

Describe alternatives you've considered

Testing

On a clean source tree, touch a single .cpp file, and run make astyle-diff. Only that single file is read and formatted by AStyle.

Additional context

@github-actions github-actions bot added Code: Build Issues regarding different builds and build environments json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Nov 6, 2022
@BrettDong BrettDong changed the title Add astyle-diff target in Makefile to only format modified files Add astyle-diff target in Makefile to format modified files only Nov 6, 2022
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Nov 6, 2022
@ZhilkinSerg ZhilkinSerg merged commit 6b42d88 into CleverRaven:master Nov 8, 2022
@akrieger
Copy link
Member

akrieger commented Nov 12, 2022

make astyle already only changes files updated since the last make astyle, and it relies on make's own logic for that instead of forking out to another program. The only time that this new make command helps is running make astyle after a rebase or other git operation which changes a lot of files, and after that the timestamps are updated already so subsequent invocations only style newly changed json. Is that sufficiently painful that this is useful, in which case, should we just change make astyle to use this logic (which would strictly regress it on Windows because shelling out and git are both substantially slower on Windows than elsewhere)?

@BrettDong BrettDong deleted the astyle-diff branch December 6, 2022 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions Code: Build Issues regarding different builds and build environments json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants