git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Jarnbo Pedersen <lars.jarnbo.pedersen@gmail.com>
To: git <git@vger.kernel.org>
Cc: gitster@pobox.com
Subject: [PATCH] request-pull: return the entered branch if more branches are at the same commit
Date: Thu, 08 Apr 2010 00:22:36 +0200	[thread overview]
Message-ID: <1270678956.27317.34.camel@neo> (raw)

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@gmail.com>
---
 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

             reply	other threads:[~2010-04-07 22:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-07 22:22 Lars Jarnbo Pedersen [this message]
2010-04-08  1:45 ` [PATCH] request-pull: return the entered branch if more branches are at the same commit Junio C Hamano
2010-04-08 20:37   ` Lars Jarnbo Pedersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270678956.27317.34.camel@neo \
    --to=lars.jarnbo.pedersen@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).