summaryrefslogtreecommitdiff
path: root/src/merge.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-02-03 21:02:08 -0800
committerRussell Belfer <rb@github.com>2014-02-03 21:02:08 -0800
commit4075e060b45a73834a24684ed835d52f7176d58b (patch)
tree89c615474fec2a85c3e53edf699531a76c1e228f /src/merge.c
parent40e10630cfbdddd878a6347c1751092bab7f7a28 (diff)
downloadlibgit2-4075e060b45a73834a24684ed835d52f7176d58b.tar.gz
Replace pqueue with code from hashsig heap
I accidentally wrote a separate priority queue implementation when I was working on file rename detection as part of the file hash signature calculation code. To simplify licensing terms, I just adapted that to a general purpose priority queue and replace the old priority queue implementation that was borrowed from elsewhere. This also removes parts of the COPYING document that no longer apply to libgit2.
Diffstat (limited to 'src/merge.c')
-rw-r--r--src/merge.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/merge.c b/src/merge.c
index 20cfc0e23..d004554cf 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -161,10 +161,10 @@ on_error:
static int interesting(git_pqueue *list)
{
- unsigned int i;
- /* element 0 isn't used - we need to start at 1 */
- for (i = 1; i < list->size; i++) {
- git_commit_list_node *commit = list->d[i];
+ size_t i;
+
+ for (i = 0; i < git_pqueue_size(list); i++) {
+ git_commit_list_node *commit = git_pqueue_get(list, i);
if ((commit->flags & STALE) == 0)
return 1;
}
@@ -186,7 +186,7 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
return git_commit_list_insert(one, out) ? 0 : -1;
}
- if (git_pqueue_init(&list, twos->length * 2, git_commit_list_time_cmp) < 0)
+ if (git_pqueue_init(&list, 0, twos->length * 2, git_commit_list_time_cmp) < 0)
return -1;
if (git_commit_list_parse(walk, one) < 0)
@@ -205,10 +205,11 @@ int git_merge__bases_many(git_commit_list **out, git_revwalk *walk, git_commit_l
/* as long as there are non-STALE commits */
while (interesting(&list)) {
- git_commit_list_node *commit;
+ git_commit_list_node *commit = git_pqueue_pop(&list);
int flags;
- commit = git_pqueue_pop(&list);
+ if (commit == NULL)
+ break;
flags = commit->flags & (PARENT1 | PARENT2 | STALE);
if (flags == (PARENT1 | PARENT2)) {