diff options
Diffstat (limited to 'commit.c')
| -rw-r--r-- | commit.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -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); +} |
