From 93dbc07b4ccc0d06ed3a546a44bb9131b86d267f Mon Sep 17 00:00:00 2001
From: Ryan Gonzalez <ryan.gonzalez@collabora.com>
Date: Fri, 26 Aug 2022 09:24:39 -0500
Subject: [PATCH] Preserve trailing newlines during rebase

Bash likes to remove these, which meant the metadata that went inside
the new commit didn't actually match the file it was read from.

https://gitlab.apertis.org/infrastructure/apertis-issues/-/issues/170

Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
---
 generate_pipeline.py                          |  7 +-
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 42 ++++++++--
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 42 ++++++++--
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 42 ++++++++--
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 42 ++++++++--
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 42 ++++++++--
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 42 ++++++++--
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 42 ++++++++--
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 42 ++++++++--
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 42 ++++++++--
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 42 ++++++++--
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 42 ++++++++--
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 42 ++++++++--
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 84 ++++++++++++++++---
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 84 ++++++++++++++++---
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 84 ++++++++++++++++---
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 84 ++++++++++++++++---
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 84 ++++++++++++++++---
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 84 ++++++++++++++++---
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 84 ++++++++++++++++---
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 84 ++++++++++++++++---
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 84 ++++++++++++++++---
 ...h_flatpakrepo.deps_sign_none.approved.yaml | 84 ++++++++++++++++---
 ...latpakrepo.deps_sign_ed25519.approved.yaml | 84 ++++++++++++++++---
 ...ut_flatpakrepo.deps_sign_gpg.approved.yaml | 84 ++++++++++++++++---
 tests/test_build_pipelines.py                 | 13 ++-
 26 files changed, 1311 insertions(+), 221 deletions(-)

diff --git a/generate_pipeline.py b/generate_pipeline.py
index 7a092d5..b477bdc 100755
--- a/generate_pipeline.py
+++ b/generate_pipeline.py
@@ -79,7 +79,12 @@ for ref in $refs; do
             message=$(ostree show "$prev" \\
                         | grep '^ ' \\
                         | sed 's/^ *//g')
-            metadata=$(ostree cat "$prev" metadata)
+
+            # Trick to preserve any trailing newlines:
+            # https://unix.stackexchange.com/a/383411/117660
+            # (The '|| :' at the end is because read always returns an exit code of 1 in
+            # this case: https://stackoverflow.com/a/67066283/2097780)
+            IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
             echo 'Applying new changes on top of remote...'
             ostree commit -b "$ref" -m "$message" \\
diff --git a/tests/approved_files/test_approval.test_apps.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_apps.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index b1b05df..d401386 100644
--- a/tests/approved_files/test_approval.test_apps.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -406,7 +411,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -487,7 +497,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -568,7 +583,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -649,7 +669,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -730,7 +755,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index a519b33..0fb1793 100644
--- a/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -405,7 +410,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -485,7 +495,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -565,7 +580,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -645,7 +665,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -725,7 +750,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index ce01a9f..e4423f6 100644
--- a/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -192,7 +192,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -272,7 +277,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -352,7 +362,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -432,7 +447,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -512,7 +532,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -592,7 +617,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_apps.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index dfd2255..b5d34eb 100644
--- a/tests/approved_files/test_approval.test_apps.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -406,7 +411,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -487,7 +497,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -568,7 +583,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -649,7 +669,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -730,7 +755,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index 34d70f3..d22f421 100644
--- a/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -405,7 +410,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -485,7 +495,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -565,7 +580,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -645,7 +665,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -725,7 +750,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index 933414e..4181f3e 100644
--- a/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -192,7 +192,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -272,7 +277,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -352,7 +362,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -432,7 +447,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -512,7 +532,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -592,7 +617,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_apps.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index a1daab1..ca1f49a 100644
--- a/tests/approved_files/test_approval.test_apps.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -406,7 +411,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -487,7 +497,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -568,7 +583,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -649,7 +669,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -730,7 +755,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index 00ebfe1..08c26db 100644
--- a/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -405,7 +410,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -485,7 +495,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -565,7 +580,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -645,7 +665,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -725,7 +750,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index 86e2c3f..2efb65e 100644
--- a/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -192,7 +192,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -272,7 +277,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -352,7 +362,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -432,7 +447,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -512,7 +532,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -592,7 +617,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_apps.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index c928a44..0f2a990 100644
--- a/tests/approved_files/test_approval.test_apps.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -406,7 +411,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -487,7 +497,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -568,7 +583,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -649,7 +669,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -730,7 +755,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index 1c3e58b..dd4456b 100644
--- a/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -325,7 +325,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -405,7 +410,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -485,7 +495,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -565,7 +580,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -645,7 +665,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -725,7 +750,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index aa84756..e23c9a8 100644
--- a/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_apps.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -192,7 +192,12 @@ publish app org.test.Test-1 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -272,7 +277,12 @@ publish app org.test.Test-1 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -352,7 +362,12 @@ publish app org.test.Test-1 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -432,7 +447,12 @@ publish app org.test.Test-2 (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -512,7 +532,12 @@ publish app org.test.Test-2 (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -592,7 +617,12 @@ publish app org.test.Test-2 (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_runtimes.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index a763b3b..5829223 100644
--- a/tests/approved_files/test_approval.test_runtimes.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.main.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -570,7 +570,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -651,7 +656,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -732,7 +742,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -813,7 +828,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -897,7 +917,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -981,7 +1006,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1065,7 +1095,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1149,7 +1184,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1233,7 +1273,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1317,7 +1362,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1401,7 +1451,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1485,7 +1540,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index 03fa67b..94f5545 100644
--- a/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -558,7 +558,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -638,7 +643,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -718,7 +728,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -798,7 +813,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -881,7 +901,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -964,7 +989,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1047,7 +1077,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1130,7 +1165,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1213,7 +1253,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1296,7 +1341,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1379,7 +1429,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1462,7 +1517,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index 8ad2488..51787e0 100644
--- a/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.main.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -371,7 +371,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -451,7 +456,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -531,7 +541,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -611,7 +626,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -691,7 +711,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -771,7 +796,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -851,7 +881,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -931,7 +966,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1011,7 +1051,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1091,7 +1136,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1171,7 +1221,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1251,7 +1306,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_runtimes.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index 4616a09..74d46f5 100644
--- a/tests/approved_files/test_approval.test_runtimes.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.main.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -570,7 +570,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -651,7 +656,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -732,7 +742,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -813,7 +828,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -897,7 +917,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -981,7 +1006,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1065,7 +1095,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1149,7 +1184,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1233,7 +1273,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1317,7 +1362,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1401,7 +1451,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1485,7 +1540,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index 27f9273..899c5c3 100644
--- a/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -558,7 +558,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -638,7 +643,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -718,7 +728,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -798,7 +813,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -881,7 +901,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -964,7 +989,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1047,7 +1077,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1130,7 +1165,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1213,7 +1253,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1296,7 +1341,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1379,7 +1429,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1462,7 +1517,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index 637db65..5284bf1 100644
--- a/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.main.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -371,7 +371,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -451,7 +456,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -531,7 +541,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -611,7 +626,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -691,7 +711,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -771,7 +796,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -851,7 +881,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -931,7 +966,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1011,7 +1051,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1091,7 +1136,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1171,7 +1221,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1251,7 +1306,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_runtimes.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index 5d9787c..6ffbe69 100644
--- a/tests/approved_files/test_approval.test_runtimes.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.test.main_only.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -564,7 +564,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -645,7 +650,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -726,7 +736,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -807,7 +822,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -891,7 +911,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -975,7 +1000,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1059,7 +1089,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1143,7 +1178,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1227,7 +1267,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1311,7 +1356,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1395,7 +1445,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1479,7 +1534,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index f99e49b..35c649e 100644
--- a/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -552,7 +552,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -632,7 +637,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -712,7 +722,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -792,7 +807,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -875,7 +895,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -958,7 +983,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1041,7 +1071,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1124,7 +1159,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1207,7 +1247,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1290,7 +1335,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1373,7 +1423,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1456,7 +1511,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index b59a74b..06cede6 100644
--- a/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.test.main_only.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -365,7 +365,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -445,7 +450,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -525,7 +535,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -605,7 +620,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -685,7 +705,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -765,7 +790,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -845,7 +875,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -925,7 +960,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1005,7 +1045,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1085,7 +1130,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1165,7 +1215,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1245,7 +1300,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml b/tests/approved_files/test_approval.test_runtimes.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
index 22f273d..ea35c76 100644
--- a/tests/approved_files/test_approval.test_runtimes.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.test.versioned.with_sign.with_tests.with_flatpakrepo.deps_sign_none.approved.yaml
@@ -570,7 +570,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -651,7 +656,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -732,7 +742,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -813,7 +828,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -897,7 +917,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -981,7 +1006,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1065,7 +1095,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1149,7 +1184,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1233,7 +1273,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1317,7 +1362,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1401,7 +1451,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1485,7 +1540,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml b/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
index e2ff1b2..a8f2dca 100644
--- a/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.with_tests.with_flatpakrepo.deps_sign_ed25519.approved.yaml
@@ -558,7 +558,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -638,7 +643,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -718,7 +728,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -798,7 +813,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -881,7 +901,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -964,7 +989,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1047,7 +1077,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1130,7 +1165,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1213,7 +1253,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1296,7 +1341,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1379,7 +1429,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1462,7 +1517,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml b/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
index edb3119..263daa0 100644
--- a/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
+++ b/tests/approved_files/test_approval.test_runtimes.test.versioned.without_sign.without_tests.without_flatpakrepo.deps_sign_gpg.approved.yaml
@@ -371,7 +371,12 @@ publish runtime org.test.bar (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -451,7 +456,12 @@ publish runtime org.test.bar (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -531,7 +541,12 @@ publish runtime org.test.bar (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -611,7 +626,12 @@ publish runtime org.test.foo (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -691,7 +711,12 @@ publish runtime org.test.foo (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -771,7 +796,12 @@ publish runtime org.test.foo (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -851,7 +881,12 @@ publish app org.test.foo.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -931,7 +966,12 @@ publish app org.test.foo.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1011,7 +1051,12 @@ publish app org.test.foo.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1091,7 +1136,12 @@ publish app org.test.bar.Test (x86_64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1171,7 +1221,12 @@ publish app org.test.bar.Test (aarch64):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
@@ -1251,7 +1306,12 @@ publish app org.test.bar.Test (arm):
                   message=$(ostree show "$prev" \
                               | grep '^ ' \
                               | sed 's/^ *//g')
-                  metadata=$(ostree cat "$prev" metadata)
+
+                  # Trick to preserve any trailing newlines:
+                  # https://unix.stackexchange.com/a/383411/117660
+                  # (The '|| :' at the end is because read always returns an exit code of 1 in
+                  # this case: https://stackoverflow.com/a/67066283/2097780)
+                  IFS= read -rd '' metadata < <(ostree cat "$prev" metadata) || :
 
                   echo 'Applying new changes on top of remote...'
                   ostree commit -b "$ref" -m "$message" \
diff --git a/tests/test_build_pipelines.py b/tests/test_build_pipelines.py
index 85ba50c..7e48653 100644
--- a/tests/test_build_pipelines.py
+++ b/tests/test_build_pipelines.py
@@ -496,10 +496,6 @@ def test_subsummaries_flatpak_metadata(subsummaries):
         refs, _meta = subsummary
 
         for ref, (_commit_size, _commit_checksum, ref_metadata) in refs:
-            flatpak_metadata = ref_metadata['xa.data'][2]
-            keyfile = GLib.KeyFile.new()
-            keyfile.load_from_bytes(GLib.Bytes.new(flatpak_metadata.encode('ascii')), 0)
-
             if ref.startswith('runtime/'):
                 group = 'Runtime'
             elif ref.startswith('app/'):
@@ -509,6 +505,15 @@ def test_subsummaries_flatpak_metadata(subsummaries):
             else:
                 assert False, ref
 
+            flatpak_metadata = ref_metadata['xa.data'][2]
+
+            # The metadata file should have a single trailing newline.
+            assert flatpak_metadata.endswith('\n'), ref
+            assert not flatpak_metadata.endswith('\n\n'), ref
+
+            keyfile = GLib.KeyFile.new()
+            keyfile.load_from_bytes(GLib.Bytes.new(flatpak_metadata.encode('ascii')), 0)
+
             ref_id = ref.split('/')[1]
             id_from_metadata = keyfile.get_string(group, 'name')
             assert ref_id == id_from_metadata
-- 
GitLab