Merge pull request #28869 from DaanDeMeyer/repart-trailing

repart: Make sure we keep trailing slashes in ExcludeFiles=
This commit is contained in:
Daan De Meyer
2023-08-17 14:55:03 +02:00
committed by GitHub
6 changed files with 44 additions and 28 deletions
+7 -2
View File
@@ -344,8 +344,8 @@ char **path_strv_resolve_uniq(char **l, const char *root) {
return strv_uniq(l);
}
char *path_simplify(char *path) {
bool add_slash = false;
char *path_simplify_full(char *path, PathSimplifyFlags flags) {
bool add_slash = false, keep_trailing_slash;
char *f = ASSERT_PTR(path);
int r;
@@ -359,6 +359,8 @@ char *path_simplify(char *path) {
if (isempty(path))
return path;
keep_trailing_slash = FLAGS_SET(flags, PATH_SIMPLIFY_KEEP_TRAILING_SLASH) && endswith(path, "/");
if (path_is_absolute(path))
f++;
@@ -388,6 +390,9 @@ char *path_simplify(char *path) {
if (f == path)
*f++ = '.';
if (*(f-1) != '/' && keep_trailing_slash)
*f++ = '/';
*f = '\0';
return path;
}
+8 -1
View File
@@ -76,7 +76,14 @@ char* path_extend_internal(char **x, ...);
#define path_extend(x, ...) path_extend_internal(x, __VA_ARGS__, POINTER_MAX)
#define path_join(...) path_extend_internal(NULL, __VA_ARGS__, POINTER_MAX)
char* path_simplify(char *path);
typedef enum PathSimplifyFlags {
PATH_SIMPLIFY_KEEP_TRAILING_SLASH = 1 << 0,
} PathSimplifyFlags;
char *path_simplify_full(char *path, PathSimplifyFlags flags);
static inline char* path_simplify(char *path) {
return path_simplify_full(path, 0);
}
static inline bool path_equal_ptr(const char *a, const char *b) {
return !!a == !!b && (!a || path_equal(a, b));