Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

domm (4030)

  (email not shown publicly)

Just in case you like to know, I'm currently full-time father of 2 kids, half-time Perl hacker, sort-of DJ, bicyclist, no longer dreadlocked and 33 years old

I'm also head of [], maintainer of the CPANTS [] project, member of the TPF Grants Commitee [] and the YAPC Europe Foundation [].

I've got stuff on CPAN [], held various talks [] and organised YAPC::Europe 2007 in Vienna [].

Journal of domm (4030)

Friday September 05, 2008
05:07 AM

/me loves git

[ #37359 ]

Some of the reasons I really like git, all experienced in this week:

Prepare CHANGES file

Run git log --no-merges --pretty=format:' - %s (%an)' `git tag | tail -n 1`.. to get a nicely formatted list of changes (and who checked it in) since the last tag. OK, most other VCS can also do similar, but git let's me alias this in my .gitconfig so I don't have to remember the details and just say git last_changes.

Revert a repo to a few hours earlier

A colleague complains that the test suite for one modul is broken, and he can't fix it. I check out his head, and can't find the problem after a few minutes. But I experience strange behaviour during tests (if you run a single test, it works, if you run all tests, it fails). So, we assume it has to with the tests fu̸cking up the DB. To prove that his changes caused the problem, I do git co a_ref_befor_his_commit and magically travel back in time. The tests work now. So we do git co HEAD to travel back into the present, and after some cross-history-diffing, we find the bug & fix it.

No need to set up a server

I was fuzzing with our post-receive hooks, which run after somebody pushed something into the public repo. Our hooks do obvious things like sending out commit mail and IRC notifications, but also nice stuff like building a tarball and uploading it to our custom cpan when the commit was a tag. Only this wasn't working after we switched to another notify-script.

But because git doesn't care where you clone from, and what exactly is a public repo, it was easy to set up a local repo on my disk, clone from it, declare another repo on my disk to be the "remote" and thus test all of the scripts without a) network, b) spamming my colleagues and (most importanly) c) any complicated setup. All that was needed were some dirs on my laptop.

And that's it for todays git propaganda!

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • On my machine, "git tag" appears to give the tags in alphabetical order, not in chronological order. So, this gives the changes since the tag that is last alphabetically, not chronologically. Those may be different if you don't name your tags after version numbers.
    • that's a strange requirement, but you can use something like this:

      git-for-each-ref refs/tags/* --format="%(tag)" --sort="taggerdate"

      Well, that only works for annotated tags... use '%(refname)' instead of '%(tag)' and add '--sort=committerdate' for a version that works with lightweight tags too. It just looks slightly uglier :-)

  • You should look at git bisect :)

    life is short
  • Did you notice that the bash/zsh tab-completion will also tab complete that alias command you defined?

    Also, be warned that when you clone, it doesn't clone absolutely everything unless you use --mirror - by default it will just clone "heads" and "tags"