git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Lars Jarnbo Pedersen <lars.jarnbo.pedersen@gmail.com>
Date
Apr 7, 2010, 22:22 UTC
Message-ID
<1270678956.27317.34.camel@neo>

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
Next: Junio C Hamano
Message 1 of 3 in “request-pull: return the entered branch if more branches are at the same commit”
  1. request-pull: return the entered branch if more branches are at the same commitLars Jarnbo Pedersen, Apr 7, 2010
  2. Junio C HamanoApr 8, 2010
  3. Lars Jarnbo PedersenApr 8, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.