# Otherwise find a random ref that matches $headrev.
find_matching_ref='
my ($head,$headrev) = (@ARGV);
+ my $pattern = qr{/\Q$head\E$};
my ($found);
while (<STDIN>) {
chomp;
my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
- my ($pattern);
next unless ($sha1 eq $headrev);
- $pattern="/$head\$";
if ($ref eq $head) {
$found = $ref;
}
- if ($ref =~ /$pattern/) {
+ if ($ref =~ $pattern) {
$found = $ref;
}
if ($sha1 eq $head) {
'
+test_expect_success 'request-pull quotes regex metacharacters properly' '
+
+ rm -fr downstream.git &&
+ git init --bare downstream.git &&
+ (
+ cd local &&
+ git checkout initial &&
+ git merge --ff-only master &&
+ git tag -mrelease v2.0 &&
+ git push origin refs/tags/v2.0:refs/tags/v2-0 &&
+ test_must_fail git request-pull initial "$downstream_url" tags/v2.0 \
+ 2>../err
+ ) &&
+ grep "No match for commit .*" err &&
+ grep "Are you sure you pushed" err
+
+'
+
test_done