mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-23 11:19:09 +00:00
Merge pull request #1791 from libgit2/cmn/revwalk-recursive
revwalk: make mark_unintersting use a loop
This commit is contained in:
commit
32e4992972
@ -63,6 +63,8 @@ GIT_INLINE(void *) git_array_grow(void *_a, size_t item_size)
|
|||||||
|
|
||||||
#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL)
|
#define git_array_last(a) ((a).size ? &(a).ptr[(a).size - 1] : NULL)
|
||||||
|
|
||||||
|
#define git_array_pop(a) ((a).size ? &(a).ptr[--(a).size] : NULL)
|
||||||
|
|
||||||
#define git_array_get(a, i) (((i) < (a).size) ? &(a).ptr[(i)] : NULL)
|
#define git_array_get(a, i) (((i) < (a).size) ? &(a).ptr[(i)] : NULL)
|
||||||
|
|
||||||
#define git_array_size(a) (a).size
|
#define git_array_size(a) (a).size
|
||||||
|
@ -41,28 +41,50 @@ git_commit_list_node *git_revwalk__commit_lookup(
|
|||||||
return commit;
|
return commit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_uninteresting(git_commit_list_node *commit)
|
static int mark_uninteresting(git_commit_list_node *commit)
|
||||||
{
|
{
|
||||||
unsigned short i;
|
unsigned short i;
|
||||||
|
git_array_t(git_commit_list_node *) pending = GIT_ARRAY_INIT;
|
||||||
|
git_commit_list_node **tmp;
|
||||||
|
|
||||||
assert(commit);
|
assert(commit);
|
||||||
|
|
||||||
|
git_array_alloc(pending);
|
||||||
|
GITERR_CHECK_ARRAY(pending);
|
||||||
|
|
||||||
|
do {
|
||||||
commit->uninteresting = 1;
|
commit->uninteresting = 1;
|
||||||
|
|
||||||
/* This means we've reached a merge base, so there's no need to walk any more */
|
/* This means we've reached a merge base, so there's no need to walk any more */
|
||||||
if ((commit->flags & (RESULT | STALE)) == RESULT)
|
if ((commit->flags & (RESULT | STALE)) == RESULT) {
|
||||||
return;
|
tmp = git_array_pop(pending);
|
||||||
|
commit = tmp ? *tmp : NULL;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < commit->out_degree; ++i)
|
for (i = 0; i < commit->out_degree; ++i)
|
||||||
if (!commit->parents[i]->uninteresting)
|
if (!commit->parents[i]->uninteresting) {
|
||||||
mark_uninteresting(commit->parents[i]);
|
git_commit_list_node **node = git_array_alloc(pending);
|
||||||
|
GITERR_CHECK_ALLOC(node);
|
||||||
|
*node = commit->parents[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = git_array_pop(pending);
|
||||||
|
commit = tmp ? *tmp : NULL;
|
||||||
|
|
||||||
|
} while (git_array_size(pending) > 0);
|
||||||
|
|
||||||
|
git_array_clear(pending);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int hide)
|
static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int hide)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (hide)
|
if (hide && mark_uninteresting(commit) < 0)
|
||||||
mark_uninteresting(commit);
|
return -1;
|
||||||
|
|
||||||
if (commit->seen)
|
if (commit->seen)
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user