On 13 February 2017 at 08:59, Vladimir Sitnikov <[email protected] > wrote:
> sebb>My experience is that code reformatting makes history browsing very > much harder. > > Could you give any example here? What particular use case breaks with > single-commit reformatting? > > Just to be clear: I don't suggest to reformat the code to some completely > alien format. I suggest to pick a format that suits most part of the > current code. > > Let me show an example that "browsing history through reformats" just > works. > It is not a theoretical example, but a very real one. > > I'll pick v3/QueryExecutorImpl from pgjdbc (that is one of the core class > that implements wire protocol, so its history browsing is important). > Here's what Github shows for the "reformat commit": > [image: 01_github_reformat_diff.png] > Basically, Github shows that "everything was changed". > Indeed the file used to have 4 space for indentation, and it was formatted > with 2 space indentation. Braces were forced after each if/else statement, > etc, etc. > There are 341 differences with "do not ignore whitespace" mode, and there > are 220 differences with "ignore whitespace" mode. > > Just for the reference: this file suffered relocation in the source tree > on 20.12.2015 as a part of "ant -> maven" migration. > > Here's the same file/line opened in IntelliJ as of now: > [image: 02_intellijidea_annotate.png] > Attachments not present; they are dropped by most Apache mailing lists. > You can see how "annotate" attributes lines way back to 2005 even though > almost every line was altered on 29.12.2015 formatting commit. > It just works across reformat and maven migration. > > So leading/trailing whitespace changes are harmless. > What happens to "add space after if", "add braces to if" kind of changes? > Of course they are listed in the annotate. > For instance: > [image: 03_brace_added_annotate.png] > Lines 1574 and 1576 are a part of reformat commit that added braces around > if. > Does it make history browsing harder? > I don't think so, as I can just click "annotate previous revision" > AFAIK, that does not work in Eclipse > [image: 04_annotate_prev_revision.png] > and see how the file looked like before reformatting took place: > [image: 05_prev_revision_annotated.png] > So having a common format is a win as > 1) it makes code easier to read, and thus contribute > 2) it makes code more robust in face of "goto fail" kind of bugs > Agreed > 3) it still allows decent annotate/history browsing > I'm not convinced. Note also that JMeter uses SVN currently, which behaves differently. Try doing the same exercise with a JMeter file. > Vladimir > >
