views:

99

answers:

1

My company is in the middle of converting from CVS over to git. We've been on CVS for a long time, so there is a huge history. Too much to do by hand.

Looking at the logs, there is a lot of squashing that could be done. A whole lot. What I would like to do is hook in a script that will compare two adjacent commits. If it returns true, then concatenate the commit messages and squash the commits. I would also be happy with a command that accepts two commits and a commit message, then squashes them together.

git rebase --interactive is close to what I need, but "squash" requires far too much manual intervention. I also looked at using "fixup" instead of squash, but I don't want to lose the commit messages.

Any ideas?

+2  A: 

How about --autosquash?

You could combine it with git filter-branch to script renaming the commits. (A word of warning, though. Be careful with filter branch, and read the warnings in its man page. It's not a command for the faint of heart.)

dublev
I could be wrong, but that still won't to solve the "Message Concatenation" problem. Autosquash looks to be the same as squash/fixup, but based on the commit message.
Nycto
Actually, you could probably just use filter-branch, forget about the rebase --autosquash entirely.
dublev
Your suggestion about filter-branch turned out to be correct. Using the "commit-filter" flag allows you to process each commit in the entire repo. Within the callback script it has you pass in, you can pipe a message into the commit-tree command to change the commit message. You can also call skip_commit to merge the current commit into the following commit.
Nycto