From: Jonas Dreßler Date: Sat, 6 Jun 2026 15:32:54 +0000 (+0200) Subject: repart: Always print underline in the last row of the partition table X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc74f8bf3649115c372d2b48cbab3c710db751d0;p=thirdparty%2Fsystemd.git 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 --- diff --git a/src/repart/repart.c b/src/repart/repart.c index c7814798ad1..6fc48754b18 100644 --- a/src/repart/repart.c +++ b/src/repart/repart.c @@ -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,