]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: Always print underline in the last row of the partition table
authorJonas Dreßler <verdre@v0yd.nl>
Sat, 6 Jun 2026 15:32:54 +0000 (17:32 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 21 Jun 2026 23:26:14 +0000 (00:26 +0100)
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>
src/repart/repart.c

index c7814798ad1e79de3660eb5a729aedbbfbebf4c3..6fc48754b18709b2afa247fb4a79d670b7fe1289 100644 (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,