]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: update `total_nr' when adding an item to a todo list
authorAlban Gruin <alban.gruin@gmail.com>
Sun, 24 Nov 2019 17:43:28 +0000 (18:43 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 Nov 2019 03:24:48 +0000 (12:24 +0900)
`total_nr' is the total number of items, counting both done and todo,
that are in a todo list.  But unlike `nr', it was not updated when an
item was appended to the list.

This variable is mostly used by command prompts (ie. git-prompt.sh and
the like).  By forgetting to update it, the original code made it not
reflect the reality, but this flaw was masked by the code calling
unnecessarily read_populate_todo() again to update the variable to its
correct value.  At the end of this series, the unnecessary call will be
removed, and the inconsistency addressed by this patch would start to
matter.

Signed-off-by: Alban Gruin <alban.gruin@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c

index d648aaf416510e656a372abe54d1a28d995de889..575b852a5a8f39d0e304bd3d0fa0703b1aa9a1bd 100644 (file)
@@ -2070,6 +2070,7 @@ void todo_list_release(struct todo_list *todo_list)
 static struct todo_item *append_new_todo(struct todo_list *todo_list)
 {
        ALLOC_GROW(todo_list->items, todo_list->nr + 1, todo_list->alloc);
+       todo_list->total_nr++;
        return todo_list->items + todo_list->nr++;
 }