mirror of
https://github.com/git/git.git
synced 2026-02-26 01:43:43 +00:00
Merge branch 'rs/commit-stack'
Code clean-up, unifying various hand-rolled "list of commit objects" and use the commit_stack API. * rs/commit-stack: commit-reach: use commit_stack commit-graph: use commit_stack commit: add commit_stack_grow() shallow: use commit_stack pack-bitmap-write: use commit_stack commit: add commit_stack_init() test-reach: use commit_stack remote: use commit_stack for src_commits remote: use commit_stack for sent_tips remote: use commit_stack for local_commits name-rev: use commit_stack midx: use commit_stack log: use commit_stack revision: export commit_stack
This commit is contained in:
28
commit.c
28
commit.c
@@ -1984,3 +1984,31 @@ int run_commit_hook(int editor_is_used, const char *index_file,
|
||||
opt.invoked_hook = invoked_hook;
|
||||
return run_hooks_opt(the_repository, name, &opt);
|
||||
}
|
||||
|
||||
void commit_stack_init(struct commit_stack *stack)
|
||||
{
|
||||
stack->items = NULL;
|
||||
stack->nr = stack->alloc = 0;
|
||||
}
|
||||
|
||||
void commit_stack_grow(struct commit_stack *stack, size_t extra)
|
||||
{
|
||||
ALLOC_GROW(stack->items, st_add(stack->nr, extra), stack->alloc);
|
||||
}
|
||||
|
||||
void commit_stack_push(struct commit_stack *stack, struct commit *commit)
|
||||
{
|
||||
commit_stack_grow(stack, 1);
|
||||
stack->items[stack->nr++] = commit;
|
||||
}
|
||||
|
||||
struct commit *commit_stack_pop(struct commit_stack *stack)
|
||||
{
|
||||
return stack->nr ? stack->items[--stack->nr] : NULL;
|
||||
}
|
||||
|
||||
void commit_stack_clear(struct commit_stack *stack)
|
||||
{
|
||||
free(stack->items);
|
||||
commit_stack_init(stack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user