| | @@ -142,22 +142,20 @@ |
| 142 | 142 | ** |
| 143 | 143 | ** Omit any file whose name is pOmit. |
| 144 | 144 | */ |
| 145 | 145 | static int add_one_file( |
| 146 | 146 | const char *zPath, /* Tree-name of file to add. */ |
| 147 | | - int vid, /* Add to this VFILE */ |
| 148 | | - int caseSensitive /* True if filenames are case sensitive */ |
| 147 | + int vid /* Add to this VFILE */ |
| 149 | 148 | ){ |
| 150 | | - const char *zCollate = caseSensitive ? "binary" : "nocase"; |
| 151 | 149 | if( !file_is_simple_pathname(zPath, 1) ){ |
| 152 | 150 | fossil_warning("filename contains illegal characters: %s", zPath); |
| 153 | 151 | return 0; |
| 154 | 152 | } |
| 155 | 153 | if( db_exists("SELECT 1 FROM vfile" |
| 156 | | - " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){ |
| 154 | + " WHERE pathname=%Q %s", zPath, filename_collation()) ){ |
| 157 | 155 | db_multi_exec("UPDATE vfile SET deleted=0" |
| 158 | | - " WHERE pathname=%Q COLLATE %s", zPath, zCollate); |
| 156 | + " WHERE pathname=%Q %s", zPath, filename_collation()); |
| 159 | 157 | }else{ |
| 160 | 158 | char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath); |
| 161 | 159 | db_multi_exec( |
| 162 | 160 | "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)" |
| 163 | 161 | "VALUES(%d,0,0,0,%Q,%d,%d)", |
| | @@ -176,11 +174,11 @@ |
| 176 | 174 | /* |
| 177 | 175 | ** Add all files in the sfile temp table. |
| 178 | 176 | ** |
| 179 | 177 | ** Automatically exclude the repository file. |
| 180 | 178 | */ |
| 181 | | -static int add_files_in_sfile(int vid, int caseSensitive){ |
| 179 | +static int add_files_in_sfile(int vid){ |
| 182 | 180 | const char *zRepo; /* Name of the repository database file */ |
| 183 | 181 | int nAdd = 0; /* Number of files added */ |
| 184 | 182 | int i; /* Loop counter */ |
| 185 | 183 | const char *zReserved; /* Name of a reserved file */ |
| 186 | 184 | Blob repoName; /* Treename of the repository */ |
| | @@ -191,28 +189,24 @@ |
| 191 | 189 | blob_zero(&repoName); |
| 192 | 190 | zRepo = ""; |
| 193 | 191 | }else{ |
| 194 | 192 | zRepo = blob_str(&repoName); |
| 195 | 193 | } |
| 196 | | - if( caseSensitive ){ |
| 194 | + if( filenames_are_case_sensitive() ){ |
| 197 | 195 | xCmp = fossil_strcmp; |
| 198 | 196 | }else{ |
| 199 | 197 | xCmp = fossil_stricmp; |
| 200 | | - db_multi_exec( |
| 201 | | - "CREATE INDEX IF NOT EXISTS vfile_nocase" |
| 202 | | - " ON vfile(pathname COLLATE nocase)" |
| 203 | | - ); |
| 204 | 198 | } |
| 205 | 199 | db_prepare(&loop, "SELECT x FROM sfile ORDER BY x"); |
| 206 | 200 | while( db_step(&loop)==SQLITE_ROW ){ |
| 207 | 201 | const char *zToAdd = db_column_text(&loop, 0); |
| 208 | 202 | if( fossil_strcmp(zToAdd, zRepo)==0 ) continue; |
| 209 | 203 | for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){ |
| 210 | 204 | if( xCmp(zToAdd, zReserved)==0 ) break; |
| 211 | 205 | } |
| 212 | 206 | if( zReserved ) continue; |
| 213 | | - nAdd += add_one_file(zToAdd, vid, caseSensitive); |
| 207 | + nAdd += add_one_file(zToAdd, vid); |
| 214 | 208 | } |
| 215 | 209 | db_finalize(&loop); |
| 216 | 210 | blob_reset(&repoName); |
| 217 | 211 | return nAdd; |
| 218 | 212 | } |
| | @@ -251,33 +245,25 @@ |
| 251 | 245 | int i; /* Loop counter */ |
| 252 | 246 | int vid; /* Currently checked out version */ |
| 253 | 247 | int nRoot; /* Full path characters in g.zLocalRoot */ |
| 254 | 248 | const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */ |
| 255 | 249 | Glob *pIgnore; /* Ignore everything matching this glob pattern */ |
| 256 | | - int caseSensitive; /* True if filenames are case sensitive */ |
| 257 | 250 | unsigned scanFlags = 0; /* Flags passed to vfile_scan() */ |
| 258 | 251 | |
| 259 | 252 | zIgnoreFlag = find_option("ignore",0,1); |
| 260 | 253 | if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL; |
| 261 | 254 | capture_case_sensitive_option(); |
| 262 | 255 | db_must_be_within_tree(); |
| 263 | | - caseSensitive = filenames_are_case_sensitive(); |
| 264 | 256 | if( zIgnoreFlag==0 ){ |
| 265 | 257 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 266 | 258 | } |
| 267 | 259 | vid = db_lget_int("checkout",0); |
| 268 | 260 | if( vid==0 ){ |
| 269 | 261 | fossil_panic("no checkout to add to"); |
| 270 | 262 | } |
| 271 | 263 | db_begin_transaction(); |
| 272 | 264 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 273 | | - if( !caseSensitive ){ |
| 274 | | - db_multi_exec( |
| 275 | | - "CREATE INDEX IF NOT EXISTS vfile_pathname " |
| 276 | | - " ON vfile(pathname COLLATE nocase)" |
| 277 | | - ); |
| 278 | | - } |
| 279 | 265 | pIgnore = glob_create(zIgnoreFlag); |
| 280 | 266 | nRoot = strlen(g.zLocalRoot); |
| 281 | 267 | |
| 282 | 268 | /* Load the names of all files that are to be added into sfile temp table */ |
| 283 | 269 | for(i=2; i<g.argc; i++){ |
| | @@ -287,11 +273,11 @@ |
| 287 | 273 | |
| 288 | 274 | file_canonical_name(g.argv[i], &fullName, 0); |
| 289 | 275 | zName = blob_str(&fullName); |
| 290 | 276 | isDir = file_wd_isdir(zName); |
| 291 | 277 | if( isDir==1 ){ |
| 292 | | - vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore, caseSensitive); |
| 278 | + vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore); |
| 293 | 279 | }else if( isDir==0 ){ |
| 294 | 280 | fossil_warning("not found: %s", zName); |
| 295 | 281 | }else if( file_access(zName, R_OK) ){ |
| 296 | 282 | fossil_fatal("cannot open %s", zName); |
| 297 | 283 | }else{ |
| | @@ -303,11 +289,11 @@ |
| 303 | 289 | } |
| 304 | 290 | blob_reset(&fullName); |
| 305 | 291 | } |
| 306 | 292 | glob_free(pIgnore); |
| 307 | 293 | |
| 308 | | - add_files_in_sfile(vid, caseSensitive); |
| 294 | + add_files_in_sfile(vid); |
| 309 | 295 | db_end_transaction(0); |
| 310 | 296 | } |
| 311 | 297 | |
| 312 | 298 | /* |
| 313 | 299 | ** COMMAND: rm |
| | @@ -414,10 +400,16 @@ |
| 414 | 400 | #else |
| 415 | 401 | caseSensitive = 1; /* Unix */ |
| 416 | 402 | #endif |
| 417 | 403 | caseSensitive = db_get_boolean("case-sensitive",caseSensitive); |
| 418 | 404 | } |
| 405 | + if( !caseSensitive ){ |
| 406 | + db_multi_exec( |
| 407 | + "CREATE INDEX IF NOT EXISTS vfile_nocase " |
| 408 | + " ON vfile(pathname COLLATE nocase)" |
| 409 | + ); |
| 410 | + } |
| 419 | 411 | } |
| 420 | 412 | return caseSensitive; |
| 421 | 413 | } |
| 422 | 414 | |
| 423 | 415 | /* |
| | @@ -429,22 +421,10 @@ |
| 429 | 421 | */ |
| 430 | 422 | const char *filename_collation(void){ |
| 431 | 423 | return filenames_are_case_sensitive() ? "" : "COLLATE nocase"; |
| 432 | 424 | } |
| 433 | 425 | |
| 434 | | -/* |
| 435 | | -** Do a strncmp() operation which is either case-sensitive or not |
| 436 | | -** depending on the setting of filenames_are_case_sensitive(). |
| 437 | | -*/ |
| 438 | | -int filenames_strncmp(const char *zA, const char *zB, int nByte){ |
| 439 | | - if( filenames_are_case_sensitive() ){ |
| 440 | | - return fossil_strncmp(zA,zB,nByte); |
| 441 | | - }else{ |
| 442 | | - return fossil_strnicmp(zA,zB,nByte); |
| 443 | | - } |
| 444 | | -} |
| 445 | | - |
| 446 | 426 | /* |
| 447 | 427 | ** COMMAND: addremove |
| 448 | 428 | ** |
| 449 | 429 | ** Usage: %fossil addremove ?OPTIONS? |
| 450 | 430 | ** |
| | @@ -485,21 +465,19 @@ |
| 485 | 465 | void addremove_cmd(void){ |
| 486 | 466 | Blob path; |
| 487 | 467 | const char *zIgnoreFlag = find_option("ignore",0,1); |
| 488 | 468 | unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0; |
| 489 | 469 | int isTest = find_option("test",0,0)!=0; |
| 490 | | - int caseSensitive; |
| 491 | 470 | int n; |
| 492 | 471 | Stmt q; |
| 493 | 472 | int vid; |
| 494 | 473 | int nAdd = 0; |
| 495 | 474 | int nDelete = 0; |
| 496 | 475 | Glob *pIgnore; |
| 497 | 476 | |
| 498 | 477 | capture_case_sensitive_option(); |
| 499 | 478 | db_must_be_within_tree(); |
| 500 | | - caseSensitive = filenames_are_case_sensitive(); |
| 501 | 479 | if( zIgnoreFlag==0 ){ |
| 502 | 480 | zIgnoreFlag = db_get("ignore-glob", 0); |
| 503 | 481 | } |
| 504 | 482 | vid = db_lget_int("checkout",0); |
| 505 | 483 | if( vid==0 ){ |
| | @@ -516,13 +494,13 @@ |
| 516 | 494 | db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)"); |
| 517 | 495 | n = strlen(g.zLocalRoot); |
| 518 | 496 | blob_init(&path, g.zLocalRoot, n-1); |
| 519 | 497 | /* now we read the complete file structure into a temp table */ |
| 520 | 498 | pIgnore = glob_create(zIgnoreFlag); |
| 521 | | - vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive); |
| 499 | + vfile_scan(&path, blob_size(&path), scanFlags, pIgnore); |
| 522 | 500 | glob_free(pIgnore); |
| 523 | | - nAdd = add_files_in_sfile(vid, caseSensitive); |
| 501 | + nAdd = add_files_in_sfile(vid); |
| 524 | 502 | |
| 525 | 503 | /* step 2: search for missing files */ |
| 526 | 504 | db_prepare(&q, |
| 527 | 505 | "SELECT pathname, %Q || pathname, deleted FROM vfile" |
| 528 | 506 | " WHERE NOT deleted" |
| 529 | 507 | |