1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-10 01:17:44 +03:00

systemctl: always print circular deps. at the end

Before:
a.target
○ └─b.target
    ├─...
●   └─paths.target

After:
a.target
○ └─b.target
●   ├─paths.target
    └─...

(cherry picked from commit bb7c4a93ea)
(cherry picked from commit c86983c58a)
This commit is contained in:
David Tardon 2023-03-17 10:11:38 +01:00 committed by Zbigniew Jędrzejewski-Szmek
parent 0b058ee2bf
commit 8bf89dddac

View File

@ -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);