Reformatting the source

From Unvanquished
Jump to: navigation, search

The Daemon and Unvanquished repositories suffer from differing code style conventions and fractally varying choice of indentation (spaces vs. tabs). The inconsistency is a constant source of friction for developers. I (slipher) propose that we may reformat the source code (in one big commit) if we have all of the following:

  1. Whitespace-ignoring replacements for 'git diff' and 'git blame'
  2. A configuration file for some cross-platform formatting tool which produces satisfying results
  3. A script to rewrite a chain of commits using the formatting tool (for use with unmerged branches)


  1. freem suggests a method for configuring git blame to ignore a particular commit:

    Here is a prototype Bash script for doing a whitespace-ignoring invocation of git diff, which works by plugging into Git as an external diff tool and processing both sides of the diff with clang-format. It is probably a bad idea to use it without specifying specific paths, since in that case, if used across the reformatting commit, it will have to process every source file in the tree (TODO: see how slow that really is).
  2.  ?
  3.  ?

Areas requiring special attention

Some people have noted difficulties with autoformatters and lambda function. cg_api.cpp is one file with a lot of lambdas.

We should consider if we want to preserve formatting of tables such as gameCvarTable in sg_main.cpp.