3 test_description
='git remote porcelain-ish'
14 git commit
-m "Initial" &&
15 git checkout
-b side
&&
19 git commit
-m "Second" &&
25 echo "$1" |
tr ' ' '\012' |
sort |
sed -e '/^$/d' >expect
&&
26 echo "$2" |
tr ' ' '\012' |
sort |
sed -e '/^$/d' >actual
&&
27 test_cmp expect actual
30 check_remote_track
() {
31 actual
=$
(git remote show
"$1" |
sed -n -e '$p') &&
33 tokens_match
"$*" "$actual"
36 check_tracking_branch
() {
38 r
=$
(git for-each-ref
"--format=%(refname)" |
39 sed -ne "s|^refs/remotes/$1/||p") &&
41 tokens_match
"$*" "$r"
44 test_expect_success setup
'
46 setup_repository one &&
47 setup_repository two &&
49 cd two && git branch another
55 test_expect_success
'remote information for the origin' '
58 tokens_match origin "$(git remote)" &&
59 check_remote_track origin master side &&
60 check_tracking_branch origin HEAD master side
64 test_expect_success
'add another remote' '
67 git remote add -f second ../two &&
68 tokens_match "origin second" "$(git remote)" &&
69 check_remote_track origin master side &&
70 check_remote_track second master side another &&
71 check_tracking_branch second master side another &&
72 git for-each-ref "--format=%(refname)" refs/remotes |
73 sed -e "/^refs\/remotes\/origin\//d" \
74 -e "/^refs\/remotes\/second\//d" >actual &&
76 test_cmp expect actual
80 test_expect_success
'remove remote' '
83 git symbolic-ref refs/remotes/second/HEAD refs/remotes/second/master &&
88 test_expect_success
'remove remote' '
91 tokens_match origin "$(git remote)" &&
92 check_remote_track origin master side &&
93 git for-each-ref "--format=%(refname)" refs/remotes |
94 sed -e "/^refs\/remotes\/origin\//d" >actual &&
96 test_cmp expect actual
100 cat > test
/expect
<< EOF
103 Remote branch merged with 'git pull' while on branch master
105 New remote branch (next fetch will store in remotes/origin)
107 Tracked remote branches
109 Local branches pushed with 'git push'
110 master:upstream +refs/tags/lastbackup
113 test_expect_success
'show' '
115 git config --add remote.origin.fetch \
116 refs/heads/master:refs/heads/upstream &&
118 git branch -d -r origin/master &&
122 git commit -m update file) &&
123 git config remote.origin.push \
124 refs/heads/master:refs/heads/upstream &&
125 git config --add remote.origin.push \
126 +refs/tags/lastbackup &&
127 git remote show origin > output &&
128 git diff expect output)
131 test_expect_success
'prune' '
133 git branch -m side side2) &&
136 git remote prune origin &&
137 git rev-parse refs/remotes/origin/side2 &&
138 ! git rev-parse refs/remotes/origin/side)
141 test_expect_success
'add --mirror && prune' '
145 git remote add --mirror -f origin ../one) &&
147 git branch -m side2 side) &&
149 git rev-parse --verify refs/heads/side2 &&
150 ! git rev-parse --verify refs/heads/side &&
152 git remote prune origin &&
153 ! git rev-parse --verify refs/heads/side2 &&
154 git rev-parse --verify refs/heads/side)
157 cat > one
/expect
<< EOF
165 test_expect_success
'update' '
168 git remote add drosophila ../two &&
169 git remote add apis ../mirror &&
171 git branch -r > output &&
172 git diff expect output)
176 cat > one
/expect
<< EOF
186 test_expect_success
'update with arguments' '
189 for b in $(git branch -r)
191 git branch -r -d $b || break
193 git remote add manduca ../mirror &&
194 git remote add megaloprepus ../mirror &&
195 git config remotes.phobaeticus "drosophila megaloprepus" &&
196 git config remotes.titanus manduca &&
197 git remote update phobaeticus titanus &&
198 git branch -r > output &&
199 git diff expect output)
203 cat > one
/expect
<< EOF
212 test_expect_success
'update default' '
215 for b in $(git branch -r)
217 git branch -r -d $b || break
219 git config remote.drosophila.skipDefaultUpdate true &&
220 git remote update default &&
221 git branch -r > output &&
222 git diff expect output)
226 cat > one
/expect
<< EOF
232 test_expect_success
'update default (overridden, with funny whitespace)' '
235 for b in $(git branch -r)
237 git branch -r -d $b || break
239 git config remotes.default "$(printf "\t drosophila \n")" &&
240 git remote update default &&
241 git branch -r > output &&
242 git diff expect output)
246 test_expect_success
'"remote show" does not show symbolic refs' '
248 git clone one three &&
250 git remote show origin > output &&
251 ! grep HEAD < output &&
252 ! grep -i stale < output)
256 test_expect_success
'reject adding remote with an invalid name' '
258 ! git remote add some:url desired-name