From 90952e68c8223e59f7b7237b09a8068982bfe82f Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Tue, 25 Jul 2023 16:09:20 +0200
Subject: [PATCH 1/2] umpf: Fix topicless tag creation
Calling umpf tag on an useries without topics aborts with the following
error message before creating the final octopus commit and the tags:
/usr/bin/umpf: line 1129: .git/umpf/topics: No such file or directory
Fix this by allowing an empty topic list (or non-existent
.git/umpf/topics state) during umpf tag.
Signed-off-by: Philipp Zabel
---
umpf | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/umpf b/umpf
index c7b5001..08efca4 100755
--- a/umpf
+++ b/umpf
@@ -1279,6 +1279,7 @@ Upstream-Status: Inappropriate [autogenerated]"
create_tag() {
local args tagname parents tree topic
+ local -a topics
if [ ! -e "${STATE}/tag" ]; then
return
@@ -1290,9 +1291,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
From fc0584583b15720458587e4832bede5ba7eff1dc Mon Sep 17 00:00:00 2001
From: Philipp Zabel
Date: Fri, 5 Jul 2024 12:59:56 +0200
Subject: [PATCH 2/2] tests: test creating a topicless tag
Creating a versioned tag should not fail, even if the series does not
contain any topic branches.
Signed-off-by: Philipp Zabel
---
tests/meson.build | 1 +
tests/series-empty-v2.ref | 4 ++++
tests/umpf-series-tag-empty | 9 +++++++++
3 files changed, 14 insertions(+)
create mode 100644 tests/series-empty-v2.ref
create mode 100644 tests/umpf-series-tag-empty
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