naccyde / rpms / systemd

Forked from rpms/systemd a year ago
Clone
2aacef
From 48455fa876129bf33df06d2e758fb0fbda510d5b Mon Sep 17 00:00:00 2001
2aacef
From: Yu Watanabe <watanabe.yu+github@gmail.com>
2aacef
Date: Wed, 16 Nov 2022 03:18:30 +0900
2aacef
Subject: [PATCH] core/unit: merge unit names after merging deps
2aacef
2aacef
Before:
2aacef
systemd[1]: issue-24990.service: Dependency Before=n/a dropped, merged into issue-24990.service
2aacef
After:
2aacef
systemd[1]: issue-24990.service: Dependency Before=test1.service dropped, merged into issue-24990.service
2aacef
2aacef
(cherry picked from commit 1d0c81a05b1605a5fc3db44d5a157a1d6876eda9)
2aacef
2aacef
Related: #2160477
2aacef
---
2aacef
 src/core/unit.c | 10 +++++-----
2aacef
 1 file changed, 5 insertions(+), 5 deletions(-)
2aacef
2aacef
diff --git a/src/core/unit.c b/src/core/unit.c
2aacef
index 6b49edc2de..d1929bbf69 100644
2aacef
--- a/src/core/unit.c
2aacef
+++ b/src/core/unit.c
2aacef
@@ -1164,11 +1164,6 @@ int unit_merge(Unit *u, Unit *other) {
2aacef
         if (r < 0)
2aacef
                 return r;
2aacef
 
2aacef
-        /* Merge names */
2aacef
-        r = unit_merge_names(u, other);
2aacef
-        if (r < 0)
2aacef
-                return r;
2aacef
-
2aacef
         /* Redirect all references */
2aacef
         while (other->refs_by_target)
2aacef
                 unit_ref_set(other->refs_by_target, other->refs_by_target->source, u);
2aacef
@@ -1176,6 +1171,11 @@ int unit_merge(Unit *u, Unit *other) {
2aacef
         /* Merge dependencies */
2aacef
         unit_merge_dependencies(u, other);
2aacef
 
2aacef
+        /* Merge names. It is better to do that after merging deps, otherwise the log message contains n/a. */
2aacef
+        r = unit_merge_names(u, other);
2aacef
+        if (r < 0)
2aacef
+                return r;
2aacef
+
2aacef
         other->load_state = UNIT_MERGED;
2aacef
         other->merged_into = u;
2aacef