Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs/heads/patch 1 #1858

Closed
wants to merge 169 commits into from
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
169 commits
Select commit Hold shift + click to select a range
a87ffb0
Merge branch 'jh/config-unset-doc-fix' into next
gitster Oct 10, 2024
5531615
Merge branch 'js/doc-platform-support-link-fix' into next
gitster Oct 10, 2024
0e38c7f
Merge branch 'xx/remote-server-option-config' into next
gitster Oct 10, 2024
0c40f5c
Merge branch 'jk/fsmonitor-event-listener-race-fix' into next
gitster Oct 10, 2024
b22c213
Merge branch 'kh/merge-tree-doc' into next
gitster Oct 11, 2024
e3a8d7f
Merge branch 'aa/t7300-modernize' into next
gitster Oct 11, 2024
99252fb
Merge branch 'kn/loose-object-layer-wo-global-hash' into next
gitster Oct 11, 2024
a5785fd
Merge branch 'ng/rebase-merges-branch-name-as-label' into next
gitster Oct 11, 2024
912ed5f
Merge branch 'jc/doc-refspec-syntax' into next
gitster Oct 11, 2024
c54df41
Merge branch 'ps/maintenance-start-crash-fix' into next
gitster Oct 11, 2024
ed66b60
Merge branch 'kh/checkout-ignore-other-docfix' into next
gitster Oct 11, 2024
37932ad
Merge branch 'xx/protocol-v2-doc-markup-fix' into next
gitster Oct 11, 2024
07ac214
Merge branch 'tc/bundle-uri-leakfix' into next
gitster Oct 11, 2024
0048cdb
Merge branch 'ps/cache-tree-w-broken-index-entry' into next
ttaylorr Oct 15, 2024
efc01c6
Merge branch 'cw/worktree-relative' into next
ttaylorr Oct 15, 2024
2ce7280
Sync with 'master'
ttaylorr Oct 15, 2024
b246cb1
Merge branch 'bf/t-readme-mention-reftable' into next
ttaylorr Oct 18, 2024
ae6e80b
Merge branch 'pb/clar-build-fix' into next
ttaylorr Oct 18, 2024
c45095c
Merge branch 'ak/typofixes' into next
ttaylorr Oct 18, 2024
a473d0d
Merge branch 'db/submodule-fetch-with-remote-name-fix' into next
ttaylorr Oct 18, 2024
2530706
Merge branch 'wm/shortlog-hash' into next
ttaylorr Oct 18, 2024
954a1eb
Merge branch 'sk/msvc-warnings' into next
ttaylorr Oct 18, 2024
83df4b3
Merge branch 'ak/typofix' into next
ttaylorr Oct 18, 2024
899fb7e
Merge branch 'jc/breaking-changes-early-adopter-option' into next
ttaylorr Oct 18, 2024
58a3be4
Merge branch 'ps/ci-gitlab-windows' into next
ttaylorr Oct 18, 2024
b428982
Merge branch 'jc/a-commands-without-the-repo' into next
ttaylorr Oct 18, 2024
1226f6d
Sync with 'master'
ttaylorr Oct 18, 2024
469c11a
Merge branch 'ps/reftable-strbuf' into next
ttaylorr Oct 22, 2024
6313df7
Merge branch 'ps/ref-filter-sort' into next
ttaylorr Oct 22, 2024
46b99d8
Merge branch 'ps/platform-compat-fixes' into next
ttaylorr Oct 22, 2024
0882adf
Merge branch 'kh/submitting-patches' into next
ttaylorr Oct 22, 2024
a87a9a8
Merge branch 'ks/t4205-fixup' into next
ttaylorr Oct 22, 2024
d377ddb
Merge branch 'co/t6050-pipefix' into next
ttaylorr Oct 22, 2024
4273cb6
Merge branch 'sk/t7011-cleanup' into next
ttaylorr Oct 22, 2024
a7371ff
Sync with 'master'
ttaylorr Oct 22, 2024
26b7b76
Merge branch 'ua/t3404-cleanup' into next
ttaylorr Oct 25, 2024
a3acd18
Merge branch 'rj/cygwin-exit' into next
ttaylorr Oct 25, 2024
db92c3e
Merge branch 'kh/mv-breakage' into next
ttaylorr Oct 25, 2024
ede3955
Merge branch 'ps/upload-pack-doc' into next
ttaylorr Oct 25, 2024
a55ee8b
Merge branch 'ss/duplicate-typos' into next
ttaylorr Oct 25, 2024
43a3513
Merge branch 'sk/t9101-cleanup' into next
ttaylorr Oct 25, 2024
29b26e5
Merge branch 'sa/notes-edit' into next
ttaylorr Oct 25, 2024
ecd980f
Merge branch 'ua/atoi' into next
ttaylorr Oct 25, 2024
1dd1717
Merge branch 'ak/t1016-cleanup' into next
ttaylorr Oct 25, 2024
44fc090
Merge branch 'rs/grep-lookahead' into next
ttaylorr Oct 25, 2024
63e3f96
Merge branch 'ak/more-typofixes' into next
ttaylorr Oct 25, 2024
317cc41
Merge branch 'kh/update-ref' into next
ttaylorr Oct 25, 2024
085561e
Sync with 'master'
ttaylorr Oct 25, 2024
eb1d692
Merge branch 'ps/platform-compat-fixes' into next
ttaylorr Oct 30, 2024
3eedf30
Merge branch 'kn/arbitrary-suffixes' into next
ttaylorr Oct 30, 2024
d063e82
Merge branch 'kn/ci-clang-format-tidy' into next
ttaylorr Oct 30, 2024
875fa0b
Merge branch 'cw/config-extensions' into next
ttaylorr Oct 30, 2024
b8b092b
Merge branch 'ps/upgrade-clar' into next
ttaylorr Oct 30, 2024
00932eb
Merge branch 'jk/dumb-http-finalize' into next
ttaylorr Oct 30, 2024
8800431
Sync with 'master'
ttaylorr Oct 30, 2024
f1d0c39
Merge branch 'jk/left-right-bitmap' into next
ttaylorr Nov 1, 2024
c08e6fc
Sync with 'master'
ttaylorr Nov 1, 2024
0260dbd
Merge branch 'ps/leakfixes-part-9' into next
gitster Nov 6, 2024
ee100e9
Merge branch 'ak/t1016-style' into next
gitster Nov 6, 2024
8c5d529
Merge branch 'en/shallow-exclude-takes-a-ref-fix' into next
gitster Nov 6, 2024
b4dd083
Merge branch 'jt/commit-graph-missing' into next
gitster Nov 6, 2024
6dd2fff
Merge branch 'ps/mingw-rename' into next
gitster Nov 6, 2024
60cca15
Sync with 'master'
gitster Nov 8, 2024
c49de5d
Sync with 'master'
gitster Nov 11, 2024
895d633
Merge branch 'jt/repack-local-promisor' into next
gitster Nov 12, 2024
9aa0331
Merge branch 'jk/test-malloc-debug-check' into next
gitster Nov 12, 2024
1af6d17
Merge branch 'ja/git-add-doc-markup' into next
gitster Nov 12, 2024
f038e22
Merge branch 'la/trailer-info' into next
gitster Nov 12, 2024
bc8a4e4
Sync with 'master'
gitster Nov 12, 2024
4f8a448
Merge branch 'jk/test-malloc-debug-check' into next
gitster Nov 15, 2024
178c112
Merge branch 'jk/fetch-prefetch-double-free-fix' into next
gitster Nov 15, 2024
a323438
Merge branch 'sm/difftool' into next
gitster Nov 15, 2024
3279229
Merge branch 'tb/multi-pack-reuse-dupfix' into next
gitster Nov 16, 2024
95f8e04
Sync with 'master'
gitster Nov 16, 2024
d70c2c3
Merge branch 'kh/bundle-docs' into next
gitster Nov 20, 2024
d88840a
Merge branch 'ps/clar-build-improvement' into next
gitster Nov 20, 2024
bd29255
Merge branch 'bc/c23' into next
gitster Nov 20, 2024
fa92bcd
Merge branch 'jk/gcc15' into next
gitster Nov 20, 2024
fad433e
Merge branch 'kh/trailer-in-glossary' into next
gitster Nov 20, 2024
751ee6b
Merge branch 'en/fast-import-avoid-self-replace' into next
gitster Nov 20, 2024
9bd7657
Merge branch 'jt/index-pack-allow-promisor-only-while-fetching' into …
gitster Nov 20, 2024
19ba395
Sync with 'master'
gitster Nov 20, 2024
2339988
Merge branch 'kn/ref-transaction-hook-with-reflog' into next
gitster Nov 20, 2024
1099c31
Merge branch 'ps/gc-stale-lock-warning' into next
gitster Nov 20, 2024
ff69ae1
Sync with 'master'
gitster Nov 22, 2024
7284f18
Merge branch 'ps/leakfixes-part-10' into next
gitster Nov 25, 2024
ee2e588
Merge branch 'ps/ref-backend-migration-optim' into next
gitster Nov 25, 2024
53e29ae
Merge branch 'sj/ref-contents-check' into next
gitster Nov 25, 2024
f312b2f
Merge branch 'tb/boundary-traversal-fix' into next
gitster Nov 25, 2024
2bdd016
Merge branch 'tb/use-test-file-size-more' into next
gitster Nov 25, 2024
dd8b44a
Sync with 'master'
gitster Nov 25, 2024
ed3858b
Merge branch 'ps/gc-stale-lock-warning' into next
gitster Nov 26, 2024
7bb66a1
Merge branch 'ps/ref-backend-migration-optim' into next
gitster Nov 26, 2024
8b145bb
Merge branch 'en/fast-import-path-sanitize' into next
gitster Nov 26, 2024
e163bce
Merge branch 'ps/bisect-double-free-fix' into next
gitster Nov 26, 2024
668c091
Merge branch 'kn/pass-repo-to-builtin-sub-sub-commands' into next
gitster Nov 26, 2024
aa7866a
Merge branch 'bc/drop-ancient-libcurl-and-perl' into next
gitster Nov 26, 2024
b33b5ae
Merge branch 'ja/git-diff-doc-markup' into next
gitster Nov 26, 2024
9683f9f
Sync with 'master'
gitster Nov 26, 2024
65eba16
Merge branch 'sj/refs-symref-referent-fix' into next
gitster Nov 28, 2024
84693f6
Merge branch 'kh/sequencer-comment-char' into next
gitster Nov 28, 2024
2932fa5
Merge branch 'en/fast-import-verify-path' into next
gitster Dec 2, 2024
f612874
Merge branch 'bc/ancient-ci' into next
gitster Dec 2, 2024
e345717
Merge branch 'jc/doc-opt-tilde-expand' into next
gitster Dec 2, 2024
b439b14
Merge branch 'pb/mergetool-errors' into next
gitster Dec 2, 2024
0f34109
Merge branch 'jk/describe-perf' into next
gitster Dec 2, 2024
bf711f0
Merge branch 'bc/allow-upload-pack-from-other-people' into next
gitster Dec 2, 2024
b142ff3
Merge branch 'bf/set-head-symref' into next
gitster Dec 2, 2024
e105e78
Merge branch 'ps/reftable-detach' into next
gitster Dec 2, 2024
3c1d2e2
Merge branch 'ps/reftable-iterator-reuse' into next
gitster Dec 2, 2024
69bfc59
Merge branch 'bf/fetch-set-head-config' (early part) into next
gitster Dec 4, 2024
bfd07a8
Merge branch 'jt/bundle-fsck' into next
gitster Dec 4, 2024
2d19ff4
Merge branch 'jc/doc-error-message-guidelines' into next
gitster Dec 4, 2024
5da441c
Merge branch 'kh/doc-bundle-typofix' into next
gitster Dec 4, 2024
9905f16
Merge branch 'kh/doc-update-ref-grammofix' into next
gitster Dec 4, 2024
a4f8a86
Sync with 'master'
gitster Dec 4, 2024
bbdd9b9
Merge branch 'en/fast-import-verify-path' into next
gitster Dec 5, 2024
1f973ae
Merge branch 'es/oss-fuzz' into next
gitster Dec 5, 2024
7bd98d1
Merge branch 'cw/worktree-extension' into next
gitster Dec 5, 2024
e48a185
Merge branch 'kn/midx-wo-the-repository' into next
gitster Dec 5, 2024
36d6c51
Merge branch 'kk/doc-ancestry-path' into next
gitster Dec 5, 2024
c27f4b7
Sync with 'master'
gitster Dec 6, 2024
adea889
Merge branch 'jc/forbid-head-as-tagname' into next
gitster Dec 10, 2024
900cadd
Merge branch 'bf/fetch-set-head-config' into next
gitster Dec 10, 2024
a20c319
Merge branch 'bf/explicit-config-set-in-advice-messages' into next
gitster Dec 10, 2024
509db1d
Merge branch 'jk/describe-perf' into next
gitster Dec 10, 2024
ddbfd88
Merge branch 'rj/strvec-splice-fix' into next
gitster Dec 10, 2024
da3d13a
Merge branch 'ps/commit-with-message-syntax-fix' into next
gitster Dec 10, 2024
5a40801
Merge branch 'jt/fix-fattening-promisor-fetch' into next
gitster Dec 10, 2024
cb270b3
Merge branch 'ps/build' into next
gitster Dec 11, 2024
f74b3f2
Sync with 'master'
gitster Dec 11, 2024
b71687c
git-submodule.sh: improve parsing of some long options
Dec 11, 2024
e6c3e34
git-submodule.sh: improve parsing of short options
Dec 11, 2024
006f546
git-submodule.sh: get rid of isnumber
Dec 11, 2024
402e46d
git-submodule.sh: get rid of unused variable
Dec 11, 2024
57f9b30
git-submodule.sh: add some comments
Dec 11, 2024
3ad0ba7
git-submodule.sh: improve variables readability
Dec 11, 2024
b86f0f9
git-submodule.sh: rename some variables
Dec 11, 2024
4784443
Merge branch 'jc/set-head-symref-fix' into next
gitster Dec 13, 2024
90156d7
Merge branch 'js/log-remerge-keep-ancestry' into next
gitster Dec 13, 2024
9f49e6f
Merge branch 'mh/doc-windows-home-env' into next
gitster Dec 13, 2024
7f4ebe0
Merge branch 'tc/bundle-with-tag-remove-workaround' into next
gitster Dec 13, 2024
23fc6f9
Sync with 'master'
gitster Dec 13, 2024
e0ca818
Merge branch 'ps/ci-gitlab-update' into next
gitster Dec 15, 2024
7e6b58d
Merge branch 'kn/reftable-writer-log-write-verify' into next
gitster Dec 16, 2024
1ddb148
Merge branch 'ps/build-sign-compare' into next
gitster Dec 16, 2024
b54e9a5
Merge branch 'as/show-index-uninitialized-hash' into next
gitster Dec 16, 2024
0fc57de
Sync with Git 2.48-rc0
gitster Dec 16, 2024
653a20d
Merge branch 'js/ps-build-cmake-fixup' into next
gitster Dec 17, 2024
6d59340
Merge branch 'js/github-windows-setup-fix' into next
gitster Dec 17, 2024
57dc9a0
Merge branch 'js/mingw-rename-fix' into next
gitster Dec 17, 2024
fc95a5a
Merge branch 'ps/ci-meson' into next
gitster Dec 17, 2024
d491657
Sync with 'master'
gitster Dec 18, 2024
5634446
Merge branch 'kn/reflog-migration' into next
gitster Dec 18, 2024
47394ea
Merge branch 'js/range-diff-diff-merges' into next
gitster Dec 19, 2024
5af85a7
Merge branch 'sk/calloc-not-malloc-plus-memset' into next
gitster Dec 19, 2024
3cddc25
Sync with 'master'
gitster Dec 19, 2024
f775554
Merge branch 'ps/build-meson-gitweb' into next
gitster Dec 21, 2024
11a5c3d
Merge branch 'jk/prio-queue-sign-compare-fix' into next
gitster Dec 21, 2024
1044634
Merge branch 'tb/bitmap-fix-pack-reuse' into next
gitster Dec 21, 2024
d6f8295
Merge branch 'kl/doc-build-fix' into next
gitster Dec 21, 2024
9e65a56
Merge branch 're/submodule-parse-opt' into next
gitster Dec 21, 2024
92bc55b
Merge branch 'ps/reftable-alloc-failures-zalloc-fix' into next
gitster Dec 22, 2024
0d4dfd1
Merge branch 'ps/build-hotfix' into next
gitster Dec 22, 2024
7a2aad7
Merge branch 'ma/asciidoctor-build-fixes' into next
gitster Dec 22, 2024
b75456b
Merge branch 'kn/reflog-migration' into next
gitster Dec 22, 2024
f2cfb42
Git 2.48-rc1
gitster Dec 23, 2024
73897bc
Sync with Git 2.48-rc1
gitster Dec 23, 2024
bde2763
Rename main.yml to main.yml
Mohammed-Alanazisa Dec 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Documentation/config/remote.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ remote.<name>.partialclonefilter::
Changing or clearing this value will only affect fetches for new commits.
To fetch associated objects for commits already present in the local object
database, use the `--refetch` option of linkgit:git-fetch[1].

remote.<name>.serverOption::
The default set of server options used when fetching from this remote.
These server options can be overridden by the `--server-option=` command
line arguments.
+
This is a multi-valued variable, and an empty value can be used in a higher
priority configuration file (e.g. `.git/config` in a repository) to clear
the values inherited from a lower priority configuration files (e.g.
`$HOME/.gitconfig`).
3 changes: 3 additions & 0 deletions Documentation/fetch-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ endif::git-pull[]
unknown ones, is server-specific.
When multiple `--server-option=<option>` are given, they are all
sent to the other side in the order listed on the command line.
When no `--server-option=<option>` is given from the command line,
the values of configuration variable `remote.<name>.serverOption`
are used instead.

--show-forced-updates::
By default, git checks if a branch is force-updated during
Expand Down
3 changes: 3 additions & 0 deletions Documentation/git-clone.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ objects from the source repository into a pack in the cloned repository.
unknown ones, is server-specific.
When multiple `--server-option=<option>` are given, they are all
sent to the other side in the order listed on the command line.
When no ++--server-option=++__<option>__ is given from the command
line, the values of configuration variable `remote.<name>.serverOption`
are used instead.

`-n`::
`--no-checkout`::
Expand Down
3 changes: 3 additions & 0 deletions Documentation/git-ls-remote.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ OPTIONS
character.
When multiple `--server-option=<option>` are given, they are all
sent to the other side in the order listed on the command line.
When no `--server-option=<option>` is given from the command line,
the values of configuration variable `remote.<name>.serverOption`
are used instead.

<repository>::
The "remote" repository to query. This parameter can be
Expand Down
2 changes: 2 additions & 0 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1981,6 +1981,8 @@ static int fetch_multiple(struct string_list *list, int max_children,
strvec_pushl(&argv, "-c", "fetch.bundleURI=",
"fetch", "--append", "--no-auto-gc",
"--no-write-commit-graph", NULL);
for (i = 0; i < server_options.nr; i++)
strvec_pushf(&argv, "--server-option=%s", server_options.items[i].string);
add_options_to_argv(&argv, config);

if (max_children != 1 && list->nr != 1) {
Expand Down
1 change: 1 addition & 0 deletions builtin/ls-remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,5 +173,6 @@ int cmd_ls_remote(int argc,
transport_ls_refs_options_release(&transport_options);

strvec_clear(&pattern);
string_list_clear(&server_options, 0);
return status;
}
9 changes: 1 addition & 8 deletions builtin/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,14 +519,7 @@ static int git_push_config(const char *k, const char *v,
RECURSE_SUBMODULES_ON_DEMAND : RECURSE_SUBMODULES_OFF;
recurse_submodules = val;
} else if (!strcmp(k, "push.pushoption")) {
if (!v)
return config_error_nonbool(k);
else
if (!*v)
string_list_clear(&push_options_config, 0);
else
string_list_append(&push_options_config, v);
return 0;
return parse_transport_option(k, v, &push_options_config);
} else if (!strcmp(k, "color.push")) {
push_use_color = git_config_colorbool(k, v);
return 0;
Expand Down
6 changes: 6 additions & 0 deletions remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "advice.h"
#include "connect.h"
#include "parse-options.h"
#include "transport.h"

enum map_direction { FROM_SRC, FROM_DST };

Expand Down Expand Up @@ -143,6 +144,7 @@ static struct remote *make_remote(struct remote_state *remote_state,
ret->name = xstrndup(name, len);
refspec_init(&ret->push, REFSPEC_PUSH);
refspec_init(&ret->fetch, REFSPEC_FETCH);
string_list_init_dup(&ret->server_options);

ALLOC_GROW(remote_state->remotes, remote_state->remotes_nr + 1,
remote_state->remotes_alloc);
Expand All @@ -166,6 +168,7 @@ static void remote_clear(struct remote *remote)
free((char *)remote->uploadpack);
FREE_AND_NULL(remote->http_proxy);
FREE_AND_NULL(remote->http_proxy_authmethod);
string_list_clear(&remote->server_options, 0);
}

static void add_merge(struct branch *branch, const char *name)
Expand Down Expand Up @@ -508,6 +511,9 @@ static int handle_config(const char *key, const char *value,
} else if (!strcmp(subkey, "vcs")) {
FREE_AND_NULL(remote->foreign_vcs);
return git_config_string(&remote->foreign_vcs, key, value);
} else if (!strcmp(subkey, "serveroption")) {
return parse_transport_option(key, value,
&remote->server_options);
}
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions remote.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "hash.h"
#include "hashmap.h"
#include "refspec.h"
#include "string-list.h"
#include "strvec.h"

struct option;
Expand Down Expand Up @@ -104,6 +105,8 @@ struct remote {

/* The method used for authenticating against `http_proxy`. */
char *http_proxy_authmethod;

struct string_list server_options;
};

/**
Expand Down
133 changes: 133 additions & 0 deletions t/t5702-protocol-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,43 @@ test_expect_success 'server-options are sent when using ls-remote' '
grep "server-option=world" log
'

test_expect_success 'server-options from configuration are used by ls-remote' '
test_when_finished "rm -rf log myclone" &&
git clone "file://$(pwd)/file_parent" myclone &&
cat >expect <<-EOF &&
$(git -C file_parent rev-parse refs/heads/main)$(printf "\t")refs/heads/main
EOF

# Default server options from configuration are used
git -C myclone config --add remote.origin.serverOption foo &&
git -C myclone config --add remote.origin.serverOption bar &&
GIT_TRACE_PACKET="$(pwd)/log" git -C myclone -c protocol.version=2 \
ls-remote origin main >actual &&
test_cmp expect actual &&
test_grep "ls-remote> server-option=foo" log &&
test_grep "ls-remote> server-option=bar" log &&
rm -f log &&

# Empty value of remote.<name>.serverOption clears the list
git -C myclone config --add remote.origin.serverOption "" &&
git -C myclone config --add remote.origin.serverOption tar &&
GIT_TRACE_PACKET="$(pwd)/log" git -C myclone -c protocol.version=2 \
ls-remote origin main >actual &&
test_cmp expect actual &&
test_grep "ls-remote> server-option=tar" log &&
test_grep ! "ls-remote> server-option=foo" log &&
test_grep ! "ls-remote> server-option=bar" log &&
rm -f log &&

# Server option from command line overrides those from configuration
GIT_TRACE_PACKET="$(pwd)/log" git -C myclone -c protocol.version=2 \
ls-remote -o hello -o world origin main >actual &&
test_cmp expect actual &&
test_grep "ls-remote> server-option=hello" log &&
test_grep "ls-remote> server-option=world" log &&
test_grep ! "ls-remote> server-option=tar" log
'

test_expect_success 'warn if using server-option with ls-remote with legacy protocol' '
test_must_fail env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
ls-remote -o hello -o world "file://$(pwd)/file_parent" main 2>err &&
Expand Down Expand Up @@ -381,6 +418,54 @@ test_expect_success 'server-options are sent when fetching' '
grep "server-option=world" log
'

test_expect_success 'server-options are sent when fetch multiple remotes' '
test_when_finished "rm -f log server_options_sent" &&
git clone "file://$(pwd)/file_parent" child_multi_remotes &&
git -C child_multi_remotes remote add another "file://$(pwd)/file_parent" &&
GIT_TRACE_PACKET="$(pwd)/log" git -C child_multi_remotes -c protocol.version=2 \
fetch -o hello --all &&
grep "fetch> server-option=hello" log >server_options_sent &&
test_line_count = 2 server_options_sent
'

test_expect_success 'server-options from configuration are used by git-fetch' '
test_when_finished "rm -rf log myclone" &&
git clone "file://$(pwd)/file_parent" myclone &&
git -C file_parent log -1 --format=%s >expect &&

# Default server options from configuration are used
git -C myclone config --add remote.origin.serverOption foo &&
git -C myclone config --add remote.origin.serverOption bar &&
GIT_TRACE_PACKET="$(pwd)/log" git -C myclone -c protocol.version=2 \
fetch origin main &&
git -C myclone log -1 --format=%s origin/main >actual &&
test_cmp expect actual &&
test_grep "fetch> server-option=foo" log &&
test_grep "fetch> server-option=bar" log &&
rm -f log &&

# Empty value of remote.<name>.serverOption clears the list
git -C myclone config --add remote.origin.serverOption "" &&
git -C myclone config --add remote.origin.serverOption tar &&
GIT_TRACE_PACKET="$(pwd)/log" git -C myclone -c protocol.version=2 \
fetch origin main &&
git -C myclone log -1 --format=%s origin/main >actual &&
test_cmp expect actual &&
test_grep "fetch> server-option=tar" log &&
test_grep ! "fetch> server-option=foo" log &&
test_grep ! "fetch> server-option=bar" log &&
rm -f log &&

# Server option from command line overrides those from configuration
GIT_TRACE_PACKET="$(pwd)/log" git -C myclone -c protocol.version=2 \
fetch -o hello -o world origin main &&
git -C myclone log -1 --format=%s origin/main >actual &&
test_cmp expect actual &&
test_grep "fetch> server-option=hello" log &&
test_grep "fetch> server-option=world" log &&
test_grep ! "fetch> server-option=tar" log
'

test_expect_success 'warn if using server-option with fetch with legacy protocol' '
test_when_finished "rm -rf temp_child" &&

Expand All @@ -404,6 +489,37 @@ test_expect_success 'server-options are sent when cloning' '
grep "server-option=world" log
'

test_expect_success 'server-options from configuration are used by git-clone' '
test_when_finished "rm -rf log myclone" &&

# Default server options from configuration are used
GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
-c remote.origin.serverOption=foo -c remote.origin.serverOption=bar \
clone "file://$(pwd)/file_parent" myclone &&
test_grep "clone> server-option=foo" log &&
test_grep "clone> server-option=bar" log &&
rm -rf log myclone &&

# Empty value of remote.<name>.serverOption clears the list
GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
-c remote.origin.serverOption=foo -c remote.origin.serverOption=bar \
-c remote.origin.serverOption= -c remote.origin.serverOption=tar \
clone "file://$(pwd)/file_parent" myclone &&
test_grep "clone> server-option=tar" log &&
test_grep ! "clone> server-option=foo" log &&
test_grep ! "clone> server-option=bar" log &&
rm -rf log myclone &&

# Server option from command line overrides those from configuration
GIT_TRACE_PACKET="$(pwd)/log" git -c protocol.version=2 \
-c remote.origin.serverOption=tar \
clone --server-option=hello --server-option=world \
"file://$(pwd)/file_parent" myclone &&
test_grep "clone> server-option=hello" log &&
test_grep "clone> server-option=world" log &&
test_grep ! "clone> server-option=tar" log
'

test_expect_success 'warn if using server-option with clone with legacy protocol' '
test_when_finished "rm -rf myclone" &&

Expand All @@ -415,6 +531,23 @@ test_expect_success 'warn if using server-option with clone with legacy protocol
test_grep "server options require protocol version 2 or later" err
'

test_expect_success 'server-option configuration with legacy protocol is ok' '
test_when_finished "rm -rf myclone" &&

env GIT_TEST_PROTOCOL_VERSION=0 git -c protocol.version=0 \
-c remote.origin.serverOption=foo -c remote.origin.serverOption=bar \
clone "file://$(pwd)/file_parent" myclone
'

test_expect_success 'invalid server-option configuration' '
test_when_finished "rm -rf myclone" &&

test_must_fail git -c protocol.version=2 \
-c remote.origin.serverOption \
clone "file://$(pwd)/file_parent" myclone 2>err &&
test_grep "error: missing value for '\''remote.origin.serveroption'\''" err
'

test_expect_success 'upload-pack respects config using protocol v2' '
git init server &&
write_script server/.git/hook <<-\EOF &&
Expand Down
15 changes: 15 additions & 0 deletions transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ static struct ref *handshake(struct transport *transport, int for_push,
data->version = discover_version(&reader);
switch (data->version) {
case protocol_v2:
if ((!transport->server_options || !transport->server_options->nr) &&
transport->remote->server_options.nr)
transport->server_options = &transport->remote->server_options;
if (server_feature_v2("session-id", &server_sid))
trace2_data_string("transfer", NULL, "server-sid", server_sid);
if (must_list_refs)
Expand Down Expand Up @@ -1108,6 +1111,18 @@ int is_transport_allowed(const char *type, int from_user)
BUG("invalid protocol_allow_config type");
}

int parse_transport_option(const char *var, const char *value,
struct string_list *transport_options)
{
if (!value)
return config_error_nonbool(var);
if (!*value)
string_list_clear(transport_options, 0);
else
string_list_append(transport_options, value);
return 0;
}

void transport_check_allowed(const char *type)
{
if (!is_transport_allowed(type, -1))
Expand Down
4 changes: 4 additions & 0 deletions transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,8 @@ void transport_print_push_status(const char *dest, struct ref *refs,
/* common method used by transport-helper.c and send-pack.c */
void reject_atomic_push(struct ref *refs, int mirror_mode);

/* common method to parse push-option or server-option from config */
int parse_transport_option(const char *var, const char *value,
struct string_list *transport_options);

#endif