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