Skip to content

Commit fa5103d

Browse files
dschogitster
authored andcommitted
rebase --update-refs: fix loops
The `total_nr` field in the `todo_list` structure merely serves display purposes, and should only be used when generating the progress message. In these two instances, however, we want to loop over all of the commands in the parsed rebase script. The loop limit therefore needs to be `nr`, which refers to the count of commands in the current `todo_list`. This is important because the two numbers, `nr` and `total_nr` can differ wildly, e.g. due to `total_nr` _not_ counting comments or empty lines, while `nr` skips any commands that already moved from the `git-rebase-todo` file to the `done` file. Signed-off-by: Johannes Schindelin <[email protected]> Acked-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ec58344 commit fa5103d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4205,7 +4205,7 @@ void todo_list_filter_update_refs(struct repository *r,
42054205
if (!is_null_oid(&rec->after))
42064206
continue;
42074207

4208-
for (j = 0; !found && j < todo_list->total_nr; j++) {
4208+
for (j = 0; !found && j < todo_list->nr; j++) {
42094209
struct todo_item *item = &todo_list->items[j];
42104210
const char *arg = todo_list->buf.buf + item->arg_offset;
42114211

@@ -4235,7 +4235,7 @@ void todo_list_filter_update_refs(struct repository *r,
42354235
* For each todo_item, check if its ref is in the update_refs list.
42364236
* If not, then add it as an un-updated ref.
42374237
*/
4238-
for (i = 0; i < todo_list->total_nr; i++) {
4238+
for (i = 0; i < todo_list->nr; i++) {
42394239
struct todo_item *item = &todo_list->items[i];
42404240
const char *arg = todo_list->buf.buf + item->arg_offset;
42414241
int j, found = 0;

0 commit comments

Comments
 (0)