[PATCH v2 04/44] request-pull: fix for specific branch

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

 



Wether we use a symbolic ref, or we specify the branch directly
shouldn't really matter, we would want the branch description either
way.

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

diff --git a/git-request-pull.sh b/git-request-pull.sh
index 6348dac..3c9a982 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -37,15 +37,12 @@ done
 
 base=$1 url=$2 head=${3-HEAD} status=0 branch_name=
 
-headref=$(git symbolic-ref -q "$head")
-if git show-ref -q --verify "$headref"
+headref=$(git rev-parse -q --verify --symbolic-full-name "$head")
+branch_name=${headref#refs/heads/}
+if test "z$branch_name" = "z$headref" ||
+	! git config "branch.$branch_name.description" >/dev/null
 then
-	branch_name=${headref#refs/heads/}
-	if test "z$branch_name" = "z$headref" ||
-		! git config "branch.$branch_name.description" >/dev/null
-	then
-		branch_name=
-	fi
+	branch_name=
 fi
 
 tag_name=$(git describe --exact "$head^0" 2>/dev/null)
diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh
index 54f41bf..a9ee96a 100755
--- a/t/t5150-request-pull.sh
+++ b/t/t5150-request-pull.sh
@@ -249,4 +249,36 @@ test_expect_success 'pull request when pushed tag' '
 	! grep "You locally have .* but it does not (yet)" err
 '
 
+test_expect_success 'pull request with branch description' '
+	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 config branch.for-upstream.description "Branch for upstream$LF" &&
+		git push origin for-upstream &&
+		git request-pull initial origin >../request
+	) &&
+	cat request &&
+	grep "(from the branch description for for-upstream local branch)" request &&
+	grep "Branch for upstream" request
+'
+
+test_expect_success 'pull request with branch description from rev' '
+	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 config branch.for-upstream.description "Branch for upstream$LF" &&
+		git push origin for-upstream &&
+		git request-pull initial origin for-upstream >../request
+	) &&
+	cat request &&
+	grep "(from the branch description for for-upstream local branch)" request &&
+	grep "Branch for upstream" request
+'
+
 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]