git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Tim Visher <tim.visher@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>,
	Eric Wong <normalperson@yhbt.net>
Subject: Re: Print last time and committer a file was touched by for a whole repo
Date: Thu, 1 Jul 2010 15:05:25 -0500	[thread overview]
Message-ID: <20100701200525.GA3686@burratino> (raw)
In-Reply-To: <AANLkTikRElk07ZqK0TOM2WD31t-H5RVngvHNU9KM7e9D@mail.gmail.com>

Hi Tim,

Tim Visher wrote:

> I need to get a listing of the entire contents of my current repo (as
> in, I don't need deleted files or anything like that, just the current
> snapshot) with the time the file was committed and who committed it.

You might be able to adapt Eric’s set-file-times script from [1].

The set-file-times script was designed to produce consistent
Last-Modified headers when serving static content from a cluster of
HTTP servers.  It does not do the right thing for merges (it is
missing at least ‘-c’), though it will at least produce consistent
results in that case.  See the wiki page for details.

For reference:

 #!/usr/bin/perl -w
 # Use of this script in combination with ‘make’ is asking for trouble.

 use strict;

 my %ls = ();
 my $commit_time;

 $/ = "\0";
 open FH, 'git ls-files -z|' or die $!;
 while (<FH>) {
	chomp;
	$ls{$_} = $_;
 }
 close FH;

 $/ = "\n";
 open FH, "git log -r --name-only --no-color --pretty=raw -z @ARGV |"
 or die $!;
 while (<FH>) {
	chomp;
	if (/^committer .*? (\d+) (?:[\-\+]\d+)$/) {
		$commit_time = $1;
	} elsif (s/\0\0commit [a-f0-9]{40}$// or s/\0$//) {
		my @files = delete @ls{split(/\0/, $_)};
		@files = grep { defined $_ } @files;
		next unless @files;
		utime $commit_time, $commit_time, @files;
	}
	last unless %ls;
 }
 close FH;

Hope that helps,
Jonathan

[1] https://git.wiki.kernel.org/index.php/ExampleScripts#Setting_the_timestamps_of_the_files_to_the_commit_timestamp_of_the_commit_which_last_touched_them

  parent reply	other threads:[~2010-07-01 20:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01 19:05 Print last time and committer a file was touched by for a whole repo Tim Visher
2010-07-01 19:45 ` Eric Raible
2010-07-01 20:05 ` Jonathan Nieder [this message]
2010-07-01 21:40   ` Eric Wong
2010-07-02  3:37     ` Jonathan Nieder
2010-07-01 20:12 ` Jakub Narebski
2010-07-02 11:55   ` Tim Visher
2010-07-03  9:13     ` Jakub Narebski
2010-07-05  9:53       ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100701200525.GA3686@burratino \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=normalperson@yhbt.net \
    --cc=tim.visher@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).