Skip to content

Commit 0fac156

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5a3b130 commit 0fac156

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

commit-reach.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt
160160
{
161161
/*
162162
* 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.
166167
*/
167168
struct commit **work;
168169
unsigned char *redundant;
@@ -209,9 +210,6 @@ static int remove_redundant(struct repository *r, struct commit **array, int cnt
209210
for (i = filled = 0; i < cnt; i++)
210211
if (!redundant[i])
211212
array[filled++] = work[i];
212-
for (j = filled, i = 0; i < cnt; i++)
213-
if (redundant[i])
214-
array[j++] = work[i];
215213
free(work);
216214
free(redundant);
217215
free(filled_index);

0 commit comments

Comments
 (0)