mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-06 23:26:39 +00:00
Fixed topological sorting stuck in infinite loop.
Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
This commit is contained in:
parent
69dca95950
commit
1f798df229
14
src/commit.c
14
src/commit.c
@ -30,6 +30,12 @@
|
|||||||
#include "revwalk.h"
|
#include "revwalk.h"
|
||||||
#include "git/odb.h"
|
#include "git/odb.h"
|
||||||
|
|
||||||
|
#define COMMIT_PRINT(commit) {\
|
||||||
|
char oid[41]; oid[40] = 0;\
|
||||||
|
git_oid_fmt(oid, &commit->object.id);\
|
||||||
|
printf("Oid: %s | In degree: %d | Time: %u\n", oid, commit->in_degree, commit->commit_time);\
|
||||||
|
}
|
||||||
|
|
||||||
const git_oid *git_commit_id(git_commit *c)
|
const git_oid *git_commit_id(git_commit *c)
|
||||||
{
|
{
|
||||||
return &c->object.id;
|
return &c->object.id;
|
||||||
@ -256,7 +262,7 @@ void git_commit_list_push_front(git_commit_list *list, git_commit *commit)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
list->head->next = node;
|
list->head->prev = node;
|
||||||
list->head = node;
|
list->head = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +392,7 @@ void git_commit_list_toposort(git_commit_list *list)
|
|||||||
git_commit_list topo;
|
git_commit_list topo;
|
||||||
memset(&topo, 0x0, sizeof(git_commit_list));
|
memset(&topo, 0x0, sizeof(git_commit_list));
|
||||||
|
|
||||||
while ((commit = git_commit_list_pop_front(list)) != NULL)
|
while ((commit = git_commit_list_pop_back(list)) != NULL)
|
||||||
{
|
{
|
||||||
git_commit_node *p;
|
git_commit_node *p;
|
||||||
|
|
||||||
@ -403,11 +409,11 @@ void git_commit_list_toposort(git_commit_list *list)
|
|||||||
if (p->commit->in_degree == 0 && p->commit->topo_delay)
|
if (p->commit->in_degree == 0 && p->commit->topo_delay)
|
||||||
{
|
{
|
||||||
p->commit->topo_delay = 0;
|
p->commit->topo_delay = 0;
|
||||||
git_commit_list_push_front(list, p->commit);
|
git_commit_list_push_back(list, p->commit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
git_commit_list_push_back(&topo, commit);
|
git_commit_list_push_front(&topo, commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
list->head = topo.head;
|
list->head = topo.head;
|
||||||
|
Loading…
Reference in New Issue
Block a user