3

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?

ProgramFOX
  • 6,131
  • 11
  • 45
  • 51
Nycto
  • 1,670
  • 2
  • 14
  • 18

1 Answers1

3

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
  • 4,257
  • 4
  • 18
  • 12
  • 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 Jun 11 '10 at 22:23
  • Actually, you could probably just use filter-branch, forget about the rebase --autosquash entirely. – dublev Jun 11 '10 at 22:32
  • 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 Jun 28 '10 at 15:59
  • @Nycto - I am looking for a way to automate/script the squashing process, similiarly the manual intervention is a problem with rebase -i. Could you elaborate on your solution if possible? Much appreciated. – marked Dec 07 '12 at 16:42