aboutsummaryrefslogtreecommitdiffstats
path: root/Perl
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2018-05-31 13:31:03 +0100
committerSteve McIntyre <steve@einval.com>2018-05-31 13:31:03 +0100
commit14588f2ce29dea28b8d377a630226896a1f72d65 (patch)
tree2bd05bf2b1399293957070923c0b173ffd222a4a /Perl
parenta407693728c2768293bcf671ec9b9a026dd8db6c (diff)
Deal with working in subdirectories when using file_info
Make sure that when we add things to the cache (and look them up) we're working in the right directory
Diffstat (limited to 'Perl')
-rw-r--r--Perl/Local/VCS_git.pm15
1 files changed, 12 insertions, 3 deletions
diff --git a/Perl/Local/VCS_git.pm b/Perl/Local/VCS_git.pm
index d8ef385555f..73cff4c53eb 100644
--- a/Perl/Local/VCS_git.pm
+++ b/Perl/Local/VCS_git.pm
@@ -126,11 +126,17 @@ sub cache_file {
_debug "cache_file($file)";
if ($self->{CACHE}{"$file"}) {
-# print "$file is already cached...\n";
+ _debug "$file is already cached...";
_debug "cache_file($file) returning early";
return;
}
-# print "Adding $file to cache\n";
+ _debug "Adding $file to cache\n";
+
+ # Store the current directory so we can return there
+ my $start_dir = cwd;
+ my $topdir = $self->get_topdir();
+ chdir ($topdir) or die "Can't chdir to $topdir: $!\n";
+
my (@commits);
open (GITLOG, "git log -p -m --first-parent --name-only --numstat --format=format:\"%H %ct\" -- $file |") or die "Can't fork git log: $!\n";
my ($cmt_date, $cmt_rev);
@@ -146,6 +152,7 @@ sub cache_file {
}
close GITLOG;
_debug "cache_file($file) done";
+ chdir ($start_dir);
return;
}
@@ -168,7 +175,7 @@ sub cache_repo {
# Store the current directory so we can return there
my $start_dir = cwd;
my $topdir = $self->get_topdir();
- chdir ($topdir) or die "Can't chdir to $topdir: $!\n";
+ chdir ($topdir) or die "Can't chdir to $topdir: $!\n";
my (@commits);
my $count = 0;
@@ -518,6 +525,8 @@ sub file_info
my %options = @_;
my $quiet = $options{quiet} || undef;
my %pathinfo;
+ $file =~ s,^(../)*,,g;
+ _debug "Looking for details of file $file";
my @commits = $self->_grab_commits($file);
if (@commits) {
# Grab the data we want from the first entry in the

© 2014-2024 Faster IT GmbH | imprint | privacy policy