Skip to content

Commit d12f455

Browse files
pyokagangitster
authored andcommitted
t5520: test no merge candidates cases
a8c9bef (pull: improve advice for unconfigured error case, 2009-10-05) fully established the current advices given by git-pull for the different cases where git-fetch will not have anything marked for merge: 1. We fetched from a specific remote, and a refspec was given, but it ended up not fetching anything. This is usually because the user provided a wildcard refspec which had no matches on the remote end. 2. We fetched from a non-default remote, but didn't specify a branch to merge. We can't use the configured one because it applies to the default remote, and thus the user must specify the branches to merge. 3. We fetched from the branch's or repo's default remote, but: a. We are not on a branch, so there will never be a configured branch to merge with. b. We are on a branch, but there is no configured branch to merge with. 4. We fetched from the branch's or repo's default remote, but the configured branch to merge didn't get fetched (either it doesn't exist, or wasn't part of the configured fetch refspec) Implement tests for the above 5 cases to ensure that the correct code paths are triggered for each of these cases. Signed-off-by: Paul Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c998b38 commit d12f455

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

t/t5520-pull.sh

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,61 @@ test_expect_success 'the default remote . should not break explicit pull' '
109109
test "$(cat file)" = modified
110110
'
111111

112+
test_expect_success 'fail if wildcard spec does not match any refs' '
113+
git checkout -b test copy^ &&
114+
test_when_finished "git checkout -f copy && git branch -D test" &&
115+
test "$(cat file)" = file &&
116+
test_must_fail git pull . "refs/nonexisting1/*:refs/nonexisting2/*" 2>err &&
117+
test_i18ngrep "no candidates for merging" err &&
118+
test "$(cat file)" = file
119+
'
120+
121+
test_expect_success 'fail if no branches specified with non-default remote' '
122+
git remote add test_remote . &&
123+
test_when_finished "git remote remove test_remote" &&
124+
git checkout -b test copy^ &&
125+
test_when_finished "git checkout -f copy && git branch -D test" &&
126+
test "$(cat file)" = file &&
127+
test_config branch.test.remote origin &&
128+
test_must_fail git pull test_remote 2>err &&
129+
test_i18ngrep "specify a branch on the command line" err &&
130+
test "$(cat file)" = file
131+
'
132+
133+
test_expect_success 'fail if not on a branch' '
134+
git remote add origin . &&
135+
test_when_finished "git remote remove origin" &&
136+
git checkout HEAD^ &&
137+
test_when_finished "git checkout -f copy" &&
138+
test "$(cat file)" = file &&
139+
test_must_fail git pull 2>err &&
140+
test_i18ngrep "not currently on a branch" err &&
141+
test "$(cat file)" = file
142+
'
143+
144+
test_expect_success 'fail if no configuration for current branch' '
145+
git remote add test_remote . &&
146+
test_when_finished "git remote remove test_remote" &&
147+
git checkout -b test copy^ &&
148+
test_when_finished "git checkout -f copy && git branch -D test" &&
149+
test_config branch.test.remote test_remote &&
150+
test "$(cat file)" = file &&
151+
test_must_fail git pull 2>err &&
152+
test_i18ngrep "no tracking information" err &&
153+
test "$(cat file)" = file
154+
'
155+
156+
test_expect_success 'fail if upstream branch does not exist' '
157+
git checkout -b test copy^ &&
158+
test_when_finished "git checkout -f copy && git branch -D test" &&
159+
test_config branch.test.remote . &&
160+
test_config branch.test.merge refs/heads/nonexisting &&
161+
test "$(cat file)" = file &&
162+
test_must_fail git pull 2>err &&
163+
test_i18ngrep "no such ref was fetched" err &&
164+
test "$(cat file)" = file
165+
'
166+
112167
test_expect_success '--rebase' '
113168
git branch to-rebase &&
114169
echo modified again > file &&

0 commit comments

Comments
 (0)