From d8a17ef09b8d9fdeb7d22cbc926cbebf3d8a58c9 Mon Sep 17 00:00:00 2001 From: René Scharfe Date: Wed, 24 Dec 2025 18:03:14 +0100 Subject: revision: export commit_stack MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dynamic arrays of commit pointers are used in several places. Some of them use a custom struct to hold array, item count and capacity, others have them as separate variables linked by a common name part. Pick one succinct, clean implementation -- commit_stack -- and convert the different variants to it to reduce code duplication. Signed-off-by: René Scharfe Signed-off-by: Junio C Hamano --- commit.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'commit.h') diff --git a/commit.h b/commit.h index 5406dd2663..81e047f820 100644 --- a/commit.h +++ b/commit.h @@ -381,4 +381,14 @@ int parse_buffer_signed_by_header(const char *buffer, const struct git_hash_algo *algop); int add_header_signature(struct strbuf *buf, struct strbuf *sig, const struct git_hash_algo *algo); +struct commit_stack { + struct commit **items; + size_t nr, alloc; +}; +#define COMMIT_STACK_INIT { 0 } + +void commit_stack_push(struct commit_stack *, struct commit *); +struct commit *commit_stack_pop(struct commit_stack *); +void commit_stack_clear(struct commit_stack *); + #endif /* COMMIT_H */ -- cgit v1.2.3