This is an archive of the discontinued LLVM Phabricator instance.

git-clang-format: refactor to support upcoming --staged flag
AcceptedPublic

Authored by lodato on Dec 12 2017, 5:16 PM.

Details

Summary

The only user-visible change is rewriting of the --help message to make the different modes more clear.

Internally, this is a significant refactoring to make the source and destination of the diff to be more clear by using subclasses rather than conditionals. The purpose is to support the next patch in this series, which adds support for a --staged flag. But even if that does not go through, the intent is for this code to be a readability improvement.

Note: In run_clang_format_and_save_to_tree(), we now generate the entire index up front rather than feeding it in line-by-line via a generator. The reason we must do this is because, in the future --staged implementation, we need to read from the index *before* calling crate_tree() since create_tree() uses a temporary index file. In practice, this will have no performance impact because the previous commit (D41130) switched to loading it all into memory in create_tree() anyway.

Diff Detail

Event Timeline

lodato created this revision.Dec 12 2017, 5:16 PM
klimek accepted this revision.Dec 13 2017, 1:02 AM

lg

google3/third_party/llvm/llvm/tools/clang/tools/clang-format/git-clang-format
252

Don't we want to die if len(commits) > 2?

This revision is now accepted and ready to land.Dec 13 2017, 1:02 AM
lodato updated this revision to Diff 126792.Dec 13 2017, 10:58 AM

Re-add check for len(commits) > 2.

lodato marked an inline comment as done.Dec 13 2017, 10:58 AM

Oops! Fixed. Thanks for catching this!

shafik added a subscriber: shafik.Sep 21 2023, 9:38 AM

Is this still relevant or can we close this?

Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2023, 9:38 AM
Herald added a subscriber: wangpc. · View Herald Transcript