Skip to content
Glenn H Tarbox, PhD edited this page Oct 3, 2015 · 5 revisions

Welcome to the GitReformat wiki!

======

Rewrite history!!!

Git blame, and more generally, the history of a project as viewed through git commits is critically useful. Reformatting a projects code (to comply with PEP-8 for example) has, the unfortunate side effect of destroying much of the history exposed by blame. Many projects, understandably, decide that the history is more valuable than the benefit enhanced code style provides,

Ideally, we'd like to reformat yet maintain the Git annotations.

Introducing the GitHistoricalReDisEntangler, or some other really fancy name.

How it works

We want "both kinds" -- history and formatting. Realizing that blame annotation is derived from local changes at each git-commit. If we transform (reformat) the code base immediately prior to each existing commit, locality and intent of each change will remain intact.

We start at the beginning -- 'git init'. Depth first search to the root, fork, and follow all the way back to the current HEAD (actually, all the heads)

Note the [yapf] comments added.

Even works when it gets complicated.

At the heads, there is a corresponding -yapf

This asciicast shows (kinda) how similar the commits are though all the formatting has changed.

How to use

Don't Merge!!

Basically, you run it and then, should you choose, make one of the reformatted heads the new head.

git checkout master
git checkout -b master-legacy
git branch -f master master-yapf
git checkout master
Clone this wiki locally