commit-reach: reduce requirements for remove_redundant()

Remove a comment at the beggining of remove_redundant() that mentions a reordering of the input array to have the initial segment be the independent commits and the final segment be the redundant commits. While this behavior is followed in remove_redundant(), no callers rely on that behavior. Remove the final loop that copies this final segment and update the comment to match the new behavior. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Derrick Stolee committed Feb 1, 2021 at 12:47 UTC 0fac15652322e607ef3cb9f59e46ca2b168e933a
1 file changed +4 -6
commit-reach.c
+4 -6
@@ -160,9 +160,10 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt
160 {
161 /*
162 * Some commit in the array may be an ancestor of
163 - * another commit. Move such commit to the end of
164 - * the array, and return the number of commits that
165 - * are independent from each other.
163 + * another commit. Move the independent commits to the
164 + * beginning of 'array' and return their number. Callers
165 + * should not rely upon the contents of 'array' after
166 + * that number.
167 */
168 struct commit **work;
169 unsigned char *redundant;
@@ -209,9 +210,6 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt
210 for (i = filled = 0; i < cnt; i++)
211 if (!redundant[i])
212 array[filled++] = work[i];
212 - for (j = filled, i = 0; i < cnt; i++)
213 - if (redundant[i])
214 - array[j++] = work[i];
213 free(work);
214 free(redundant);
215 free(filled_index);