diff --git a/tests/meson.build b/tests/meson.build index f7721ce..e9d802f 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -19,6 +19,7 @@ tests = [ 'umpf-series-tag-continue', 'umpf-series-tag-rerere', 'umpf-series-tag-continue-flags', + 'umpf-series-tag-empty', 'umpf-format-patch', 'umpf-format-patch-bb', 'umpf-show', diff --git a/tests/series-empty-v2.ref b/tests/series-empty-v2.ref new file mode 100644 index 0000000..daa2dcd --- /dev/null +++ b/tests/series-empty-v2.ref @@ -0,0 +1,4 @@ +# umpf-base: base +# umpf-name: name +# umpf-version: name/20221209-2 +# umpf-end diff --git a/tests/umpf-series-tag-empty b/tests/umpf-series-tag-empty new file mode 100644 index 0000000..ab4bd17 --- /dev/null +++ b/tests/umpf-series-tag-empty @@ -0,0 +1,9 @@ +#!/bin/sh +# +# Test creating an umpf tag from a series file without any topics. +# + +umpf tag --version=2 --base=base --name=name --remote=origin + +git log --format=%B -n 1 | grep "^# umpf-" > series.tag +diff -u ${TEST_DIR}/series-empty-v2.ref series.tag diff --git a/umpf b/umpf index 656b6d0..1625b52 100755 --- a/umpf +++ b/umpf @@ -1283,6 +1283,7 @@ Upstream-Status: Inappropriate [autogenerated]" create_tag() { local args tagname parents tree topic + local -a topics if [ ! -e "${STATE}/tag" ]; then return @@ -1294,9 +1295,12 @@ create_tag() { fi tree="$(${GIT} log -1 --format="%T")" - for topic in $(<"${STATE}/topics"); do - parents="${parents} -p ${topic}" - done + if [ -e "${STATE}/topics" ]; then + mapfile -t topics < "${STATE}/topics" + for topic in "${topics[@]}"; do + parents="${parents} -p ${topic}" + done + fi commit=$(${GIT} commit-tree "${tree}" -p HEAD ${parents} -m "${tagname}" -F "${STATE}/series.next") if ${GIT} tag ${args} --cleanup=verbatim -F "${STATE}/series.next" "${tagname}" "${commit}" >&2; then