I formatted Carpet's source code with clang-format. If you are maintaining a branch or patches, then you should reformat them as well to minimize conflicts. I am very interested in hearing whether this causes any problems.
-erik
... and here is how to reformat your source code:
(1) Install clang-format, which comes with the clang compiler, e.g. the "clang-format-3.6" package on Ubuntu (2) Run "clang-format -i *.hh *.cc" (the "-i" option modifies files in-place)
(3) For added benefit: Install a clang-format package for your favourite editor that provides a key shortcode for reformatting, or even reformats automatically when you save (that's what I do). I'm using Atom < https://atom.io%3E with https://github.com/LQDH/atom-clang-format for this.
-erik
On Mon, Nov 23, 2015 at 2:34 PM, Erik Schnetter schnetter@gmail.com wrote:
I formatted Carpet's source code with clang-format. If you are maintaining a branch or patches, then you should reformat them as well to minimize conflicts. I am very interested in hearing whether this causes any problems.
-erik
-- Erik Schnetter schnetter@gmail.com http://www.perimeterinstitute.ca/personal/eschnetter/
On Mon, Nov 23, 2015 at 03:13:36PM -0500, Erik Schnetter wrote:
... and here is how to reformat your source code:
(1) Install clang-format, which comes with the clang compiler, e.g. the "clang-format-3.6" package on Ubuntu (2) Run "clang-format -i *.hh *.cc" (the "-i" option modifies files in-place)
This is what happens for me:
$ git clone https://bitbucket.org/eschnett/carpet.git Cloning into 'carpet'... remote: Counting objects: 42555, done. remote: Compressing objects: 100% (12129/12129), done. remote: Total 42555 (delta 31639), reused 40682 (delta 30202) Receiving objects: 100% (42555/42555), 59.27 MiB | 22.80 MiB/s, done. Resolving deltas: 100% (31639/31639), done. Checking connectivity... done. +knarf@topf:~/ET_dev/repos$ cd carpet/Carpet/src/ +knarf@topf:~/ET_dev/repos/carpet/Carpet/src$ clang-format-3.5 -i *.hh *.cc +knarf@topf:~/ET_dev/repos/carpet/Carpet/src$ git diff | wc -l 594
Does this mean we would require clang-format-3.6 (and not supporting 3.5 or earlier)? I thought clang-format wouldn't change the way it formats stuff in between versions, but it apparently does. One example from the current changes:
-vector<vector<int> > const &HostProcs() { return host_procs; } +vector<vector<int>> const &HostProcs() { return host_procs; }
Frank
Frank
These changes are independent of the clang-format version. You are most likely missing the file Cactus/.clang-format that defines how to format the code. By default, clang-format assumes C++11 compilers for C++ code, but some machines cannot handle this yet, so we format for the C++03 standard. (This is the option "Standard: Cpp03" in .clang-format.)
-erik
On Mon, Nov 23, 2015 at 3:23 PM, Frank Loeffler knarf@cct.lsu.edu wrote:
On Mon, Nov 23, 2015 at 03:13:36PM -0500, Erik Schnetter wrote:
... and here is how to reformat your source code:
(1) Install clang-format, which comes with the clang compiler, e.g. the "clang-format-3.6" package on Ubuntu (2) Run "clang-format -i *.hh *.cc" (the "-i" option modifies files in-place)
This is what happens for me:
$ git clone https://bitbucket.org/eschnett/carpet.git Cloning into 'carpet'... remote: Counting objects: 42555, done. remote: Compressing objects: 100% (12129/12129), done. remote: Total 42555 (delta 31639), reused 40682 (delta 30202) Receiving objects: 100% (42555/42555), 59.27 MiB | 22.80 MiB/s, done. Resolving deltas: 100% (31639/31639), done. Checking connectivity... done. +knarf@topf:~/ET_dev/repos$ cd carpet/Carpet/src/ +knarf@topf:~/ET_dev/repos/carpet/Carpet/src$ clang-format-3.5 -i *.hh *.cc +knarf@topf:~/ET_dev/repos/carpet/Carpet/src$ git diff | wc -l 594
Does this mean we would require clang-format-3.6 (and not supporting 3.5 or earlier)? I thought clang-format wouldn't change the way it formats stuff in between versions, but it apparently does. One example from the current changes:
-vector<vector<int> > const &HostProcs() { return host_procs; } +vector<vector<int>> const &HostProcs() { return host_procs; }
Frank
On Mon, Nov 23, 2015 at 03:46:44PM -0500, Erik Schnetter wrote:
These changes are independent of the clang-format version. You are most likely missing the file Cactus/.clang-format that defines how to format the code. By default, clang-format assumes C++11 compilers for C++ code, but some machines cannot handle this yet, so we format for the C++03 standard. (This is the option "Standard: Cpp03" in .clang-format.)
I do have a .clang-format in my Cactus root directory (and the carpet clone is inside that).
Frank
On Mon, Nov 23, 2015 at 03:02:31PM -0600, Frank Loeffler wrote:
On Mon, Nov 23, 2015 at 03:46:44PM -0500, Erik Schnetter wrote:
These changes are independent of the clang-format version. You are most likely missing the file Cactus/.clang-format that defines how to format the code. By default, clang-format assumes C++11 compilers for C++ code, but some machines cannot handle this yet, so we format for the C++03 standard. (This is the option "Standard: Cpp03" in .clang-format.)
I do have a .clang-format in my Cactus root directory (and the carpet clone is inside that).
I did have such a file, but it seemed to be an old version somehow, not linked to the version in the Cactus flesh.
What I now get is this:
$ git clone https://bitbucket.org/eschnett/carpet.git Cloning into 'carpet'... remote: Counting objects: 42560, done. remote: Compressing objects: 100% (12134/12134), done. remote: Total 42560 (delta 31633), reused 40689 (delta 30202) Receiving objects: 100% (42560/42560), 59.30 MiB | 35.51 MiB/s, done. Resolving deltas: 100% (31633/31633), done. Checking connectivity... done. +knarf@topf:~/ET_dev/repos$ cd carpet/Carpet/src/ +knarf@topf:~/ET_dev/repos/carpet/Carpet/src$ clang-format-3.5 -i *.hh *.cc YAML:18:29: error: invalid boolean BreakBeforeBinaryOperators: None ^~~~ Error reading /home/knarf/ET_dev/.clang-format: Invalid argument Can't find usable .clang-format, using LLVM style ... <many lines>
... and since it falls back to LLVM style the same changes.
To get it to work, I would have to take these out:
BreakBeforeBinaryOperators BinPackArguments ObjCBlockIndentWidth AlwaysBreakAfterDefinitionReturnType SpaceAfterCStyleCast AllowShortCaseLabelsOnASingleLine AlignAfterOpenBracket ... I stopped here. The current .clang-format is clearly not version for clang-format-3.5 and below.
Frank
On Mon, Nov 23, 2015 at 02:34:38PM -0500, Erik Schnetter wrote:
I formatted Carpet's source code with clang-format. If you are maintaining a branch or patches, then you should reformat them as well to minimize conflicts. I am very interested in hearing whether this causes any problems.
Wouldn't changing all files in the branch using clang-format (assuming clang-format would actually behave the same way on different machines) create merge conflicts in git? After all - git couldn't decide which of the commits to keep, even if the changes are the same. It did when I tried.
The alternative is to merge with master first, before any format changes on the branch. But this of course also leaves you with conflicts in anything your branch touched.
Frank
users@lists.einsteintoolkit.org