Fossil SCM
Do not allow the "fossil add" command to add files beneath a symlink.
Commit
a6abfb911b31d8f814be147299b6c0cd9e45740b00a96f6de7e4ff64bb9ebf2c
Parent
888da94e0a7983f…
1 file changed
+12
-2
+12
-2
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -186,11 +186,13 @@ | ||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | /* |
| 189 | 189 | ** Add all files in the sfile temp table. |
| 190 | 190 | ** |
| 191 | -** Automatically exclude the repository file. | |
| 191 | +** Automatically exclude the repository file and any other files | |
| 192 | +** with reserved names. Also exclude files that are beneath an | |
| 193 | +** existing symlink. | |
| 192 | 194 | */ |
| 193 | 195 | static int add_files_in_sfile(int vid){ |
| 194 | 196 | const char *zRepo; /* Name of the repository database file */ |
| 195 | 197 | int nAdd = 0; /* Number of files added */ |
| 196 | 198 | int i; /* Loop counter */ |
| @@ -208,11 +210,19 @@ | ||
| 208 | 210 | if( filenames_are_case_sensitive() ){ |
| 209 | 211 | xCmp = fossil_strcmp; |
| 210 | 212 | }else{ |
| 211 | 213 | xCmp = fossil_stricmp; |
| 212 | 214 | } |
| 213 | - db_prepare(&loop, "SELECT pathname FROM sfile ORDER BY pathname"); | |
| 215 | + db_prepare(&loop, | |
| 216 | + "SELECT pathname FROM sfile" | |
| 217 | + " WHERE pathname NOT IN (" | |
| 218 | + "SELECT sfile.pathname FROM vfile, sfile" | |
| 219 | + " WHERE vfile.islink" | |
| 220 | + " AND NOT vfile.deleted" | |
| 221 | + " AND sfile.pathname>(vfile.pathname||'/')" | |
| 222 | + " AND sfile.pathname<(vfile.pathname||'0'))" | |
| 223 | + " ORDER BY pathname"); | |
| 214 | 224 | while( db_step(&loop)==SQLITE_ROW ){ |
| 215 | 225 | const char *zToAdd = db_column_text(&loop, 0); |
| 216 | 226 | if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 217 | 227 | if( strchr(zToAdd,'/') ){ |
| 218 | 228 | if( file_is_reserved_name(zToAdd, -1) ) continue; |
| 219 | 229 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -186,11 +186,13 @@ | |
| 186 | } |
| 187 | |
| 188 | /* |
| 189 | ** Add all files in the sfile temp table. |
| 190 | ** |
| 191 | ** Automatically exclude the repository file. |
| 192 | */ |
| 193 | static int add_files_in_sfile(int vid){ |
| 194 | const char *zRepo; /* Name of the repository database file */ |
| 195 | int nAdd = 0; /* Number of files added */ |
| 196 | int i; /* Loop counter */ |
| @@ -208,11 +210,19 @@ | |
| 208 | if( filenames_are_case_sensitive() ){ |
| 209 | xCmp = fossil_strcmp; |
| 210 | }else{ |
| 211 | xCmp = fossil_stricmp; |
| 212 | } |
| 213 | db_prepare(&loop, "SELECT pathname FROM sfile ORDER BY pathname"); |
| 214 | while( db_step(&loop)==SQLITE_ROW ){ |
| 215 | const char *zToAdd = db_column_text(&loop, 0); |
| 216 | if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 217 | if( strchr(zToAdd,'/') ){ |
| 218 | if( file_is_reserved_name(zToAdd, -1) ) continue; |
| 219 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -186,11 +186,13 @@ | |
| 186 | } |
| 187 | |
| 188 | /* |
| 189 | ** Add all files in the sfile temp table. |
| 190 | ** |
| 191 | ** Automatically exclude the repository file and any other files |
| 192 | ** with reserved names. Also exclude files that are beneath an |
| 193 | ** existing symlink. |
| 194 | */ |
| 195 | static int add_files_in_sfile(int vid){ |
| 196 | const char *zRepo; /* Name of the repository database file */ |
| 197 | int nAdd = 0; /* Number of files added */ |
| 198 | int i; /* Loop counter */ |
| @@ -208,11 +210,19 @@ | |
| 210 | if( filenames_are_case_sensitive() ){ |
| 211 | xCmp = fossil_strcmp; |
| 212 | }else{ |
| 213 | xCmp = fossil_stricmp; |
| 214 | } |
| 215 | db_prepare(&loop, |
| 216 | "SELECT pathname FROM sfile" |
| 217 | " WHERE pathname NOT IN (" |
| 218 | "SELECT sfile.pathname FROM vfile, sfile" |
| 219 | " WHERE vfile.islink" |
| 220 | " AND NOT vfile.deleted" |
| 221 | " AND sfile.pathname>(vfile.pathname||'/')" |
| 222 | " AND sfile.pathname<(vfile.pathname||'0'))" |
| 223 | " ORDER BY pathname"); |
| 224 | while( db_step(&loop)==SQLITE_ROW ){ |
| 225 | const char *zToAdd = db_column_text(&loop, 0); |
| 226 | if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 227 | if( strchr(zToAdd,'/') ){ |
| 228 | if( file_is_reserved_name(zToAdd, -1) ) continue; |
| 229 |