MCPcopy Create free account
hub / github.com/git/git / bundle_list_update

Function bundle_list_update

bundle-uri.c:143–232  ·  view source on GitHub ↗

* Given a key-value pair, update the state of the given bundle list. * Returns 0 if the key-value pair is understood. Returns -1 if the key * is not understood or the value is malformed. */

Source from the content-addressed store, hash-verified

141 * is not understood or the value is malformed.
142 */
143static int bundle_list_update(const char *key, const char *value,
144 struct bundle_list *list)
145{
146 struct strbuf id = STRBUF_INIT;
147 struct remote_bundle_info lookup = REMOTE_BUNDLE_INFO_INIT;
148 struct remote_bundle_info *bundle;
149 const char *subsection, *subkey;
150 size_t subsection_len;
151
152 if (parse_config_key(key, "bundle", &subsection, &subsection_len, &subkey))
153 return -1;
154
155 if (!subsection_len) {
156 if (!strcmp(subkey, "version")) {
157 int version;
158 if (!git_parse_int(value, &version))
159 return -1;
160 if (version != 1)
161 return -1;
162
163 list->version = version;
164 return 0;
165 }
166
167 if (!strcmp(subkey, "mode")) {
168 if (!strcmp(value, "all"))
169 list->mode = BUNDLE_MODE_ALL;
170 else if (!strcmp(value, "any"))
171 list->mode = BUNDLE_MODE_ANY;
172 else
173 return -1;
174 return 0;
175 }
176
177 if (!strcmp(subkey, "heuristic")) {
178 int i;
179 for (i = 0; i < BUNDLE_HEURISTIC__COUNT; i++) {
180 if (heuristics[i].heuristic &&
181 heuristics[i].name &&
182 !strcmp(value, heuristics[i].name)) {
183 list->heuristic = heuristics[i].heuristic;
184 return 0;
185 }
186 }
187
188 /* Ignore unknown heuristics. */
189 return 0;
190 }
191
192 /* Ignore other unknown global keys. */
193 return 0;
194 }
195
196 strbuf_add(&id, subsection, subsection_len);
197
198 /*
199 * Check for an existing bundle with this <id>, or create one
200 * if necessary.

Callers 2

config_to_bundle_listFunction · 0.85
bundle_uri_parse_lineFunction · 0.85

Calls 10

parse_config_keyFunction · 0.85
git_parse_intFunction · 0.85
strbuf_addFunction · 0.85
hashmap_entry_initFunction · 0.85
strhashFunction · 0.85
strbuf_detachFunction · 0.85
hashmap_addFunction · 0.85
strbuf_releaseFunction · 0.85
relative_urlFunction · 0.85
warningFunction · 0.85

Tested by

no test coverage detected