From: David Tardon Date: Fri, 17 Mar 2023 09:11:38 +0000 (+0100) Subject: systemctl: always print circular deps. at the end X-Git-Tag: v254-rc1~973^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=bb7c4a93ea1167b1294f86307d712d45655e9632;p=thirdparty%2Fsystemd.git systemctl: always print circular deps. at the end Before: a.target ○ └─b.target ├─... ● └─paths.target After: a.target ○ └─b.target ● ├─paths.target └─... --- diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c index 95949ab763a..1da5cf5075e 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); @@ -84,12 +85,7 @@ static int list_dependencies_one( UnitActiveState active_state; 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; } @@ -138,7 +134,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; @@ -149,6 +145,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);