aboutsummaryrefslogtreecommitdiff
path: root/src/delta
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-01-16 20:22:25 +1100
committerGitHub <noreply@github.com>2018-01-16 20:22:25 +1100
commit4579e8ef313efe56f99a4bdd43439c508a6d49ce (patch)
tree559d4563579c4309877879622cfaf957d946f1cd /src/delta
parentmachined: use getent to get default shell for machinectl shell (#7684) (diff)
parentdelta: don't ignore PREFIX when the given argument is PREFIX/SUFFIX (diff)
downloadsystemd-4579e8ef313efe56f99a4bdd43439c508a6d49ce.tar.gz
systemd-4579e8ef313efe56f99a4bdd43439c508a6d49ce.tar.bz2
systemd-4579e8ef313efe56f99a4bdd43439c508a6d49ce.zip
Merge pull request #7540 from fbuihuu/systemd-delta-tweaks
Systemd delta tweaks
Diffstat (limited to 'src/delta')
-rw-r--r--src/delta/delta.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/delta/delta.c b/src/delta/delta.c
index d94ae0275..645b0b227 100644
--- a/src/delta/delta.c
+++ b/src/delta/delta.c
@@ -387,19 +387,28 @@ static int enumerate_dir(
return 0;
}
-static int should_skip_prefix(const char* p) {
+static bool should_skip_path(const char *prefix, const char *suffix) {
#if HAVE_SPLIT_USR
- int r;
_cleanup_free_ char *target = NULL;
+ const char *p;
+ char *dirname;
- r = chase_symlinks(p, NULL, 0, &target);
- if (r < 0)
- return r;
+ dirname = strjoina(prefix, "/", suffix);
- return !streq(p, target) && nulstr_contains(prefixes, target);
-#else
- return 0;
+ if (chase_symlinks(dirname, NULL, 0, &target) < 0)
+ return false;
+
+ NULSTR_FOREACH(p, prefixes) {
+ if (path_startswith(dirname, p))
+ continue;
+
+ if (path_equal(target, strjoina(p, "/", suffix))) {
+ log_debug("%s redirects to %s, skipping.", dirname, target);
+ return true;
+ }
+ }
#endif
+ return false;
}
static int process_suffix(const char *suffix, const char *onlyprefix) {
@@ -429,14 +438,8 @@ static int process_suffix(const char *suffix, const char *onlyprefix) {
NULSTR_FOREACH(p, prefixes) {
_cleanup_free_ char *t = NULL;
- int skip;
- skip = should_skip_prefix(p);
- if (skip < 0) {
- r = skip;
- goto finish;
- }
- if (skip)
+ if (should_skip_path(p, suffix))
continue;
t = strjoin(p, "/", suffix);
@@ -515,19 +518,12 @@ static int process_suffix_chop(const char *arg) {
/* Strip prefix from the suffix */
NULSTR_FOREACH(p, prefixes) {
const char *suffix;
- int skip;
-
- skip = should_skip_prefix(p);
- if (skip < 0)
- return skip;
- if (skip)
- continue;
suffix = startswith(arg, p);
if (suffix) {
suffix += strspn(suffix, "/");
if (*suffix)
- return process_suffix(suffix, NULL);
+ return process_suffix(suffix, p);
else
return process_suffixes(arg);
}