}
}
+static int non_matching_ref(struct string_list_item *item, void *unused)
+{
+ if (item->util) {
+ item->util = NULL;
+ return 0;
+ }
+ else
+ return 1;
+}
+
static void filter_refs(struct ref **refs, struct string_list *sought)
{
struct ref **return_refs;
break;
else if (cmp == 0) { /* definitely have it */
return_refs[sought_pos] = ref;
- sought->items[sought_pos++].string[0] = '\0';
+ sought->items[sought_pos++].util = "matched";
break;
}
else /* might have it; keep looking */
}
if (return_refs != fastarray)
free(return_refs);
+ filter_string_list(sought, 0, non_matching_ref, NULL);
}
*refs = newlist;
}
* Otherwise, 'git fetch remote no-such-ref' would
* silently succeed without issuing an error.
*/
- for (i = 0; i < sought.nr; i++) {
- char *s = sought.items[i].string;
- if (s && s[0]) {
- error("no such remote ref %s", s);
- ret = 1;
- }
- }
+ for (i = 0; i < sought.nr; i++)
+ error("no such remote ref %s", sought.items[i].string);
+ ret = 1;
}
while (ref) {
printf("%s %s\n",
stateless_rpc:1;
};
+/*
+ * sought contains the full names of remote references that should be
+ * updated from. On return, the names that were found on the remote
+ * will have been removed from the list. The util members of the
+ * string_list_items are used internally; they must be NULL on entry
+ * (and will be NULL on exit).
+ */
struct ref *fetch_pack(struct fetch_pack_args *args,
int fd[], struct child_process *conn,
const struct ref *ref,
int nr_heads, struct ref **to_fetch)
{
struct git_transport_data *data = transport->data;
- struct string_list orig_sought = STRING_LIST_INIT_DUP;
- struct string_list sought = STRING_LIST_INIT_NODUP;
+ struct string_list sought = STRING_LIST_INIT_DUP;
const struct ref *refs;
char *dest = xstrdup(transport->url);
struct fetch_pack_args args;
args.no_progress = !transport->progress;
args.depth = data->options.depth;
- for (i = 0; i < nr_heads; i++) {
- string_list_append(&orig_sought, to_fetch[i]->name);
- string_list_append(&sought, orig_sought.items[orig_sought.nr - 1].string);
- }
+ for (i = 0; i < nr_heads; i++)
+ string_list_append(&sought, to_fetch[i]->name);
if (!data->got_remote_heads) {
connect_setup(transport, 0, 0);
free_refs(refs_tmp);
string_list_clear(&sought, 0);
- string_list_clear(&orig_sought, 0);
free(dest);
return (refs ? 0 : -1);
}