How to commit a file conversion?
- by l0b0
Say you've committed a file of type foo in your favorite vcs:
$ vcs add data.foo
$ vcs commit -m "My data"
After publishing you realize there's a better data format bar. To convert you can use one of these solutions:
$ vcs mv data.foo data.bar
$ vcs commit -m "Preparing to use format bar"
$ foo2bar --output data.bar data.bar
$ vcs commit -m "Actual foo to bar conversion"
or
$ foo2bar --output data.foo data.foo
$ vcs commit -m "Converted data to format bar"
$ vcs mv data.foo data.bar
$ vcs commit -m "Renamed to fit data type"
or
$ foo2bar --output data.bar data.foo
$ vcs rm data.foo
$ vcs add data.bar
$ vcs commit -m "Converted data to format bar"
In the first two cases the conversion is not an atomic operation and the file extension is "lying" in the first commit. In the last case the conversion will not be detected as a move operation, so as far as I can tell it'll be difficult to trace the file history across the commit. Although I'd instinctively prefer the last solution, I can't help thinking that tracing history should be given very high priority in version control. What is the best thing to do here?