Use shorter error messages for whitespace problems
[git/git-p4.git] / t / t5505-remote.sh
blob636aec2f7139cad63591d64e8c89e82d2ed4760b
1 #!/bin/sh
3 test_description='git remote porcelain-ish'
5 . ./test-lib.sh
7 GIT_CONFIG=.git/config
8 export GIT_CONFIG
10 setup_repository () {
11 mkdir "$1" && (
12 cd "$1" &&
13 git init &&
14 >file &&
15 git add file &&
16 git commit -m "Initial" &&
17 git checkout -b side &&
18 >elif &&
19 git add elif &&
20 git commit -m "Second" &&
21 git checkout master
25 tokens_match () {
26 echo "$1" | tr ' ' '\012' | sort | sed -e '/^$/d' >expect &&
27 echo "$2" | tr ' ' '\012' | sort | sed -e '/^$/d' >actual &&
28 diff -u expect actual
31 check_remote_track () {
32 actual=$(git remote show "$1" | sed -n -e '$p') &&
33 shift &&
34 tokens_match "$*" "$actual"
37 check_tracking_branch () {
38 f="" &&
39 r=$(git for-each-ref "--format=%(refname)" |
40 sed -ne "s|^refs/remotes/$1/||p") &&
41 shift &&
42 tokens_match "$*" "$r"
45 test_expect_success setup '
47 setup_repository one &&
48 setup_repository two &&
50 cd two && git branch another
51 ) &&
52 git clone one test
56 test_expect_success 'remote information for the origin' '
58 cd test &&
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' '
67 cd test &&
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 &&
76 >expect &&
77 diff -u expect actual
81 test_expect_success 'remove remote' '
83 cd test &&
84 git remote rm second
88 test_expect_success 'remove remote' '
90 cd test &&
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 &&
95 >expect &&
96 diff -u expect actual
100 test_done