Revision cc8d872e691c9a0cda5a0b08e1c7e92acb6b7ebe authored by Johannes Schindelin on 14 June 2019, 12:16:08 UTC, committed by Junio C Hamano on 14 June 2019, 19:30:23 UTC
This one slipped through the review of a9279c678588 (sequencer: do not
squash 'reword' commits when we hit conflicts, 2018-06-19).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a9279c6
Raw File
oidset.c
#include "cache.h"
#include "oidset.h"

int oidset_contains(const struct oidset *set, const struct object_id *oid)
{
	if (!set->map.map.tablesize)
		return 0;
	return !!oidmap_get(&set->map, oid);
}

int oidset_insert(struct oidset *set, const struct object_id *oid)
{
	struct oidmap_entry *entry;

	if (!set->map.map.tablesize)
		oidmap_init(&set->map, 0);
	else if (oidset_contains(set, oid))
		return 1;

	entry = xmalloc(sizeof(*entry));
	oidcpy(&entry->oid, oid);

	oidmap_put(&set->map, entry);
	return 0;
}

int oidset_remove(struct oidset *set, const struct object_id *oid)
{
	struct oidmap_entry *entry;

	entry = oidmap_remove(&set->map, oid);
	free(entry);

	return (entry != NULL);
}

void oidset_clear(struct oidset *set)
{
	oidmap_free(&set->map, 1);
}
back to top