From 8bf89dddac2f53932fca8e23f5ca5a7794e63556 Mon Sep 17 00:00:00 2001 From: David Tardon Date: Fri, 17 Mar 2023 10:11:38 +0100 Subject: [PATCH] systemctl: always print circular deps. at the end MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before: a.target ○ └─b.target ├─... ● └─paths.target After: a.target ○ └─b.target ● ├─paths.target └─... (cherry picked from commit bb7c4a93ea1167b1294f86307d712d45655e9632) (cherry picked from commit c86983c58a8ca57b15ef4d401262b64d4d27a254) --- src/systemctl/systemctl-list-dependencies.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c index c5be002005..25ce09cbd8 100644 --- a/src/systemctl/systemctl-list-dependencies.c +++ b/src/systemctl/systemctl-list-dependencies.c @@ -64,6 +64,7 @@ static int list_dependencies_one( _cleanup_strv_free_ char **deps = NULL; int r; + bool circular = false; assert(bus); assert(name); @@ -81,12 +82,7 @@ static int list_dependencies_one( STRV_FOREACH(c, deps) { if (strv_contains(*units, *c)) { - if (!arg_plain) { - printf(" "); - r = list_dependencies_print("...", level, branches, /* last = */ c[1] == NULL); - if (r < 0) - return r; - } + circular = true; continue; } @@ -118,7 +114,7 @@ static int list_dependencies_one( printf("%s%s%s ", on, special_glyph(unit_active_state_to_glyph(active_state)), ansi_normal()); } - r = list_dependencies_print(*c, level, branches, c[1] == NULL); + r = list_dependencies_print(*c, level, branches, /* last = */ c[1] == NULL && !circular); if (r < 0) return r; @@ -129,6 +125,13 @@ static int list_dependencies_one( } } + if (circular && !arg_plain) { + printf(" "); + r = list_dependencies_print("...", level, branches, /* last = */ true); + if (r < 0) + return r; + } + if (!arg_plain) strv_remove(*units, name);