git: --getctime will now follow renames back to the original creation of a file.

This will be a bit more expensive, but --getctime does not need to be fast.
And getting the real creation time a very useful when untangling blog
histories that involve renames.
master
Joey Hess 2009-10-11 22:38:42 -04:00
parent 99eec4f03d
commit 33f42db2ea
2 changed files with 7 additions and 3 deletions

View File

@ -613,9 +613,11 @@ sub rcs_getctime ($) {
# Remove srcdir prefix # Remove srcdir prefix
$file =~ s/^\Q$config{srcdir}\E\/?//; $file =~ s/^\Q$config{srcdir}\E\/?//;
my @sha1s = run_or_non('git', 'rev-list', 'HEAD', '--', $file); my @raw_lines = run_or_die('git', 'log', '--reverse', '--follow',
my $ci = git_commit_info($sha1s[$#sha1s], 1); '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c',
my $ctime = $ci->{'author_epoch'}; '-r', '--', $file);
my $first = parse_diff_tree("", \@raw_lines);
my $ctime = $first->{'author_epoch'};
debug("ctime for '$file': ". localtime($ctime)); debug("ctime for '$file': ". localtime($ctime));
return $ctime; return $ctime;

2
debian/changelog vendored
View File

@ -2,6 +2,8 @@ ikiwiki (3.20091010) UNRELEASED; urgency=low
* ikiwiki-calendar: New command automates creation of archive pages * ikiwiki-calendar: New command automates creation of archive pages
using the calendar plugin. using the calendar plugin.
* git: --getctime will now follow renames back to the original creation
of a file.
-- Joey Hess <joeyh@debian.org> Sun, 11 Oct 2009 15:54:45 -0400 -- Joey Hess <joeyh@debian.org> Sun, 11 Oct 2009 15:54:45 -0400