table: Fix JSON name mangling breaking changes

In previous commits, we've changed the JSON name mangling logic. This,
of course, will cause breaking changes to occur on anything that relied
on the JSON mangling logic.

This commit fixes those breaking changes by manually forcing the JSON
name back to what it was before.
This commit is contained in:
Adrian Vovk
2024-07-17 14:15:44 -04:00
parent c4cb49eb34
commit c82dfaf7e2
3 changed files with 14 additions and 0 deletions
+5
View File
@@ -912,6 +912,11 @@ static int list_images(int argc, char *argv[], void *userdata) {
(void) table_hide_column_from_display(t, 8);
(void) table_hide_column_from_display(t, 10);
/* Starting in v257, these fields would be automatically formatted with underscores. However, this
* command was introduced in v256, so changing the field name would be a breaking change. */
(void) table_set_json_field_name(t, 8, "usage-exclusive");
(void) table_set_json_field_name(t, 10, "limit-exclusive");
for (;;) {
uint64_t crtime, mtime, usage, usage_exclusive, limit, limit_exclusive;
const char *class, *name, *type, *path;
+4
View File
@@ -3043,6 +3043,10 @@ static int context_dump_partitions(Context *context) {
if (!t)
return log_oom();
/* Starting in v257, these fields would be automatically formatted with underscores. This would have
* been a breaking change, so to avoid that let's hard-code their original names. */
table_set_json_field_name(t, 15, "drop-in_files");
if (!DEBUG_LOGGING) {
if (arg_json_format_flags & SD_JSON_FORMAT_OFF)
(void) table_set_display(t, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4,
+5
View File
@@ -470,6 +470,11 @@ static int context_show_version(Context *c, const char *version) {
(void) table_set_align_percent(t, table_get_cell(t, 0, 8), 100);
table_set_ersatz_string(t, TABLE_ERSATZ_DASH);
/* Starting in v257, these fields would be automatically formatted with underscores. This would have
* been a breaking change, so to avoid that let's hard-code their original names. */
(void) table_set_json_field_name(t, 7, "tries-done");
(void) table_set_json_field_name(t, 8, "tries-left");
/* Determine if the target will make use of partition/fs attributes for any of the transfers */
FOREACH_ARRAY(transfer, c->transfers, c->n_transfers) {
Transfer *tr = *transfer;