Thu, 25 Oct 2012
Getting a list of git tags to a particular ref
For some reason, I'm always doing something related to backups, and frequently I need a way of testing backup software to see how it operates, if it's doing things properly and working the way I expect, etc.
One way I came up to test is to use a large git repository as a testbed — it's got easily reproducable history and you can check the correctness of any restore --- does a particular restore match what git thinks a particular ref should be? To do this, it's nice to find a linear path between two points in a repository's history. For that, I did this:
git rev-list --simplify-by-decoration --pretty=oneline --reverse HEAD
If you do that, you get a list, in chronological order, of every tag between the start of a repository and your current HEAD. If you want every commit, remove --simplify-by-decoration. The output is "[sha1] [title]"; you can use the [sha1] to check out that tag in the repository.
This works well for me with the OpenAFS git repository; I'm familiar with it, and it's got a rich set of tags. But any repo should do, as long as it's got enough history for you to find it useful.
Posted at: 14:25 | category: /computers/git | Link