@@ -182,6 +182,13 @@ test_expect_success 'server-options are sent when using ls-remote' '
182182 grep "server-option=world" log
183183'
184184
185+ test_expect_success ' warn if using server-option with ls-remote with legacy protocol' '
186+ test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
187+ ls-remote -o hello -o world "file://$(pwd)/file_parent" master 2>err &&
188+
189+ test_i18ngrep "see protocol.version in" err &&
190+ test_i18ngrep "server options require protocol version 2 or later" err
191+ '
185192
186193test_expect_success ' clone with file:// using protocol v2' '
187194 test_when_finished "rm -f log" &&
@@ -251,6 +258,40 @@ test_expect_success 'server-options are sent when fetching' '
251258 grep "server-option=world" log
252259'
253260
261+ test_expect_success ' warn if using server-option with fetch with legacy protocol' '
262+ test_when_finished "rm -rf temp_child" &&
263+
264+ git init temp_child &&
265+
266+ test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -C temp_child -c protocol.version=0 \
267+ fetch -o hello -o world "file://$(pwd)/file_parent" master 2>err &&
268+
269+ test_i18ngrep "see protocol.version in" err &&
270+ test_i18ngrep "server options require protocol version 2 or later" err
271+ '
272+
273+ test_expect_success ' server-options are sent when cloning' '
274+ test_when_finished "rm -rf log myclone" &&
275+
276+ GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
277+ clone --server-option=hello --server-option=world \
278+ "file://$(pwd)/file_parent" myclone &&
279+
280+ grep "server-option=hello" log &&
281+ grep "server-option=world" log
282+ '
283+
284+ test_expect_success ' warn if using server-option with clone with legacy protocol' '
285+ test_when_finished "rm -rf myclone" &&
286+
287+ test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
288+ clone --server-option=hello --server-option=world \
289+ "file://$(pwd)/file_parent" myclone 2>err &&
290+
291+ test_i18ngrep "see protocol.version in" err &&
292+ test_i18ngrep "server options require protocol version 2 or later" err
293+ '
294+
254295test_expect_success ' upload-pack respects config using protocol v2' '
255296 git init server &&
256297 write_script server/.git/hook <<-\EOF &&
0 commit comments