diff options
author | Steve McIntyre <steve@einval.com> | 2023-09-28 22:59:38 +0100 |
---|---|---|
committer | Steve McIntyre <steve@einval.com> | 2023-09-28 22:59:38 +0100 |
commit | 424e33a9782ff3a31f4c1c2aadbd427c995204ed (patch) | |
tree | 23d97ec5f4762d3b8674094b69fb0096862bfeab /Perl | |
parent | b1ab0700ee535809875d557458de06536c7ac699 (diff) |
For git rev strings in the API, trim leading and trailing whitespace
Diffstat (limited to 'Perl')
-rw-r--r-- | Perl/Local/VCS_git.pm | 19 |
1 files changed, 19 insertions, 0 deletions
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 |