How to commit a file conversion?

Posted by l0b0 on Programmers See other posts from Programmers or by l0b0
Published on 2012-06-10T22:11:02Z Indexed on 2012/06/10 22:46 UTC
Read the original article Hit count: 371

Filed under:

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?

© Programmers or respective owner

Related posts about version-control