diff options
author | Eric Wong <e@80x24.org> | 2023-10-27 22:21:11 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-10-28 09:08:16 +0000 |
commit | 9de1ad677fbb89bf1babd08e9df4969f0ad77983 (patch) | |
tree | d2450b1922b30b48b4ad6e6e877a032eb2a739ff /lib | |
parent | e57a3412a379ff57ba7d5cfaf609ffeec6e04f71 (diff) | |
download | public-inbox-9de1ad677fbb89bf1babd08e9df4969f0ad77983.tar.gz |
No sane installer will update executable files in place due to ETXTBSY on execve. So save ourselves a stat(2) call by relying on the special `CORE::stat(_)' case to reuse the cached result from the `-x FILE' filetest in which().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Git.pm | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index b5adc1f4..a1d52118 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -17,7 +17,6 @@ use PublicInbox::Syscall qw(EPOLLIN EPOLLET); use Errno qw(EINTR EAGAIN); use File::Glob qw(bsd_glob GLOB_NOSORT); use File::Spec (); -use Time::HiRes qw(stat); use PublicInbox::Spawn qw(spawn popen_rd run_qx which); use PublicInbox::ProcessIONBF; use PublicInbox::Tmpfile; @@ -53,13 +52,13 @@ my %GIT_ESC = ( ); my %ESC_GIT = map { $GIT_ESC{$_} => $_ } keys %GIT_ESC; -my $EXE_ST = ''; # pack('dd', st_ctime, st_size); +my $EXE_ST = ''; # pack('dd', st_dev, st_ino); # no `q' in some 32-bit builds my ($GIT_EXE, $GIT_VER); sub check_git_exe () { $GIT_EXE = which('git') // die "git not found in $ENV{PATH}"; - my @st = stat($GIT_EXE) or die "stat($GIT_EXE): $!"; - my $st = pack('dd', $st[10], $st[7]); + my @st = stat(_) or die "stat($GIT_EXE): $!"; # can't do HiRes w/ _ + my $st = pack('dd', $st[0], $st[1]); if ($st ne $EXE_ST) { my $v = run_qx([ $GIT_EXE, '--version' ]); die "$GIT_EXE --version: \$?=$?" if $?; @@ -117,6 +116,7 @@ sub git_path ($$) { sub alternates_changed { my ($self) = @_; my $alt = git_path($self, 'objects/info/alternates'); + use Time::HiRes qw(stat); my @st = stat($alt) or return 0; # can't rely on 'q' on some 32-bit builds, but `d' works |