[PATCH v2 06/44] request-pull: fix exact match checking

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It obviously never worked, refs don't start with '/'.

Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
 git-request-pull.sh     | 10 ++++++++--
 t/t5150-request-pull.sh | 21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/git-request-pull.sh b/git-request-pull.sh
index 3e510ca..c970244 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -38,6 +38,11 @@ done
 base=$1 url=$2 head=${3-HEAD} status=0 branch_name=
 
 headref=$(git rev-parse -q --verify --symbolic-full-name "$head")
+if test "$headref" = "HEAD"
+then
+	headref=
+fi
+
 branch_name=${headref#refs/heads/}
 if test "z$branch_name" = "z$headref" ||
 	! git config "branch.$branch_name.description" >/dev/null
@@ -90,8 +95,9 @@ find_matching_ref='
 			$tagged = $found;
 			last;
 		}
-		if ($ref =~ m|/\Q$ARGV[0]\E$|) {
+		if ($ref eq $ARGV[0]) {
 			$exact = $found;
+			last;
 		}
 	}
 	if ($tagged) {
@@ -103,7 +109,7 @@ find_matching_ref='
 	}
 '
 
-ref=$(git ls-remote "$url" | perl -e "$find_matching_ref" "$head" "$headrev" "$tag_name")
+ref=$(git ls-remote "$url" | perl -e "$find_matching_ref" "$headref" "$headrev" "$tag_name")
 
 url=$(git ls-remote --get-url "$url")
 
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index a9ee96a..73f0369 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -281,4 +281,25 @@ test_expect_success 'pull request with branch description from rev' '
 	grep "Branch for upstream" request
 '
 
+test_expect_success 'pull request with exact match' '
+	test_when_finished "(cd local && git checkout - && git branch -D for-upstream)" &&
+	rm -fr downstream.git &&
+	git init --bare downstream.git &&
+	(
+		cd local &&
+		git checkout -b for-upstream master &&
+		git push origin master:for-upstream master:zeebra &&
+		git request-pull initial origin for-upstream >../request
+	) &&
+	cat request &&
+	sed -nf read-request.sed <request >digest &&
+	cat digest &&
+	{
+		read task &&
+		read repository &&
+		read branch
+	} <digest &&
+	test "$branch" = for-upstream
+'
+
 test_done
-- 
1.8.4-fc

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]