<commit_before>#include <stdlib.h>
#include "cache.h"
#include "commit.h"

static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2)
{
	struct commit_list *list = NULL;
	struct commit_list *result = NULL;

	if (rev1 == rev2)
		return rev1;

	parse_commit(rev1);
	parse_commit(rev2);

	rev1->object.flags |= 1;
	rev2->object.flags |= 2;
	insert_by_date(rev1, &list);
	insert_by_date(rev2, &list);

	while (list) {
		struct commit *commit = list->item;
		struct commit_list *tmp = list, *parents;
		int flags = commit->object.flags & 3;

		list = list->next;
		free(tmp);
		switch (flags) {
		case 3:
			insert_by_date(commit, &result);
			continue;
		case 0:
			die("git-merge-base: commit without either parent?");
		}
		parents = commit->parents;
		while (parents) {
			struct commit *p = parents->item;
			parents = parents->next;
			if ((p->object.flags & flags) == flags)<commit_msg>[PATCH] Speed up git-merge-base a lot<commit_after>#include <stdlib.h>
#include "cache.h"
#include "commit.h"

#define PARENT1 1
#define PARENT2 2
#define UNINTERESTING 4

static int interesting(struct commit_list *list)
{
	while (list) {
		struct commit *commit = list->item;
		list = list->next;
		if (commit->object.flags & UNINTERESTING)
			continue;
		return 1;
	}
	return 0;
}

static struct commit *common_ancestor(struct commit *rev1, struct commit *rev2)
{
	struct commit_list *list = NULL;
	struct commit_list *result = NULL;

	if (rev1 == rev2)
		return rev1;

	parse_commit(rev1);
	parse_commit(rev2);

	rev1->object.flags |= 1;
	rev2->object.flags |= 2;
	insert_by_date(rev1, &list);
	insert_by_date(rev2, &list);

	while (interesting(list)) {
		struct commit *commit = list->item;
		struct commit_list *tmp = list, *parents;
		int flags = commit->object.flags & 7;

		list = list->next;
		free(tmp);
		if (flags == 3) {
			insert_by_date(commit, &result);

			/* Mark children of a found merge uninteresting */
			flags |= UNINTERESTING;
		}
		parents = commit->parents;
		while (parents) {
			struct commit *p = parents->item;
			parents = parents->next;
			if ((p->object.flags & flags) == flags)
{'fraction_non_alphanumeric': 0.1419141914191419, 'fraction_numerical': 0.017916077322017915, 'mean_word_length': 4.004716981132075, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1244137', 'n_tokens_mistral': 837, 'n_tokens_neox': 751, 'n_words': 202}