[PATCH] request-pull: return the entered branch if more branches are at the same commit

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

 



Currently request-pull identifies the branch to pull from by finding the commit
using rev-parse and then identifying the branch from the commit using ls-remote.
If more branches are pointing to the same commit the first will be chosen even
if the one we entered in the command-line exist.

This change returns the same branch as entered at the commandline if it exists in refs/heads.

Signed-off-by: Lars Jarnbo Pedersen <lars.jarnbo.pedersen@xxxxxxxxx>
---
 git-request-pull.sh |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/git-request-pull.sh b/git-request-pull.sh
index 8fd15f6..787383f 100755
--- a/git-request-pull.sh
+++ b/git-request-pull.sh
@@ -49,11 +49,21 @@ merge_base=`git merge-base $baserev $headrev` ||
 die "fatal: No commits in common between $base and $head"
 
 branch=$(git ls-remote "$url" \
+	| sed -n -e "/^$headrev	refs.heads.$head/{
+		s/^.*	refs.heads.//
+		p
+		q
+	}")
+
+if [ -z "$branch" ]; then
+    branch=$(git ls-remote "$url" \
 	| sed -n -e "/^$headrev	refs.heads./{
 		s/^.*	refs.heads.//
 		p
 		q
 	}")
+fi
+
 url=$(get_remote_url "$url")
 if [ -z "$branch" ]; then
 	echo "warn: No branch of $url is at:" >&2
-- 
1.7.1.rc0.1.ga751b


--
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]