Stories
Slash Boxes
Comments
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 ]

BooK (2612)

BooK
  {book} {at} {cpan.org}
http://paris.mongueurs.net/
Yahoo! ID: philippe_bruhat (Add User, Send Message)

Obfuscation [plover.com]. Pink [axis-of-aevil.net]. HTTP::Proxy [cpan.org]. YEF [yapceurope.org]. Fishnet [perl.org]. Kapow [cpan.org]. Cog's [perl.org] bitch [cpan.org]. Invitation [perl.org]. White [perl.org] Camel [perl.org]. Nuff' said.

Journal of BooK (2612)

Monday November 23, 2009
07:41 AM

git-mtime

[ #39932 ]

Ever complained that on a checkout Git did not reset the mtime of your files to the date when they were commited?

My home page is generated with Template Toolkit but a script stored in the post-receive hook. On a checkout Git only updates the files that have changed, so normally I can trust template.modtime to be correct and use it to show a Last mofidied date.

But I'm a perfectionist, and I want to be extra sure. So I created this little utility, that I called git-mtime:

    #!/bin/sh
    git log --name-only --date=iso --reverse --pretty=format:%at "$@" \
    | perl -00ln -e '($d,@f)=split/\n/;$d{$_}=$d for grep{-e}@f' \
                 -e '}{utime undef,$d{$_},$_ for keys%d'

Note that it passes all parameters to git log, so you can apply it on a subdirectory (using --), or even use the dates from another branch (though I'm not sure what use this can have).

And for extra bonus points, it uses the secret eskimo greeting operator!

Now that I have a few gadgets based on Git, I thought I might as well publish them somewhere. A quick look on Github ruled out git-tools, git-utils and git-extras (come on people, most of these things could be done with Git aliases!). git-aid (especially the plural) didn't seem like a good name either. So after looking around for synonyms, I settled on git-gadgets.

Clone it from http://github.com/book/git-gadgets.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.