| 129 | } |
| 130 | |
| 131 | static struct remote *make_remote(struct remote_state *remote_state, |
| 132 | const char *name, int len) |
| 133 | { |
| 134 | struct remote *ret; |
| 135 | struct remotes_hash_key lookup; |
| 136 | struct hashmap_entry lookup_entry, *e; |
| 137 | |
| 138 | if (!len) |
| 139 | len = strlen(name); |
| 140 | |
| 141 | lookup.str = name; |
| 142 | lookup.len = len; |
| 143 | hashmap_entry_init(&lookup_entry, memhash(name, len)); |
| 144 | |
| 145 | e = hashmap_get(&remote_state->remotes_hash, &lookup_entry, &lookup); |
| 146 | if (e) |
| 147 | return container_of(e, struct remote, ent); |
| 148 | |
| 149 | CALLOC_ARRAY(ret, 1); |
| 150 | ret->prune = -1; /* unspecified */ |
| 151 | ret->prune_tags = -1; /* unspecified */ |
| 152 | ret->name = xstrndup(name, len); |
| 153 | refspec_init_push(&ret->push); |
| 154 | refspec_init_fetch(&ret->fetch); |
| 155 | string_list_init_dup(&ret->server_options); |
| 156 | string_list_init_dup(&ret->negotiation_restrict); |
| 157 | string_list_init_dup(&ret->negotiation_include); |
| 158 | |
| 159 | ALLOC_GROW(remote_state->remotes, remote_state->remotes_nr + 1, |
| 160 | remote_state->remotes_alloc); |
| 161 | remote_state->remotes[remote_state->remotes_nr++] = ret; |
| 162 | |
| 163 | hashmap_entry_init(&ret->ent, lookup_entry.hash); |
| 164 | if (hashmap_put_entry(&remote_state->remotes_hash, ret, ent)) |
| 165 | BUG("hashmap_put overwrote entry after hashmap_get returned NULL"); |
| 166 | return ret; |
| 167 | } |
| 168 | |
| 169 | static void remote_clear(struct remote *remote) |
| 170 | { |
no test coverage detected