| 47 | } |
| 48 | |
| 49 | enum protocol_version determine_protocol_version_server(void) |
| 50 | { |
| 51 | const char *git_protocol = getenv(GIT_PROTOCOL_ENVIRONMENT); |
| 52 | enum protocol_version version = protocol_v0; |
| 53 | |
| 54 | /* |
| 55 | * Determine which protocol version the client has requested. Since |
| 56 | * multiple 'version' keys can be sent by the client, indicating that |
| 57 | * the client is okay to speak any of them, select the greatest version |
| 58 | * that the client has requested. This is due to the assumption that |
| 59 | * the most recent protocol version will be the most state-of-the-art. |
| 60 | */ |
| 61 | if (git_protocol) { |
| 62 | struct string_list list = STRING_LIST_INIT_DUP; |
| 63 | const struct string_list_item *item; |
| 64 | string_list_split(&list, git_protocol, ":", -1); |
| 65 | |
| 66 | for_each_string_list_item(item, &list) { |
| 67 | const char *value; |
| 68 | enum protocol_version v; |
| 69 | |
| 70 | if (skip_prefix(item->string, "version=", &value)) { |
| 71 | v = parse_protocol_version(value); |
| 72 | if (v > version) |
| 73 | version = v; |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | string_list_clear(&list, 0); |
| 78 | } |
| 79 | |
| 80 | trace2_data_intmax("transfer", NULL, "negotiated-version", version); |
| 81 | |
| 82 | return version; |
| 83 | } |
| 84 | |
| 85 | enum protocol_version determine_protocol_version_client(const char *server_response) |
| 86 | { |
no test coverage detected