views:

53

answers:

2

I'm converting the infrastructure at my workplace to use git instead of svn. The overall migration is going well, but we have a tool that I developed to do our SQL schema migrations.

In order to deal with individual schema change dependencies, the migrations script used subversion keyword replacement to put the last-changed revision number in the schema. With git, we can't use the same idea, since revision history is non-linear (and we're fully intending on utilizing the branching features).

Therefore, how do I get a topologically sorted list of commit ids out of git? Barring that, anyone have a better idea for how to handle this problem?

+1  A: 
git rev-list old-revision..new-revision

That shows newest-first. If you want oldest-first, add --reverse

Dustin
A: 

If you want to have a way to track where a file came from in your source code repository, you may want to look into tagging your work and finding some way to mark the file with the tag it came from. Some of this depends on your actual deployment process, but my short answer would be to replace svn keywords with a tag-based mechanism. (It may have been what you should have been doing in svn all along, actually.)

I've heard "smudge filters" mentioned around here, but I haven't used them myself, so I can't speculate how they might fit in here.

MikeSep
Tags are too heavy-weight for us, but this would definitely work in general!. Thanks.
Silas
version tags + `git describe` could help. If your HEAD is 13 commits after tag foo-1.2 and has SHA 5af74bc, that produces something like "foo-1.2-13-g5af74bc". If you add the branch name and whether the local tree is dirty or not, that gives a lot of information on where that file came from. However, you will need to do all that in the build logic, not in some checkout magic.
ndim