@matheusbsbs / matheus-bagliano / commits / 687b8be8bb
Fork 0

fetch,parse-remote,fmt-merge-msg: refs/remotes/* support

We can now easily fetch and merge things from heads in the refs/remotes/ hierarchy in remote repositories. The refs/remotes/ hierarchy is likely to become the standard for tracking foreign SCMs, as well as the location of Pull: targets for tracking remote branches in newly cloned repositories. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Mar 10, 2006 at 04:19 UTC 687b8be8bb75b97e917dc744f91890270913041d
3 files changed +20 -6
git-fetch.sh
+8 -2
@@ -94,6 +94,9 @@ append_fetch_head () {
94 # remote-nick is the URL given on the command line (or a shorthand)
95 # remote-name is the $GIT_DIR relative refs/ path we computed
96 # for this refspec.
97 +
98 + # the $note_ variable will be fed to git-fmt-merge-msg for further
99 + # processing.
100 case "$remote_name_" in
101 HEAD)
102 note_= ;;
@@ -103,6 +106,9 @@ append_fetch_head () {
106 refs/tags/*)
107 note_="$(expr "$remote_name_" : 'refs/tags/\(.*\)')"
108 note_="tag '$note_' of " ;;
109 + refs/remotes/*)
110 + note_="$(expr "$remote_name_" : 'refs/remotes/\(.*\)')"
111 + note_="remote branch '$note_' of " ;;
112 *)
113 note_="$remote_name of " ;;
114 esac
@@ -147,10 +153,10 @@ fast_forward_local () {
153 else
154 echo >&2 "* $1: storing $3"
155 fi
150 - git-update-ref "$1" "$2"
156 + git-update-ref "$1" "$2"
157 ;;
158
153 - refs/heads/*)
159 + refs/heads/* | refs/remotes/*)
160 # $1 is the ref being updated.
161 # $2 is the new value for the ref.
162 local=$(git-rev-parse --verify "$1^0" 2>/dev/null)
git-fmt-merge-msg.perl
+8
@@ -75,6 +75,7 @@ while (<>) {
75 $src{$src} = {
76 BRANCH => [],
77 TAG => [],
78 + R_BRANCH => [],
79 GENERIC => [],
80 # &1 == has HEAD.
81 # &2 == has others.
@@ -91,6 +92,11 @@ while (<>) {
92 push @{$src{$src}{TAG}}, $1;
93 $src{$src}{HEAD_STATUS} |= 2;
94 }
95 + elsif (/^remote branch (.*)$/) {
96 + $origin = $1;
97 + push @{$src{$src}{R_BRANCH}}, $1;
98 + $src{$src}{HEAD_STATUS} |= 2;
99 + }
100 elsif (/^HEAD$/) {
101 $origin = $src;
102 $src{$src}{HEAD_STATUS} |= 1;
@@ -123,6 +129,8 @@ for my $src (@src) {
129 }
130 push @this, andjoin("branch ", "branches ",
131 $src{$src}{BRANCH});
132 + push @this, andjoin("remote branch ", "remote branches ",
133 + $src{$src}{R_BRANCH});
134 push @this, andjoin("tag ", "tags ",
135 $src{$src}{TAG});
136 push @this, andjoin("commit ", "commits ",
git-parse-remote.sh
+4 -4
@@ -86,14 +86,14 @@ canon_refs_list_for_fetch () {
86 local=$(expr "$ref" : '[^:]*:\(.*\)')
87 case "$remote" in
88 '') remote=HEAD ;;
89 - refs/heads/* | refs/tags/*) ;;
90 - heads/* | tags/* ) remote="refs/$remote" ;;
89 + refs/heads/* | refs/tags/* | refs/remotes/*) ;;
90 + heads/* | tags/* | remotes/* ) remote="refs/$remote" ;;
91 *) remote="refs/heads/$remote" ;;
92 esac
93 case "$local" in
94 '') local= ;;
95 - refs/heads/* | refs/tags/*) ;;
96 - heads/* | tags/* ) local="refs/$local" ;;
95 + refs/heads/* | refs/tags/* | refs/remotes/*) ;;
96 + heads/* | tags/* | remotes/* ) local="refs/$local" ;;
97 *) local="refs/heads/$local" ;;
98 esac
99