Skip to content

Commit a5ae650

Browse files
feiniksyangheran
andauthored
Ignore checkout . and .. (#2841)
Co-authored-by: yangheran <heran.yang@seafile.com>
1 parent 6e2ad47 commit a5ae650

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/utils.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,13 @@ should_ignore_on_checkout (const char *file_path, IgnoreReason *ignore_reason)
806806
for (; j < n_comps; ++j) {
807807
file_name = components[j];
808808

809+
if (g_strcmp0(file_name, ".") == 0 || g_strcmp0(file_name, "..") == 0) {
810+
if (ignore_reason)
811+
*ignore_reason = IGNORE_REASON_INVALID_CHARACTER;
812+
ret = TRUE;
813+
goto out;
814+
}
815+
809816
if (has_trailing_space_or_period (file_name)) {
810817
/* Ignore files/dir whose path has trailing spaces. It would cause
811818
* problem on windows. */
@@ -839,6 +846,22 @@ should_ignore_on_checkout (const char *file_path, IgnoreReason *ignore_reason)
839846
g_strfreev (components);
840847
#endif
841848

849+
char **components = g_strsplit (file_path, "/", -1);
850+
int n_comps = g_strv_length (components);
851+
int j = 0;
852+
char *file_name;
853+
854+
for (; j < n_comps; ++j) {
855+
file_name = components[j];
856+
if (g_strcmp0(file_name, ".") == 0 || g_strcmp0(file_name, "..") == 0) {
857+
ret = TRUE;
858+
if (ignore_reason)
859+
*ignore_reason = IGNORE_REASON_INVALID_CHARACTER;
860+
break;
861+
}
862+
}
863+
g_strfreev (components);
864+
842865
return ret;
843866
}
844867

0 commit comments

Comments
 (0)