3 test_description='git remote porcelain-ish'
16 git commit -m "Initial" &&
17 git checkout -b side &&
20 git commit -m "Second" &&
26 echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect &&
27 echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual &&
31 check_remote_track () {
32 actual=$(git remote show "$1" | sed -n -e '$p') &&
34 tokens_match "$*" "$actual"
37 check_tracking_branch () {
39 r=$(git for-each-ref "--format=%(refname)" |
40 sed -ne "s|^refs/remotes/$1/||p") &&
42 tokens_match "$*" "$r"
45 test_expect_success setup '
47 setup_repository one &&
48 setup_repository two &&
50 cd two && git branch another
56 test_expect_success 'remote information for the origin' '
59 tokens_match origin "$(git remote)" &&
60 check_remote_track origin master side &&
61 check_tracking_branch origin HEAD master side
65 test_expect_success 'add another remote' '
68 git remote add -f second ../two &&
69 tokens_match "origin second" "$(git remote)" &&
70 check_remote_track origin master side &&
71 check_remote_track second master side another &&
72 check_tracking_branch second master side another &&
73 git for-each-ref "--format=%(refname)" refs/remotes |
74 sed -e "/^refs\/remotes\/origin\//d" \
75 -e "/^refs\/remotes\/second\//d" >actual &&
81 test_expect_success 'remove remote' '
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 &&