Skip to content

Commit 042cca3

Browse files
drafnelgitster
authored andcommitted
t/t5510-fetch.sh: improve testing with explicit URL and merge spec
Commit 6106ce4 introduced a test to demonstrate fetch's failure to retrieve any objects or update FETCH_HEAD when it was supplied a repository URL and the current branch had a configured merge spec. This commit expands the original test based on comments from Junio Hamano. In addition to actually verifying that the fetch updates FETCH_HEAD correctly, and does not update the current branch, two more tests are added to ensure that the merge configuration is ignored even when the supplied URL matches the URL of the remote configured for the branch. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f31dbdc commit 042cca3

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

t/t5510-fetch.sh

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,36 @@ test_expect_success 'fetch with a non-applying branch.<name>.merge' '
240240
git fetch blub
241241
'
242242

243-
test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge' '
243+
# URL supplied to fetch does not match the url of the configured branch's remote
244+
test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge [1]' '
245+
one_head=$(cd one && git rev-parse HEAD) &&
246+
this_head=$(git rev-parse HEAD) &&
244247
git update-ref -d FETCH_HEAD &&
245248
git fetch one &&
246-
git rev-parse --verify FETCH_HEAD
249+
test $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&
250+
test $this_head = "$(git rev-parse --verify HEAD)"
251+
'
252+
253+
# URL supplied to fetch matches the url of the configured branch's remote and
254+
# the merge spec matches the branch the remote HEAD points to
255+
test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge [2]' '
256+
one_ref=$(cd one && git symbolic-ref HEAD) &&
257+
git config branch.master.remote blub &&
258+
git config branch.master.merge "$one_ref" &&
259+
git update-ref -d FETCH_HEAD &&
260+
git fetch one &&
261+
test $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&
262+
test $this_head = "$(git rev-parse --verify HEAD)"
263+
'
264+
265+
# URL supplied to fetch matches the url of the configured branch's remote, but
266+
# the merge spec does not match the branch the remote HEAD points to
267+
test_expect_success 'fetch from GIT URL with a non-applying branch.<name>.merge [3]' '
268+
git config branch.master.merge "${one_ref}_not" &&
269+
git update-ref -d FETCH_HEAD &&
270+
git fetch one &&
271+
test $one_head = "$(git rev-parse --verify FETCH_HEAD)" &&
272+
test $this_head = "$(git rev-parse --verify HEAD)"
247273
'
248274

249275
# the strange name is: a\!'b

0 commit comments

Comments
 (0)