On 2011.1.27 10:43 AM, Timothy Knox wrote:
> Bonus hate: When I am refactoring software, I will sometimes rename a
> variable or function or what-have-you. Before I submit the code to my
> source repository, I'd like to ensure that I am not picking up any stray
> diffs (debugging changes, forgot to sync before checkin, etc). It would
> be awfully nice if diff gave one the ability to say, in essence, take
> one of the files, and notionally perform the following substitution,
> then diff the resultant with the other file. In other words, only show
> me the diffs I don't recall making. HATE!

Take advantage of the fact that diff doesn't try to be some huge, bloated
refactoring tool...

    perl -nwle 's{foo}{bar}' old_file | diff - new_file

But I think what you really hate is your version control system.

The CVS way...

    ...refactor stuff...
    ...debug stuff...
    ...edit stuff...
    ...add a new feature...
    ...take a nap...
    ...refactor some more...
    cvs diff
    ...oh god what is all this crap I did...

The distributed way...

    ....refactor stuff....
    git diff
    ...looks ok so...
    git commit
    ....do some more work...
    git diff
    ....looks ok so...
    git commit
    ...now I'm done and ready to inflict it on everyone else...
    git push

(or you can "git add ." or even "git commit --amend" if you don't like lots of
little commits)


-- 
191. Our Humvees cannot be assembled into a giant battle-robot.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/

Reply via email to