repart: Always print underline in the last row of the partition table

Claude found a small bug with the partition table we print: We filter out
partitions with p->dropped while making the table, but we want to put an
underline after the last row of the table. In the case where the last entry
in the context->partitions list is a dropped partition, the check for
!p->partitions_next returns FALSE when it actually *is* the last row in the
table.

So move to a check that's based on a pre-counted number of partitions to
print rather than checking for !p->partitions_next.

Co-developed-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Jonas Dreßler
2026-06-22 00:26:14 +01:00
committed by Luca Boccassi
parent a4f7c9589e
commit cc74f8bf36
+13 -2
View File
@@ -4325,6 +4325,15 @@ static int context_dump_partitions(Context *context) {
(void) table_set_align_percent(t, table_get_cell(t, 0, 11), 100);
(void) table_set_align_percent(t, table_get_cell(t, 0, 12), 100);
size_t n_partitions = 0;
LIST_FOREACH(partitions, p, context->partitions) {
if (p->dropped)
continue;
n_partitions++;
}
size_t cur_n_partition = 0;
LIST_FOREACH(partitions, p, context->partitions) {
_cleanup_free_ char *size_change = NULL, *padding_change = NULL, *partname = NULL, *rh = NULL;
char uuid_buffer[SD_ID128_UUID_STRING_MAX];
@@ -4333,6 +4342,8 @@ static int context_dump_partitions(Context *context) {
if (p->dropped)
continue;
cur_n_partition++;
if (p->current_size == UINT64_MAX)
activity = "create";
else if (p->current_size != p->new_size)
@@ -4373,10 +4384,10 @@ static int context_dump_partitions(Context *context) {
TABLE_UINT64, p->offset,
TABLE_UINT64, p->current_size == UINT64_MAX ? 0 : p->current_size,
TABLE_UINT64, p->new_size,
TABLE_STRING, size_change, TABLE_SET_COLOR, !p->partitions_next && sum_size > 0 ? ansi_underline() : NULL,
TABLE_STRING, size_change, TABLE_SET_COLOR, cur_n_partition == n_partitions && sum_size > 0 ? ansi_underline() : NULL,
TABLE_UINT64, p->current_padding == UINT64_MAX ? 0 : p->current_padding,
TABLE_UINT64, p->new_padding,
TABLE_STRING, padding_change, TABLE_SET_COLOR, !p->partitions_next && sum_padding > 0 ? ansi_underline() : NULL,
TABLE_STRING, padding_change, TABLE_SET_COLOR, cur_n_partition == n_partitions && sum_padding > 0 ? ansi_underline() : NULL,
TABLE_STRING, activity ?: "unchanged",
TABLE_STRING, rh,
TABLE_STRV, p->drop_in_files,