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

[RFC/PATCH 2/2] get_remote_merge_branch: Support for arbitrary mapping

From
SBSanti Béjar <santi@agolina.net>
Date
Jun 18, 2009, 07:57 UTC
Message-ID
<1245311834-5290-4-git-send-email-santi@agolina.net>
In-Reply-To
<1245311834-5290-1-git-send-email-santi@agolina.net>
This function is used in "git pull --rebase" to know the tracking branch.
Signed-off-by: Santi Béjar <santi@agolina.net>
---
 git-parse-remote.sh |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5f47b18..1aa6ffe 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -74,8 +74,6 @@ get_remote_merge_branch () {
 	    repo=$1
 	    shift
 	    ref=$1
-	    # FIXME: It should return the tracking branch
-	    #        Currently only works with the default mapping
 	    case "$ref" in
 	    +*)
 		ref=$(expr "z$ref" : 'z+\(.*\)')
@@ -83,13 +81,18 @@ get_remote_merge_branch () {
 	    esac
 	    expr "z$ref" : 'z.*:' >/dev/null || ref="${ref}:"
 	    remote=$(expr "z$ref" : 'z\([^:]*\):')
-	    case "$remote" in
-	    '' | HEAD ) remote=HEAD ;;
-	    heads/*) remote=${remote#heads/} ;;
-	    refs/heads/*) remote=${remote#refs/heads/} ;;
-	    refs/* | tags/* | remotes/* ) remote=
-	    esac
+	    while true ; do
+		case "$remote" in
+		'' | HEAD ) remote=;;
+		heads/*) remote=refs/$remote;;
+		refs/heads/*) ;;
+		refs/* | tags/* | remotes/* ) remote=;;
+		*) remote=heads/$remote
+		esac
 
-	    [ -n "$remote" ] && echo "refs/remotes/$repo/$remote"
+		[ -n "$remote" ] &&
+		git remote tracking $repo $remote && break
+		case "$remote" in refs/heads/* | "" ) break ; esac
+	    done
 	esac
 }
-- 
1.6.3.2.406.gd6a466
Previous: Santi BéjarNext: Santi Béjar
Message 15 of 19 in “Support for arbitrary mapping for "git pull --rebase"”
  1. 0/2 Support for arbitrary mapping for "git pull --rebase"Santi Béjar, Jun 18, 2009
  2. 1/2 remote tracking: return the tracking branch for the given branchesSanti Béjar, Jun 18, 2009
  3. Paolo BonziniJun 18, 2009
  4. Santi BéjarJun 18, 2009
  5. Johannes SchindelinJun 18, 2009
  6. Santi BéjarJun 18, 2009
  7. Jakub NarebskiJun 18, 2009
  8. Santi BéjarJun 18, 2009
  9. Jakub NarebskiJun 18, 2009
  10. Santi BéjarJun 18, 2009
  11. Santi BéjarJun 18, 2009
  12. Junio C HamanoJun 18, 2009
  13. Santi BéjarJun 18, 2009
  14. Santi BéjarJun 18, 2009
  15. 2/2 get_remote_merge_branch: Support for arbitrary mappingSanti Béjar, Jun 18, 2009
  16. Santi BéjarJun 18, 2009
  17. Johannes SchindelinJun 18, 2009
  18. Santi BéjarJun 18, 2009
  19. Santi BéjarJun 19, 2009

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.