commit: move clear_commit_marks_many() loop body to clear_commit_marks()

clear_commit_marks_many() clears multiple commits one by one.  Move the
code for handling a single commit to clear_commit_marks() and call it
instead of the other way around, to simplify the code.

Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2025-03-23 10:53:21 +01:00
committed by Junio C Hamano
parent 683c54c999
commit 98b423bc1c

View File

@@ -780,19 +780,17 @@ static void clear_commit_marks_1(struct commit_list **plist,
void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark) void clear_commit_marks_many(size_t nr, struct commit **commit, unsigned int mark)
{ {
for (size_t i = 0; i < nr; i++) { for (size_t i = 0; i < nr; i++)
struct commit_list *list = NULL; clear_commit_marks(commit[i], mark);
clear_commit_marks_1(&list, *commit, mark);
while (list)
clear_commit_marks_1(&list, pop_commit(&list), mark);
commit++;
}
} }
void clear_commit_marks(struct commit *commit, unsigned int mark) void clear_commit_marks(struct commit *commit, unsigned int mark)
{ {
clear_commit_marks_many(1, &commit, mark); struct commit_list *list = NULL;
clear_commit_marks_1(&list, commit, mark);
while (list)
clear_commit_marks_1(&list, pop_commit(&list), mark);
} }
struct commit *pop_commit(struct commit_list **stack) struct commit *pop_commit(struct commit_list **stack)