chiark / gitweb /
analyze: change behaviour of combined --to/from--pattern
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 13 Feb 2015 23:38:33 +0000 (18:38 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 16 Feb 2015 18:16:46 +0000 (13:16 -0500)
We would require a match against all three: patterns specified
with --to, with --from, and as positional arguments to show an
edge. This does not seem useful. Let instead the positional args
behave like they were specified in both --to and --from, which is
fairly intuitive and should be more useful.

man/systemd-analyze.xml
src/analyze/analyze.c

index 61315a0d89883d6c76bbe7507f6eea0e910694cb..1ff81d3d5a4dff91dbe8829ed12eaf2ea2591643 100644 (file)
 
         <listitem><para>When used in conjunction with the
         <command>dot</command> command (see above), this selects which
 
         <listitem><para>When used in conjunction with the
         <command>dot</command> command (see above), this selects which
-        relationships are shown in the dependency graph. They both
-        require
+        relationships are shown in the dependency graph. Both options
+        require a
         <citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>
         <citerefentry><refentrytitle>glob</refentrytitle><manvolnum>7</manvolnum></citerefentry>
-        patterns as arguments, which are matched against left-hand and
-        right-hand, respectively, nodes of a relationship. Each of
-        these can be used more than once, which means a unit name must
-        match one of the given values.</para></listitem>
+        pattern as an argument, which will be matched against the
+        left-hand and the right-hand, respectively, nodes of a
+        relationship.</para>
+
+        <para>Each of these can be used more than once, in which case
+        the unit name must match one of the values. When tests for
+        both sides of the relation are present, a relation must pass
+        both tests to be shown. When patterns are also specified as
+        positional arguments, they must match at least one side of the
+        relation. In other words, patterns specified with those two
+        options will trim the list of edges matched by the positional
+        arguments, if any are given, and fully determine the list of
+        edges shown otherwise.</para></listitem>
       </varlistentry>
 
       <varlistentry>
       </varlistentry>
 
       <varlistentry>
         <term><option>--no-man</option></term>
 
         <listitem><para>Do not invoke man to verify the existence of
         <term><option>--no-man</option></term>
 
         <listitem><para>Do not invoke man to verify the existence of
-        man pages listen in <varname>Documentation=</varname>.
+        man pages listed in <varname>Documentation=</varname>.
         </para></listitem>
       </varlistentry>
 
         </para></listitem>
       </varlistentry>
 
index 672a0d79761bae5f00ef7c2c54d0900b37e64188..1e2a6bbf25b036d6a24d0cb4a503759af5cac7b4 100644 (file)
@@ -974,24 +974,34 @@ static int graph_one_property(sd_bus *bus, const UnitInfo *u, const char* prop,
         _cleanup_strv_free_ char **units = NULL;
         char **unit;
         int r;
         _cleanup_strv_free_ char **units = NULL;
         char **unit;
         int r;
+        bool match_patterns;
 
         assert(u);
         assert(prop);
         assert(color);
 
 
         assert(u);
         assert(prop);
         assert(color);
 
+        match_patterns = strv_fnmatch(u->id, patterns, 0);
+
+        if (!strv_isempty(arg_dot_from_patterns) &&
+            !match_patterns &&
+            !strv_fnmatch(u->id, arg_dot_from_patterns, 0))
+                        return 0;
+
         r = bus_get_unit_property_strv(bus, u->unit_path, prop, &units);
         if (r < 0)
                 return r;
 
         STRV_FOREACH(unit, units) {
         r = bus_get_unit_property_strv(bus, u->unit_path, prop, &units);
         if (r < 0)
                 return r;
 
         STRV_FOREACH(unit, units) {
-                if (!strv_fnmatch_or_empty(u->id, arg_dot_from_patterns, 0))
-                        continue;
+                bool match_patterns2;
+
+                match_patterns2 = strv_fnmatch(*unit, patterns, 0);
 
 
-                if (!strv_fnmatch_or_empty(*unit, arg_dot_to_patterns, 0))
+                if (!strv_isempty(arg_dot_to_patterns) &&
+                    !match_patterns2 &&
+                    !strv_fnmatch(*unit, arg_dot_to_patterns, 0))
                         continue;
 
                         continue;
 
-                if (!strv_fnmatch_or_empty(u->id, patterns, 0) &&
-                    !strv_fnmatch_or_empty(*unit, patterns, 0))
+                if (!strv_isempty(patterns) && !match_patterns && !match_patterns2)
                         continue;
 
                 printf("\t\"%s\"->\"%s\" [color=\"%s\"];\n", u->id, *unit, color);
                         continue;
 
                 printf("\t\"%s\"->\"%s\" [color=\"%s\"];\n", u->id, *unit, color);