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

Request: Add the .clang-format file to the repository #2703

Closed
Naios opened this issue Jun 19, 2017 · 9 comments · Fixed by #2706
Closed

Request: Add the .clang-format file to the repository #2703

Naios opened this issue Jun 19, 2017 · 9 comments · Fixed by #2706

Comments

@Naios
Copy link
Contributor

Naios commented Jun 19, 2017

@hkaiser It would be really useful, if the HPX project could include the .clang-format file you sent me recently into the main tree, in order to provide official support for clang-format.

It's difficult to work with branches meant for pull requests while keeping an untracked .clang-format file, because the config pollutes the working directory which prevents some commonly used git commands like rebasing.

Also, an officially supported config could increase the usage of the formatter to get a better and consistently formatted codebase.

@hkaiser hkaiser added this to the 1.1.0 milestone Jun 19, 2017
@hkaiser
Copy link
Member

hkaiser commented Jun 19, 2017

I'd like to hear everybody's opinion on this.

@sithhell
Copy link
Member

sithhell commented Jun 19, 2017 via email

@hkaiser
Copy link
Member

hkaiser commented Jun 19, 2017

Here are the problems I see (all of which have already been discussed):

  • if we add a .clang-format to the repository any edit may (will?) result in a full reformatting of the file
  • partial reformats (only the lines touched by an edit) will result in inconsistent formatting
  • full reformatting of the whole code base destroys all of the edit history

the bottom line is that there does not seem to be a solution which has no bad side effects. The only viable application of a .clang-format file would be to use it for new files or for massive edits of older files, which implies for it to be manually used only. Not sure how to enforce this, however.

@Naios
Copy link
Contributor Author

Naios commented Jun 19, 2017

You could still not enforce the formatting from the CI side, but recommend to developers to use it.
This would have the benefit that no full reformatting of the source is needed.
As I know LLVM is doing it in this way while providing its own .clang-format file.

@hkaiser
Copy link
Member

hkaiser commented Jun 19, 2017

@Naios: do the LLVM guys have that written up somewhere as a policy?

@Naios
Copy link
Contributor Author

Naios commented Jun 19, 2017

@hkaiser Currently I don't know anything about such a policy in the LLVM project (also my search didn't reveal anything related).
However as I remind there were some sections of the project not formatted, probably not to destroy the git log for better bisect support (see LLVM's bugpoint tool).
Probably we would need to ask in the LLVM IRC in order to receive an answer about this.

@biddisco
Copy link
Contributor

biddisco commented Jun 20, 2017

I do not see how having a .clang-format file in your tree affects rebasing. I have one in mine and I rebase all the time. (rebasing is only affected when files tracked by git are in a modified state)

I am in favour of adding the clang-format file to the repo. It should be provided so that as we work on classes we can reformat them as we go. There is no need to reformat the entire code base in one go - our inspect tool already enforces style well enough that existing code is fine. It's nice to be able to format new or edited code using the tool and know that it will pass inspect checks.

The clang-format file I'm using can't be used to reformat the whole file as it indents the namespaces too much - but it's fine for sections of code. (I got it from Thomas originally so it's probably the same one as used by others).

@biddisco
Copy link
Contributor

biddisco commented Jun 20, 2017

Addressing these points ...

  • if we add a .clang-format to the repository any edit may (will?) result in a full reformatting of the file
    Why? Only when the user says "reformat this file" does that happen. In my QtCreator, there is an option to automatically run the format tool on save/etc. I have that turned off.
  • partial reformats (only the lines touched by an edit) will result in inconsistent formatting
    I think the clang-format generated style is close enough to what's used that
    a) we do not need to worry
    b) we are grown up enough to cope with some minor differnces
  • full reformatting of the whole code base destroys all of the edit history
    Let's not do that then.

@sithhell
Copy link
Member

sithhell commented Jun 20, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants