static void setup_reference(void) { int required = 1; for_each_string_list(&option_required_reference, add_one_reference, &required); required = 0; for_each_string_list(&option_optional_reference, add_one_reference, &required); }
int combine_notes_cat_sort_uniq(struct object_id *cur_oid, const struct object_id *new_oid) { struct string_list sort_uniq_list = STRING_LIST_INIT_DUP; struct strbuf buf = STRBUF_INIT; int ret = 1; /* read both note blob objects into unique_lines */ if (string_list_add_note_lines(&sort_uniq_list, cur_oid)) goto out; if (string_list_add_note_lines(&sort_uniq_list, new_oid)) goto out; string_list_remove_empty_items(&sort_uniq_list, 0); string_list_sort(&sort_uniq_list); string_list_remove_duplicates(&sort_uniq_list, 0); /* create a new blob object from sort_uniq_list */ if (for_each_string_list(&sort_uniq_list, string_list_join_lines_helper, &buf)) goto out; ret = write_object_file(buf.buf, buf.len, blob_type, cur_oid); out: strbuf_release(&buf); string_list_clear(&sort_uniq_list, 0); return ret; }
int combine_notes_cat_sort_uniq(unsigned char *cur_sha1, const unsigned char *new_sha1) { struct string_list sort_uniq_list = { NULL, 0, 0, 1 }; struct strbuf buf = STRBUF_INIT; int ret = 1; /* read both note blob objects into unique_lines */ if (string_list_add_note_lines(&sort_uniq_list, cur_sha1)) goto out; if (string_list_add_note_lines(&sort_uniq_list, new_sha1)) goto out; /* create a new blob object from sort_uniq_list */ if (for_each_string_list(&sort_uniq_list, string_list_join_lines_helper, &buf)) goto out; ret = write_sha1_file(buf.buf, buf.len, blob_type, cur_sha1); out: strbuf_release(&buf); string_list_clear(&sort_uniq_list, 0); return ret; }
static void add_repack_all_option(struct string_list *keep_pack) { if (prune_expire && !strcmp(prune_expire, "now")) argv_array_push(&repack, "-a"); else { argv_array_push(&repack, "-A"); if (prune_expire) argv_array_pushf(&repack, "--unpack-unreachable=%s", prune_expire); } if (keep_pack) for_each_string_list(keep_pack, keep_one_pack, NULL); }
static void setup_reference(void) { for_each_string_list(&option_reference, add_one_reference, NULL); }
static void find_non_local_tags(struct transport *transport, struct ref **head, struct ref ***tail) { struct string_list existing_refs = { NULL, 0, 0, 0 }; struct string_list remote_refs = { NULL, 0, 0, 0 }; struct tag_data data = {head, tail}; const struct ref *ref; struct string_list_item *item = NULL; for_each_ref(add_existing, &existing_refs); for (ref = transport_get_remote_refs(transport); ref; ref = ref->next) { if (prefixcmp(ref->name, "refs/tags")) continue; /* * The peeled ref always follows the matching base * ref, so if we see a peeled ref that we don't want * to fetch then we can mark the ref entry in the list * as one to ignore by setting util to NULL. */ if (!suffixcmp(ref->name, "^{}")) { if (item && !has_sha1_file(ref->old_sha1) && !will_fetch(head, ref->old_sha1) && !has_sha1_file(item->util) && !will_fetch(head, item->util)) item->util = NULL; item = NULL; continue; } /* * If item is non-NULL here, then we previously saw a * ref not followed by a peeled reference, so we need * to check if it is a lightweight tag that we want to * fetch. */ if (item && !has_sha1_file(item->util) && !will_fetch(head, item->util)) item->util = NULL; item = NULL; /* skip duplicates and refs that we already have */ if (string_list_has_string(&remote_refs, ref->name) || string_list_has_string(&existing_refs, ref->name)) continue; item = string_list_insert(ref->name, &remote_refs); item->util = (void *)ref->old_sha1; } string_list_clear(&existing_refs, 0); /* * We may have a final lightweight tag that needs to be * checked to see if it needs fetching. */ if (item && !has_sha1_file(item->util) && !will_fetch(head, item->util)) item->util = NULL; /* * For all the tags in the remote_refs string list, call * add_to_tail to add them to the list of refs to be fetched */ for_each_string_list(add_to_tail, &remote_refs, &data); string_list_clear(&remote_refs, 0); }
void resolve_undo_write(struct strbuf *sb, struct string_list *resolve_undo) { for_each_string_list(resolve_undo, write_one, sb); }
static void show_ru_info(const char *prefix) { if (!the_index.resolve_undo) return; for_each_string_list(show_one_ru, the_index.resolve_undo, NULL); }
static void show_ru_info(void) { if (!the_index.resolve_undo) return; for_each_string_list(the_index.resolve_undo, show_one_ru, NULL); }