MCPcopy Index your code
hub / github.com/git/git / git_proxy_command_options

Function git_proxy_command_options

connect.c:951–999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

949static char *git_proxy_command;
950
951static int git_proxy_command_options(const char *var, const char *value,
952 const struct config_context *ctx, void *cb)
953{
954 if (!strcmp(var, "core.gitproxy")) {
955 const char *for_pos;
956 int matchlen = -1;
957 int hostlen;
958 const char *rhost_name = cb;
959 int rhost_len = strlen(rhost_name);
960
961 if (git_proxy_command)
962 return 0;
963 if (!value)
964 return config_error_nonbool(var);
965 /* [core]
966 * ;# matches www.kernel.org as well
967 * gitproxy = netcatter-1 for kernel.org
968 * gitproxy = netcatter-2 for sample.xz
969 * gitproxy = netcatter-default
970 */
971 for_pos = strstr(value, " for ");
972 if (!for_pos)
973 /* matches everybody */
974 matchlen = strlen(value);
975 else {
976 hostlen = strlen(for_pos + 5);
977 if (rhost_len < hostlen)
978 matchlen = -1;
979 else if (!strncmp(for_pos + 5,
980 rhost_name + rhost_len - hostlen,
981 hostlen) &&
982 ((rhost_len == hostlen) ||
983 rhost_name[rhost_len - hostlen -1] == '.'))
984 matchlen = for_pos - value;
985 else
986 matchlen = -1;
987 }
988 if (0 <= matchlen) {
989 /* core.gitproxy = none for kernel.org */
990 if (matchlen == 4 &&
991 !memcmp(value, "none", 4))
992 matchlen = 0;
993 git_proxy_command = xmemdupz(value, matchlen);
994 }
995 return 0;
996 }
997
998 return git_default_config(var, value, ctx, cb);
999}
1000
1001static int git_use_proxy(const char *host)
1002{

Callers

nothing calls this directly

Calls 3

config_error_nonboolFunction · 0.85
xmemdupzFunction · 0.85
git_default_configFunction · 0.85

Tested by

no test coverage detected