scripts: replace/extend -- with --end-of-options in git commands

It makes these scripts require Git 2.24.0+ (2019-11-04).

Refs:
https://git-scm.com/docs/gitcli
https://nesbitt.io/2026/07/21/end-of-options.html
19e8789b23

Closes #22369
This commit is contained in:
Viktor Szakats 2026-07-22 12:22:18 +02:00
parent 6bff85be68
commit 41b4a91123
No known key found for this signature in database
6 changed files with 8 additions and 8 deletions

View file

@ -122,7 +122,7 @@ sub process {
}
my @filemasks = @ARGV;
open(my $git_ls_files, '-|', 'git', 'ls-files', '--', @filemasks) or die "Failed running git ls-files: $!";
open(my $git_ls_files, '-|', 'git', 'ls-files', '--end-of-options', @filemasks) or die "Failed running git ls-files: $!";
while(my $f = <$git_ls_files>) {
chomp $f;
process($f);

View file

@ -318,7 +318,7 @@ sub file {
}
my @filemasks = @ARGV;
open(my $git_ls_files, '-|', 'git', 'ls-files', '--', ":!:$file", @filemasks) or die "Failed running git ls-files: $!";
open(my $git_ls_files, '-|', 'git', 'ls-files', '--end-of-options', ":!:$file", @filemasks) or die "Failed running git ls-files: $!";
my @files;
while(my $each = <$git_ls_files>) {
chomp $each;

View file

@ -1236,12 +1236,12 @@ sub scanfile {
@copyright = sort {$$b{year} cmp $$a{year}} @copyright;
# if the file is modified, assume commit year this year
if(qx(git status -s -- "$file") =~ /^ [MARCU]/) {
if(qx(git status -s --end-of-options "$file") =~ /^ [MARCU]/) {
$commityear = (localtime(time))[5] + 1900;
}
else {
# min-parents=1 to ignore wrong initial commit in truncated repos
my $grl = qx(git rev-list --max-count=1 --min-parents=1 --timestamp HEAD -- "$file");
my $grl = qx(git rev-list --max-count=1 --min-parents=1 --timestamp --end-of-options HEAD -- "$file");
if($grl) {
chomp $grl;
$commityear = (localtime((split(/ /, $grl))[0]))[5] + 1900;

View file

@ -131,8 +131,8 @@ my $total = $now - Time::Piece->strptime('19980320', '%Y%m%d')->epoch;
my $totalhttpget = $now - Time::Piece->strptime('19961111', '%Y%m%d')->epoch;
# Number of public functions in libcurl
my $apublic = cmd('git', 'grep', '^CURL_EXTERN', '--', 'include/curl');
my $bpublic = cmd('git', 'grep', '^CURL_EXTERN', $start, '--', 'include/curl');
my $apublic = cmd('git', 'grep', '--end-of-options', '^CURL_EXTERN', '--', 'include/curl');
my $bpublic = cmd('git', 'grep', '--end-of-options', '^CURL_EXTERN', $start, '--', 'include/curl');
my $public = $apublic - $bpublic;
# diffstat

View file

@ -167,7 +167,7 @@ my %api = (
sub doublecheck {
my ($f, $used) = @_;
open(F, '-|', 'git', 'grep', '-Fwle', $f, '--', 'lib', @unittests, 'projects');
open(F, '-|', 'git', 'grep', '-Fwl', '--end-of-options', $f, '--', 'lib', @unittests, 'projects');
my @also;
while(<F>) {
my $e = $_;

View file

@ -29,7 +29,7 @@ use warnings;
my $root = $ARGV[0] || "..";
my @m;
if(open(O, '-|', 'git', 'ls-files', '--', $root)) {
if(open(O, '-|', 'git', 'ls-files', '--end-of-options', $root)) {
push @m, <O>;
close(O);
}