mirror of
https://github.com/git/git.git
synced 2024-12-26 18:24:21 +08:00
51b74b57ae
Commit2071e05ed2
("t5536: new test of refspec conflicts when fetching", 2013-10-30), introduced the verify_stderr() function which was used to verify that certain fatal/warning messages were issued by a given git command. In addition, verify_stderr() would filter a specific "fatal: The remote end hung up unexpectedly" message, which may, or may not, be present (depending on the relative timing of the git-fetch and git-upload-pack processes). The verify_stderr() function has seen several modifications, which has introduced a couple of minor problems. For example, commit1edbaac3bb
("tests: use test_i18n* functions to suppress false positives", 2016-06-17) introduced an inappropriate test_i18ngrep call and commitf096e6e826
("fetch: improve the error messages emitted for conflicting refspecs", 2013-10-30) included an ineffective invocation of sort at the end of a grep pipeline. Instead of fixing these minor problems in verify_stderr(), we take the simpler approach of directly searching the error file, using test_i18ngrep, for the specific message(s) we expect. (The only minor downside is that we would not notice any new messages). Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
87 lines
2.3 KiB
Bash
Executable File
87 lines
2.3 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='fetch handles conflicting refspecs correctly'
|
|
|
|
. ./test-lib.sh
|
|
|
|
D=$(pwd)
|
|
|
|
setup_repository () {
|
|
git init "$1" && (
|
|
cd "$1" &&
|
|
git config remote.origin.url "$D" &&
|
|
shift &&
|
|
for refspec in "$@"
|
|
do
|
|
git config --add remote.origin.fetch "$refspec"
|
|
done
|
|
)
|
|
}
|
|
|
|
test_expect_success 'setup' '
|
|
git commit --allow-empty -m "Initial" &&
|
|
git branch branch1 &&
|
|
git tag tag1 &&
|
|
git commit --allow-empty -m "First" &&
|
|
git branch branch2 &&
|
|
git tag tag2
|
|
'
|
|
|
|
test_expect_success 'fetch with no conflict' '
|
|
setup_repository ok "+refs/heads/*:refs/remotes/origin/*" && (
|
|
cd ok &&
|
|
git fetch origin
|
|
)
|
|
'
|
|
|
|
test_expect_success 'fetch conflict: config vs. config' '
|
|
setup_repository ccc \
|
|
"+refs/heads/branch1:refs/remotes/origin/branch1" \
|
|
"+refs/heads/branch2:refs/remotes/origin/branch1" && (
|
|
cd ccc &&
|
|
test_must_fail git fetch origin 2>error &&
|
|
test_i18ngrep "fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1" error
|
|
)
|
|
'
|
|
|
|
test_expect_success 'fetch duplicate: config vs. config' '
|
|
setup_repository dcc \
|
|
"+refs/heads/*:refs/remotes/origin/*" \
|
|
"+refs/heads/branch1:refs/remotes/origin/branch1" && (
|
|
cd dcc &&
|
|
git fetch origin
|
|
)
|
|
'
|
|
|
|
test_expect_success 'fetch conflict: arg overrides config' '
|
|
setup_repository aoc \
|
|
"+refs/heads/*:refs/remotes/origin/*" && (
|
|
cd aoc &&
|
|
git fetch origin refs/heads/branch2:refs/remotes/origin/branch1
|
|
)
|
|
'
|
|
|
|
test_expect_success 'fetch conflict: arg vs. arg' '
|
|
setup_repository caa && (
|
|
cd caa &&
|
|
test_must_fail git fetch origin \
|
|
refs/heads/*:refs/remotes/origin/* \
|
|
refs/heads/branch2:refs/remotes/origin/branch1 2>error &&
|
|
test_i18ngrep "fatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1" error
|
|
)
|
|
'
|
|
|
|
test_expect_success 'fetch conflict: criss-cross args' '
|
|
setup_repository xaa \
|
|
"+refs/heads/*:refs/remotes/origin/*" && (
|
|
cd xaa &&
|
|
git fetch origin \
|
|
refs/heads/branch1:refs/remotes/origin/branch2 \
|
|
refs/heads/branch2:refs/remotes/origin/branch1 2>error &&
|
|
test_i18ngrep "warning: refs/remotes/origin/branch1 usually tracks refs/heads/branch1, not refs/heads/branch2" error &&
|
|
test_i18ngrep "warning: refs/remotes/origin/branch2 usually tracks refs/heads/branch2, not refs/heads/branch1" error
|
|
)
|
|
'
|
|
|
|
test_done
|