From 424e33a9782ff3a31f4c1c2aadbd427c995204ed Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Thu, 28 Sep 2023 22:59:38 +0100 Subject: For git rev strings in the API, trim leading and trailing whitespace --- Perl/Local/VCS_git.pm | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'Perl') diff --git a/Perl/Local/VCS_git.pm b/Perl/Local/VCS_git.pm index 7f67d9f17e4..62015bcea19 100644 --- a/Perl/Local/VCS_git.pm +++ b/Perl/Local/VCS_git.pm @@ -427,6 +427,10 @@ sub cmp_rev my $rev2 = shift or return undef; my $ret = undef; + # remove both leading and trailing whitespace, in case + $rev1 =~ s/^\s+|\s+$//g; + $rev2 =~ s/^\s+|\s+$//g; + # Work out where we need to be. This can be quite hairy if the # user has given us a mix of relative and absolute paths from # their program. Do this cleanly, somehow...! @@ -513,6 +517,10 @@ sub count_changes my $rev2 = shift || ''; my $ret = 0; + # remove both leading and trailing whitespace, in case + $rev1 =~ s/^\s+|\s+$//g; + $rev2 =~ s/^\s+|\s+$//g; + if ($rev1 =~ m/^\Q$rev2\E$/) { # same revisions return 0; } @@ -818,6 +826,10 @@ sub get_log my @logdata; my $command; + # remove both leading and trailing whitespace, in case + $rev1 =~ s/^\s+|\s+$//g; + $rev2 =~ s/^\s+|\s+$//g; + # Work out where we need to be. This can be quite hairy if the # user has given us a mix of relative and absolute paths from # their program. Do this cleanly, somehow...! @@ -938,6 +950,10 @@ sub get_diff my $rev1 = shift; my $rev2 = shift; + # remove both leading and trailing whitespace, in case + $rev1 =~ s/^\s+|\s+$//g; + $rev2 =~ s/^\s+|\s+$//g; + # hash to store the output my %data; @@ -1205,6 +1221,9 @@ sub next_revision my $move = shift or return undef; my $ret = undef; + # remove both leading and trailing whitespace, in case + $rev1 =~ s/^\s+|\s+$//g; + croak( "No such file: $file" ) unless -f $file; # Work out where we need to be. This can be quite hairy if the -- cgit v1.2.3