test-prune: Read to the end of cut(1) output
authorSimon McVittie <smcv@debian.org>
Mon, 7 Mar 2022 19:52:25 +0000 (19:52 +0000)
committerSimon McVittie <smcv@collabora.com>
Mon, 7 Mar 2022 23:03:33 +0000 (23:03 +0000)
If we use head(1) to take only the first two lines, then cut(1) and
earlier pipeline entries are killed by SIGPIPE (if they have not already
terminated), and that's flagged as an error under `set -o pipefail`.
Use an equivalent sed command to take exactly the second line, but
without SIGPIPE.

Signed-off-by: Simon McVittie <smcv@debian.org>
Gbp-Pq: Name test-prune-Read-to-the-end-of-cut-1-output.patch

tests/test-prune.sh

index 20904f31b339025466ec48980e99eb184c3d56ad..bbb77a23de8b5d69b3efead9321426054d925d4d 100755 (executable)
@@ -350,7 +350,7 @@ tap_ok --commit-only and --delete-commit
 # Test --delete-commit when it creates orphaned commits
 reinitialize_commit_only_test_repo
 # get the current HEAD's parent on dev branch
-COMMIT_TO_DELETE=$(${CMD_PREFIX} ostree --repo=repo log dev | grep ^commit | cut -f 2 -d' ' | head -n 2 | tail -n 1)
+COMMIT_TO_DELETE=$(${CMD_PREFIX} ostree --repo=repo log dev | grep ^commit | cut -f 2 -d' ' | sed -ne '2p')
 ${CMD_PREFIX} ostree --repo=repo prune --commit-only --refs-only --delete-commit=$COMMIT_TO_DELETE
 # we deleted a commit that orphaned another, so we lose two commits
 assert_repo_has_n_commits repo 4