Ignore checkout . and .. (#2841)

Co-authored-by: yangheran <heran.yang@seafile.com>
This commit is contained in:
feiniks 2024-11-07 22:59:55 +08:00 committed by GitHub
parent 6e2ad478ac
commit a5ae65086a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -806,6 +806,13 @@ should_ignore_on_checkout (const char *file_path, IgnoreReason *ignore_reason)
for (; j < n_comps; ++j) {
file_name = components[j];
if (g_strcmp0(file_name, ".") == 0 || g_strcmp0(file_name, "..") == 0) {
if (ignore_reason)
*ignore_reason = IGNORE_REASON_INVALID_CHARACTER;
ret = TRUE;
goto out;
}
if (has_trailing_space_or_period (file_name)) {
/* Ignore files/dir whose path has trailing spaces. It would cause
* problem on windows. */
@ -839,6 +846,22 @@ out:
g_strfreev (components);
#endif
char **components = g_strsplit (file_path, "/", -1);
int n_comps = g_strv_length (components);
int j = 0;
char *file_name;
for (; j < n_comps; ++j) {
file_name = components[j];
if (g_strcmp0(file_name, ".") == 0 || g_strcmp0(file_name, "..") == 0) {
ret = TRUE;
if (ignore_reason)
*ignore_reason = IGNORE_REASON_INVALID_CHARACTER;
break;
}
}
g_strfreev (components);
return ret;
}