Fossil SCM

Use the function filename_collation() everywhere in stead of passing caseSensitive as parameter.

jan.nijtmans 2013-04-18 08:46 trunk
Commit 3c781f4f0b6df2501ea71e313e3ba3f8b52aca33
+16 -38
--- src/add.c
+++ src/add.c
@@ -142,22 +142,20 @@
142142
**
143143
** Omit any file whose name is pOmit.
144144
*/
145145
static int add_one_file(
146146
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 */
149148
){
150
- const char *zCollate = caseSensitive ? "binary" : "nocase";
151149
if( !file_is_simple_pathname(zPath, 1) ){
152150
fossil_warning("filename contains illegal characters: %s", zPath);
153151
return 0;
154152
}
155153
if( db_exists("SELECT 1 FROM vfile"
156
- " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){
154
+ " WHERE pathname=%Q %s", zPath, filename_collation()) ){
157155
db_multi_exec("UPDATE vfile SET deleted=0"
158
- " WHERE pathname=%Q COLLATE %s", zPath, zCollate);
156
+ " WHERE pathname=%Q %s", zPath, filename_collation());
159157
}else{
160158
char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
161159
db_multi_exec(
162160
"INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
163161
"VALUES(%d,0,0,0,%Q,%d,%d)",
@@ -176,11 +174,11 @@
176174
/*
177175
** Add all files in the sfile temp table.
178176
**
179177
** Automatically exclude the repository file.
180178
*/
181
-static int add_files_in_sfile(int vid, int caseSensitive){
179
+static int add_files_in_sfile(int vid){
182180
const char *zRepo; /* Name of the repository database file */
183181
int nAdd = 0; /* Number of files added */
184182
int i; /* Loop counter */
185183
const char *zReserved; /* Name of a reserved file */
186184
Blob repoName; /* Treename of the repository */
@@ -191,28 +189,24 @@
191189
blob_zero(&repoName);
192190
zRepo = "";
193191
}else{
194192
zRepo = blob_str(&repoName);
195193
}
196
- if( caseSensitive ){
194
+ if( filenames_are_case_sensitive() ){
197195
xCmp = fossil_strcmp;
198196
}else{
199197
xCmp = fossil_stricmp;
200
- db_multi_exec(
201
- "CREATE INDEX IF NOT EXISTS vfile_nocase"
202
- " ON vfile(pathname COLLATE nocase)"
203
- );
204198
}
205199
db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
206200
while( db_step(&loop)==SQLITE_ROW ){
207201
const char *zToAdd = db_column_text(&loop, 0);
208202
if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
209203
for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){
210204
if( xCmp(zToAdd, zReserved)==0 ) break;
211205
}
212206
if( zReserved ) continue;
213
- nAdd += add_one_file(zToAdd, vid, caseSensitive);
207
+ nAdd += add_one_file(zToAdd, vid);
214208
}
215209
db_finalize(&loop);
216210
blob_reset(&repoName);
217211
return nAdd;
218212
}
@@ -251,33 +245,25 @@
251245
int i; /* Loop counter */
252246
int vid; /* Currently checked out version */
253247
int nRoot; /* Full path characters in g.zLocalRoot */
254248
const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
255249
Glob *pIgnore; /* Ignore everything matching this glob pattern */
256
- int caseSensitive; /* True if filenames are case sensitive */
257250
unsigned scanFlags = 0; /* Flags passed to vfile_scan() */
258251
259252
zIgnoreFlag = find_option("ignore",0,1);
260253
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
261254
capture_case_sensitive_option();
262255
db_must_be_within_tree();
263
- caseSensitive = filenames_are_case_sensitive();
264256
if( zIgnoreFlag==0 ){
265257
zIgnoreFlag = db_get("ignore-glob", 0);
266258
}
267259
vid = db_lget_int("checkout",0);
268260
if( vid==0 ){
269261
fossil_panic("no checkout to add to");
270262
}
271263
db_begin_transaction();
272264
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
- }
279265
pIgnore = glob_create(zIgnoreFlag);
280266
nRoot = strlen(g.zLocalRoot);
281267
282268
/* Load the names of all files that are to be added into sfile temp table */
283269
for(i=2; i<g.argc; i++){
@@ -287,11 +273,11 @@
287273
288274
file_canonical_name(g.argv[i], &fullName, 0);
289275
zName = blob_str(&fullName);
290276
isDir = file_wd_isdir(zName);
291277
if( isDir==1 ){
292
- vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore, caseSensitive);
278
+ vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore);
293279
}else if( isDir==0 ){
294280
fossil_warning("not found: %s", zName);
295281
}else if( file_access(zName, R_OK) ){
296282
fossil_fatal("cannot open %s", zName);
297283
}else{
@@ -303,11 +289,11 @@
303289
}
304290
blob_reset(&fullName);
305291
}
306292
glob_free(pIgnore);
307293
308
- add_files_in_sfile(vid, caseSensitive);
294
+ add_files_in_sfile(vid);
309295
db_end_transaction(0);
310296
}
311297
312298
/*
313299
** COMMAND: rm
@@ -414,10 +400,16 @@
414400
#else
415401
caseSensitive = 1; /* Unix */
416402
#endif
417403
caseSensitive = db_get_boolean("case-sensitive",caseSensitive);
418404
}
405
+ if( !caseSensitive ){
406
+ db_multi_exec(
407
+ "CREATE INDEX IF NOT EXISTS vfile_nocase "
408
+ " ON vfile(pathname COLLATE nocase)"
409
+ );
410
+ }
419411
}
420412
return caseSensitive;
421413
}
422414
423415
/*
@@ -429,22 +421,10 @@
429421
*/
430422
const char *filename_collation(void){
431423
return filenames_are_case_sensitive() ? "" : "COLLATE nocase";
432424
}
433425
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
-
446426
/*
447427
** COMMAND: addremove
448428
**
449429
** Usage: %fossil addremove ?OPTIONS?
450430
**
@@ -485,21 +465,19 @@
485465
void addremove_cmd(void){
486466
Blob path;
487467
const char *zIgnoreFlag = find_option("ignore",0,1);
488468
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
489469
int isTest = find_option("test",0,0)!=0;
490
- int caseSensitive;
491470
int n;
492471
Stmt q;
493472
int vid;
494473
int nAdd = 0;
495474
int nDelete = 0;
496475
Glob *pIgnore;
497476
498477
capture_case_sensitive_option();
499478
db_must_be_within_tree();
500
- caseSensitive = filenames_are_case_sensitive();
501479
if( zIgnoreFlag==0 ){
502480
zIgnoreFlag = db_get("ignore-glob", 0);
503481
}
504482
vid = db_lget_int("checkout",0);
505483
if( vid==0 ){
@@ -516,13 +494,13 @@
516494
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
517495
n = strlen(g.zLocalRoot);
518496
blob_init(&path, g.zLocalRoot, n-1);
519497
/* now we read the complete file structure into a temp table */
520498
pIgnore = glob_create(zIgnoreFlag);
521
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive);
499
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
522500
glob_free(pIgnore);
523
- nAdd = add_files_in_sfile(vid, caseSensitive);
501
+ nAdd = add_files_in_sfile(vid);
524502
525503
/* step 2: search for missing files */
526504
db_prepare(&q,
527505
"SELECT pathname, %Q || pathname, deleted FROM vfile"
528506
" WHERE NOT deleted"
529507
--- src/add.c
+++ src/add.c
@@ -142,22 +142,20 @@
142 **
143 ** Omit any file whose name is pOmit.
144 */
145 static int add_one_file(
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 */
149 ){
150 const char *zCollate = caseSensitive ? "binary" : "nocase";
151 if( !file_is_simple_pathname(zPath, 1) ){
152 fossil_warning("filename contains illegal characters: %s", zPath);
153 return 0;
154 }
155 if( db_exists("SELECT 1 FROM vfile"
156 " WHERE pathname=%Q COLLATE %s", zPath, zCollate) ){
157 db_multi_exec("UPDATE vfile SET deleted=0"
158 " WHERE pathname=%Q COLLATE %s", zPath, zCollate);
159 }else{
160 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
161 db_multi_exec(
162 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
163 "VALUES(%d,0,0,0,%Q,%d,%d)",
@@ -176,11 +174,11 @@
176 /*
177 ** Add all files in the sfile temp table.
178 **
179 ** Automatically exclude the repository file.
180 */
181 static int add_files_in_sfile(int vid, int caseSensitive){
182 const char *zRepo; /* Name of the repository database file */
183 int nAdd = 0; /* Number of files added */
184 int i; /* Loop counter */
185 const char *zReserved; /* Name of a reserved file */
186 Blob repoName; /* Treename of the repository */
@@ -191,28 +189,24 @@
191 blob_zero(&repoName);
192 zRepo = "";
193 }else{
194 zRepo = blob_str(&repoName);
195 }
196 if( caseSensitive ){
197 xCmp = fossil_strcmp;
198 }else{
199 xCmp = fossil_stricmp;
200 db_multi_exec(
201 "CREATE INDEX IF NOT EXISTS vfile_nocase"
202 " ON vfile(pathname COLLATE nocase)"
203 );
204 }
205 db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
206 while( db_step(&loop)==SQLITE_ROW ){
207 const char *zToAdd = db_column_text(&loop, 0);
208 if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
209 for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){
210 if( xCmp(zToAdd, zReserved)==0 ) break;
211 }
212 if( zReserved ) continue;
213 nAdd += add_one_file(zToAdd, vid, caseSensitive);
214 }
215 db_finalize(&loop);
216 blob_reset(&repoName);
217 return nAdd;
218 }
@@ -251,33 +245,25 @@
251 int i; /* Loop counter */
252 int vid; /* Currently checked out version */
253 int nRoot; /* Full path characters in g.zLocalRoot */
254 const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
255 Glob *pIgnore; /* Ignore everything matching this glob pattern */
256 int caseSensitive; /* True if filenames are case sensitive */
257 unsigned scanFlags = 0; /* Flags passed to vfile_scan() */
258
259 zIgnoreFlag = find_option("ignore",0,1);
260 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
261 capture_case_sensitive_option();
262 db_must_be_within_tree();
263 caseSensitive = filenames_are_case_sensitive();
264 if( zIgnoreFlag==0 ){
265 zIgnoreFlag = db_get("ignore-glob", 0);
266 }
267 vid = db_lget_int("checkout",0);
268 if( vid==0 ){
269 fossil_panic("no checkout to add to");
270 }
271 db_begin_transaction();
272 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 pIgnore = glob_create(zIgnoreFlag);
280 nRoot = strlen(g.zLocalRoot);
281
282 /* Load the names of all files that are to be added into sfile temp table */
283 for(i=2; i<g.argc; i++){
@@ -287,11 +273,11 @@
287
288 file_canonical_name(g.argv[i], &fullName, 0);
289 zName = blob_str(&fullName);
290 isDir = file_wd_isdir(zName);
291 if( isDir==1 ){
292 vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore, caseSensitive);
293 }else if( isDir==0 ){
294 fossil_warning("not found: %s", zName);
295 }else if( file_access(zName, R_OK) ){
296 fossil_fatal("cannot open %s", zName);
297 }else{
@@ -303,11 +289,11 @@
303 }
304 blob_reset(&fullName);
305 }
306 glob_free(pIgnore);
307
308 add_files_in_sfile(vid, caseSensitive);
309 db_end_transaction(0);
310 }
311
312 /*
313 ** COMMAND: rm
@@ -414,10 +400,16 @@
414 #else
415 caseSensitive = 1; /* Unix */
416 #endif
417 caseSensitive = db_get_boolean("case-sensitive",caseSensitive);
418 }
 
 
 
 
 
 
419 }
420 return caseSensitive;
421 }
422
423 /*
@@ -429,22 +421,10 @@
429 */
430 const char *filename_collation(void){
431 return filenames_are_case_sensitive() ? "" : "COLLATE nocase";
432 }
433
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 /*
447 ** COMMAND: addremove
448 **
449 ** Usage: %fossil addremove ?OPTIONS?
450 **
@@ -485,21 +465,19 @@
485 void addremove_cmd(void){
486 Blob path;
487 const char *zIgnoreFlag = find_option("ignore",0,1);
488 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
489 int isTest = find_option("test",0,0)!=0;
490 int caseSensitive;
491 int n;
492 Stmt q;
493 int vid;
494 int nAdd = 0;
495 int nDelete = 0;
496 Glob *pIgnore;
497
498 capture_case_sensitive_option();
499 db_must_be_within_tree();
500 caseSensitive = filenames_are_case_sensitive();
501 if( zIgnoreFlag==0 ){
502 zIgnoreFlag = db_get("ignore-glob", 0);
503 }
504 vid = db_lget_int("checkout",0);
505 if( vid==0 ){
@@ -516,13 +494,13 @@
516 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
517 n = strlen(g.zLocalRoot);
518 blob_init(&path, g.zLocalRoot, n-1);
519 /* now we read the complete file structure into a temp table */
520 pIgnore = glob_create(zIgnoreFlag);
521 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive);
522 glob_free(pIgnore);
523 nAdd = add_files_in_sfile(vid, caseSensitive);
524
525 /* step 2: search for missing files */
526 db_prepare(&q,
527 "SELECT pathname, %Q || pathname, deleted FROM vfile"
528 " WHERE NOT deleted"
529
--- src/add.c
+++ src/add.c
@@ -142,22 +142,20 @@
142 **
143 ** Omit any file whose name is pOmit.
144 */
145 static int add_one_file(
146 const char *zPath, /* Tree-name of file to add. */
147 int vid /* Add to this VFILE */
 
148 ){
 
149 if( !file_is_simple_pathname(zPath, 1) ){
150 fossil_warning("filename contains illegal characters: %s", zPath);
151 return 0;
152 }
153 if( db_exists("SELECT 1 FROM vfile"
154 " WHERE pathname=%Q %s", zPath, filename_collation()) ){
155 db_multi_exec("UPDATE vfile SET deleted=0"
156 " WHERE pathname=%Q %s", zPath, filename_collation());
157 }else{
158 char *zFullname = mprintf("%s%s", g.zLocalRoot, zPath);
159 db_multi_exec(
160 "INSERT INTO vfile(vid,deleted,rid,mrid,pathname,isexe,islink)"
161 "VALUES(%d,0,0,0,%Q,%d,%d)",
@@ -176,11 +174,11 @@
174 /*
175 ** Add all files in the sfile temp table.
176 **
177 ** Automatically exclude the repository file.
178 */
179 static int add_files_in_sfile(int vid){
180 const char *zRepo; /* Name of the repository database file */
181 int nAdd = 0; /* Number of files added */
182 int i; /* Loop counter */
183 const char *zReserved; /* Name of a reserved file */
184 Blob repoName; /* Treename of the repository */
@@ -191,28 +189,24 @@
189 blob_zero(&repoName);
190 zRepo = "";
191 }else{
192 zRepo = blob_str(&repoName);
193 }
194 if( filenames_are_case_sensitive() ){
195 xCmp = fossil_strcmp;
196 }else{
197 xCmp = fossil_stricmp;
 
 
 
 
198 }
199 db_prepare(&loop, "SELECT x FROM sfile ORDER BY x");
200 while( db_step(&loop)==SQLITE_ROW ){
201 const char *zToAdd = db_column_text(&loop, 0);
202 if( fossil_strcmp(zToAdd, zRepo)==0 ) continue;
203 for(i=0; (zReserved = fossil_reserved_name(i, 0))!=0; i++){
204 if( xCmp(zToAdd, zReserved)==0 ) break;
205 }
206 if( zReserved ) continue;
207 nAdd += add_one_file(zToAdd, vid);
208 }
209 db_finalize(&loop);
210 blob_reset(&repoName);
211 return nAdd;
212 }
@@ -251,33 +245,25 @@
245 int i; /* Loop counter */
246 int vid; /* Currently checked out version */
247 int nRoot; /* Full path characters in g.zLocalRoot */
248 const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
249 Glob *pIgnore; /* Ignore everything matching this glob pattern */
 
250 unsigned scanFlags = 0; /* Flags passed to vfile_scan() */
251
252 zIgnoreFlag = find_option("ignore",0,1);
253 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
254 capture_case_sensitive_option();
255 db_must_be_within_tree();
 
256 if( zIgnoreFlag==0 ){
257 zIgnoreFlag = db_get("ignore-glob", 0);
258 }
259 vid = db_lget_int("checkout",0);
260 if( vid==0 ){
261 fossil_panic("no checkout to add to");
262 }
263 db_begin_transaction();
264 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
 
 
 
 
 
 
265 pIgnore = glob_create(zIgnoreFlag);
266 nRoot = strlen(g.zLocalRoot);
267
268 /* Load the names of all files that are to be added into sfile temp table */
269 for(i=2; i<g.argc; i++){
@@ -287,11 +273,11 @@
273
274 file_canonical_name(g.argv[i], &fullName, 0);
275 zName = blob_str(&fullName);
276 isDir = file_wd_isdir(zName);
277 if( isDir==1 ){
278 vfile_scan(&fullName, nRoot-1, scanFlags, pIgnore);
279 }else if( isDir==0 ){
280 fossil_warning("not found: %s", zName);
281 }else if( file_access(zName, R_OK) ){
282 fossil_fatal("cannot open %s", zName);
283 }else{
@@ -303,11 +289,11 @@
289 }
290 blob_reset(&fullName);
291 }
292 glob_free(pIgnore);
293
294 add_files_in_sfile(vid);
295 db_end_transaction(0);
296 }
297
298 /*
299 ** COMMAND: rm
@@ -414,10 +400,16 @@
400 #else
401 caseSensitive = 1; /* Unix */
402 #endif
403 caseSensitive = db_get_boolean("case-sensitive",caseSensitive);
404 }
405 if( !caseSensitive ){
406 db_multi_exec(
407 "CREATE INDEX IF NOT EXISTS vfile_nocase "
408 " ON vfile(pathname COLLATE nocase)"
409 );
410 }
411 }
412 return caseSensitive;
413 }
414
415 /*
@@ -429,22 +421,10 @@
421 */
422 const char *filename_collation(void){
423 return filenames_are_case_sensitive() ? "" : "COLLATE nocase";
424 }
425
 
 
 
 
 
 
 
 
 
 
 
 
426 /*
427 ** COMMAND: addremove
428 **
429 ** Usage: %fossil addremove ?OPTIONS?
430 **
@@ -485,21 +465,19 @@
465 void addremove_cmd(void){
466 Blob path;
467 const char *zIgnoreFlag = find_option("ignore",0,1);
468 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
469 int isTest = find_option("test",0,0)!=0;
 
470 int n;
471 Stmt q;
472 int vid;
473 int nAdd = 0;
474 int nDelete = 0;
475 Glob *pIgnore;
476
477 capture_case_sensitive_option();
478 db_must_be_within_tree();
 
479 if( zIgnoreFlag==0 ){
480 zIgnoreFlag = db_get("ignore-glob", 0);
481 }
482 vid = db_lget_int("checkout",0);
483 if( vid==0 ){
@@ -516,13 +494,13 @@
494 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
495 n = strlen(g.zLocalRoot);
496 blob_init(&path, g.zLocalRoot, n-1);
497 /* now we read the complete file structure into a temp table */
498 pIgnore = glob_create(zIgnoreFlag);
499 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
500 glob_free(pIgnore);
501 nAdd = add_files_in_sfile(vid);
502
503 /* step 2: search for missing files */
504 db_prepare(&q,
505 "SELECT pathname, %Q || pathname, deleted FROM vfile"
506 " WHERE NOT deleted"
507
+9 -2
--- src/browse.c
+++ src/browse.c
@@ -208,24 +208,31 @@
208208
Stmt ins;
209209
ManifestFile *pFile;
210210
ManifestFile *pPrev = 0;
211211
int nPrev = 0;
212212
int c;
213
+ int (*xCmp)(const char*,const char*,int);
214
+
215
+ if( filenames_are_case_sensitive() ){
216
+ xCmp = fossil_strncmp;
217
+ }else{
218
+ xCmp = fossil_strnicmp;
219
+ }
213220
214221
db_prepare(&ins,
215222
"INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
216223
);
217224
manifest_file_rewind(pM);
218225
while( (pFile = manifest_file_next(pM,0))!=0 ){
219226
if( nD>0
220
- && (filenames_strncmp(pFile->zName, zD, nD-1)!=0
227
+ && (xCmp(pFile->zName, zD, nD-1)!=0
221228
|| pFile->zName[nD-1]!='/')
222229
){
223230
continue;
224231
}
225232
if( pPrev
226
- && filenames_strncmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
233
+ && xCmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
227234
&& (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/')
228235
){
229236
continue;
230237
}
231238
db_bind_text(&ins, ":x", &pFile->zName[nD]);
232239
--- src/browse.c
+++ src/browse.c
@@ -208,24 +208,31 @@
208 Stmt ins;
209 ManifestFile *pFile;
210 ManifestFile *pPrev = 0;
211 int nPrev = 0;
212 int c;
 
 
 
 
 
 
 
213
214 db_prepare(&ins,
215 "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
216 );
217 manifest_file_rewind(pM);
218 while( (pFile = manifest_file_next(pM,0))!=0 ){
219 if( nD>0
220 && (filenames_strncmp(pFile->zName, zD, nD-1)!=0
221 || pFile->zName[nD-1]!='/')
222 ){
223 continue;
224 }
225 if( pPrev
226 && filenames_strncmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
227 && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/')
228 ){
229 continue;
230 }
231 db_bind_text(&ins, ":x", &pFile->zName[nD]);
232
--- src/browse.c
+++ src/browse.c
@@ -208,24 +208,31 @@
208 Stmt ins;
209 ManifestFile *pFile;
210 ManifestFile *pPrev = 0;
211 int nPrev = 0;
212 int c;
213 int (*xCmp)(const char*,const char*,int);
214
215 if( filenames_are_case_sensitive() ){
216 xCmp = fossil_strncmp;
217 }else{
218 xCmp = fossil_strnicmp;
219 }
220
221 db_prepare(&ins,
222 "INSERT OR IGNORE INTO localfiles VALUES(pathelement(:x,0), :u)"
223 );
224 manifest_file_rewind(pM);
225 while( (pFile = manifest_file_next(pM,0))!=0 ){
226 if( nD>0
227 && (xCmp(pFile->zName, zD, nD-1)!=0
228 || pFile->zName[nD-1]!='/')
229 ){
230 continue;
231 }
232 if( pPrev
233 && xCmp(&pFile->zName[nD],&pPrev->zName[nD],nPrev)==0
234 && (pFile->zName[nD+nPrev]==0 || pFile->zName[nD+nPrev]=='/')
235 ){
236 continue;
237 }
238 db_bind_text(&ins, ":x", &pFile->zName[nD]);
239
+2 -6
--- src/checkin.c
+++ src/checkin.c
@@ -332,26 +332,24 @@
332332
unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
333333
int cwdRelative = 0;
334334
Glob *pIgnore;
335335
Blob rewrittenPathname;
336336
const char *zPathname, *zDisplayName;
337
- int caseSensitive;
338337
339338
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
340339
capture_case_sensitive_option();
341340
db_must_be_within_tree();
342
- caseSensitive = filenames_are_case_sensitive();
343341
cwdRelative = determine_cwd_relative_option();
344342
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
345343
filename_collation());
346344
n = strlen(g.zLocalRoot);
347345
blob_init(&path, g.zLocalRoot, n-1);
348346
if( zIgnoreFlag==0 ){
349347
zIgnoreFlag = db_get("ignore-glob", 0);
350348
}
351349
pIgnore = glob_create(zIgnoreFlag);
352
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive);
350
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
353351
glob_free(pIgnore);
354352
db_prepare(&q,
355353
"SELECT x FROM sfile"
356354
" WHERE x NOT IN (%s)"
357355
" ORDER BY 1",
@@ -413,29 +411,27 @@
413411
Blob path, repo;
414412
Stmt q;
415413
int n;
416414
Glob *pIgnore;
417415
int testFlag = 0;
418
- int caseSensitive;
419416
420417
allFlag = find_option("force","f",0)!=0;
421418
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
422419
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
423420
zIgnoreFlag = find_option("ignore",0,1);
424421
testFlag = find_option("test",0,0)!=0;
425422
capture_case_sensitive_option();
426423
db_must_be_within_tree();
427
- caseSensitive = filenames_are_case_sensitive();
428424
if( zIgnoreFlag==0 ){
429425
zIgnoreFlag = db_get("ignore-glob", 0);
430426
}
431427
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
432428
filename_collation());
433429
n = strlen(g.zLocalRoot);
434430
blob_init(&path, g.zLocalRoot, n-1);
435431
pIgnore = glob_create(zIgnoreFlag);
436
- vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive);
432
+ vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
437433
glob_free(pIgnore);
438434
db_prepare(&q,
439435
"SELECT %Q || x FROM sfile"
440436
" WHERE x NOT IN (%s)"
441437
" ORDER BY 1",
442438
--- src/checkin.c
+++ src/checkin.c
@@ -332,26 +332,24 @@
332 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
333 int cwdRelative = 0;
334 Glob *pIgnore;
335 Blob rewrittenPathname;
336 const char *zPathname, *zDisplayName;
337 int caseSensitive;
338
339 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
340 capture_case_sensitive_option();
341 db_must_be_within_tree();
342 caseSensitive = filenames_are_case_sensitive();
343 cwdRelative = determine_cwd_relative_option();
344 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
345 filename_collation());
346 n = strlen(g.zLocalRoot);
347 blob_init(&path, g.zLocalRoot, n-1);
348 if( zIgnoreFlag==0 ){
349 zIgnoreFlag = db_get("ignore-glob", 0);
350 }
351 pIgnore = glob_create(zIgnoreFlag);
352 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive);
353 glob_free(pIgnore);
354 db_prepare(&q,
355 "SELECT x FROM sfile"
356 " WHERE x NOT IN (%s)"
357 " ORDER BY 1",
@@ -413,29 +411,27 @@
413 Blob path, repo;
414 Stmt q;
415 int n;
416 Glob *pIgnore;
417 int testFlag = 0;
418 int caseSensitive;
419
420 allFlag = find_option("force","f",0)!=0;
421 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
422 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
423 zIgnoreFlag = find_option("ignore",0,1);
424 testFlag = find_option("test",0,0)!=0;
425 capture_case_sensitive_option();
426 db_must_be_within_tree();
427 caseSensitive = filenames_are_case_sensitive();
428 if( zIgnoreFlag==0 ){
429 zIgnoreFlag = db_get("ignore-glob", 0);
430 }
431 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
432 filename_collation());
433 n = strlen(g.zLocalRoot);
434 blob_init(&path, g.zLocalRoot, n-1);
435 pIgnore = glob_create(zIgnoreFlag);
436 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore, caseSensitive);
437 glob_free(pIgnore);
438 db_prepare(&q,
439 "SELECT %Q || x FROM sfile"
440 " WHERE x NOT IN (%s)"
441 " ORDER BY 1",
442
--- src/checkin.c
+++ src/checkin.c
@@ -332,26 +332,24 @@
332 unsigned scanFlags = find_option("dotfiles",0,0)!=0 ? SCAN_ALL : 0;
333 int cwdRelative = 0;
334 Glob *pIgnore;
335 Blob rewrittenPathname;
336 const char *zPathname, *zDisplayName;
 
337
338 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
339 capture_case_sensitive_option();
340 db_must_be_within_tree();
 
341 cwdRelative = determine_cwd_relative_option();
342 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
343 filename_collation());
344 n = strlen(g.zLocalRoot);
345 blob_init(&path, g.zLocalRoot, n-1);
346 if( zIgnoreFlag==0 ){
347 zIgnoreFlag = db_get("ignore-glob", 0);
348 }
349 pIgnore = glob_create(zIgnoreFlag);
350 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
351 glob_free(pIgnore);
352 db_prepare(&q,
353 "SELECT x FROM sfile"
354 " WHERE x NOT IN (%s)"
355 " ORDER BY 1",
@@ -413,29 +411,27 @@
411 Blob path, repo;
412 Stmt q;
413 int n;
414 Glob *pIgnore;
415 int testFlag = 0;
 
416
417 allFlag = find_option("force","f",0)!=0;
418 if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
419 if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
420 zIgnoreFlag = find_option("ignore",0,1);
421 testFlag = find_option("test",0,0)!=0;
422 capture_case_sensitive_option();
423 db_must_be_within_tree();
 
424 if( zIgnoreFlag==0 ){
425 zIgnoreFlag = db_get("ignore-glob", 0);
426 }
427 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
428 filename_collation());
429 n = strlen(g.zLocalRoot);
430 blob_init(&path, g.zLocalRoot, n-1);
431 pIgnore = glob_create(zIgnoreFlag);
432 vfile_scan(&path, blob_size(&path), scanFlags, pIgnore);
433 glob_free(pIgnore);
434 db_prepare(&q,
435 "SELECT %Q || x FROM sfile"
436 " WHERE x NOT IN (%s)"
437 " ORDER BY 1",
438
+2 -4
--- src/merge.c
+++ src/merge.c
@@ -113,11 +113,10 @@
113113
int nChng; /* Number of file name changes */
114114
int *aChng; /* An array of file name changes */
115115
int i; /* Loop counter */
116116
int nConflict = 0; /* Number of conflicts seen */
117117
int nOverwrite = 0; /* Number of unmanaged files overwritten */
118
- int caseSensitive; /* True for case-sensitive filenames */
119118
Stmt q;
120119
121120
122121
/* Notation:
123122
**
@@ -136,11 +135,10 @@
136135
forceFlag = find_option("force","f",0)!=0;
137136
zPivot = find_option("baseline",0,1);
138137
capture_case_sensitive_option();
139138
verify_all_options();
140139
db_must_be_within_tree();
141
- caseSensitive = filenames_are_case_sensitive();
142140
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
143141
vid = db_lget_int("checkout", 0);
144142
if( vid==0 ){
145143
fossil_fatal("nothing is checked out");
146144
}
@@ -275,11 +273,11 @@
275273
** in the current checkout, the pivot, and the version being merged.
276274
*/
277275
db_multi_exec(
278276
"DROP TABLE IF EXISTS fv;"
279277
"CREATE TEMP TABLE fv("
280
- " fn TEXT PRIMARY KEY COLLATE %s," /* The filename */
278
+ " fn TEXT PRIMARY KEY %s," /* The filename */
281279
" idv INTEGER," /* VFILE entry for current version */
282280
" idp INTEGER," /* VFILE entry for the pivot */
283281
" idm INTEGER," /* VFILE entry for version merging in */
284282
" chnged BOOLEAN," /* True if current version has been edited */
285283
" ridv INTEGER," /* Record ID for current version */
@@ -289,11 +287,11 @@
289287
" fnp TEXT," /* The filename in the pivot */
290288
" fnm TEXT," /* the filename in the merged version */
291289
" islinkv BOOLEAN," /* True if current version is a symlink */
292290
" islinkm BOOLEAN" /* True if merged version in is a symlink */
293291
");",
294
- caseSensitive ? "binary" : "nocase"
292
+ filename_collation()
295293
);
296294
297295
/* Add files found in V
298296
*/
299297
db_multi_exec(
300298
--- src/merge.c
+++ src/merge.c
@@ -113,11 +113,10 @@
113 int nChng; /* Number of file name changes */
114 int *aChng; /* An array of file name changes */
115 int i; /* Loop counter */
116 int nConflict = 0; /* Number of conflicts seen */
117 int nOverwrite = 0; /* Number of unmanaged files overwritten */
118 int caseSensitive; /* True for case-sensitive filenames */
119 Stmt q;
120
121
122 /* Notation:
123 **
@@ -136,11 +135,10 @@
136 forceFlag = find_option("force","f",0)!=0;
137 zPivot = find_option("baseline",0,1);
138 capture_case_sensitive_option();
139 verify_all_options();
140 db_must_be_within_tree();
141 caseSensitive = filenames_are_case_sensitive();
142 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
143 vid = db_lget_int("checkout", 0);
144 if( vid==0 ){
145 fossil_fatal("nothing is checked out");
146 }
@@ -275,11 +273,11 @@
275 ** in the current checkout, the pivot, and the version being merged.
276 */
277 db_multi_exec(
278 "DROP TABLE IF EXISTS fv;"
279 "CREATE TEMP TABLE fv("
280 " fn TEXT PRIMARY KEY COLLATE %s," /* The filename */
281 " idv INTEGER," /* VFILE entry for current version */
282 " idp INTEGER," /* VFILE entry for the pivot */
283 " idm INTEGER," /* VFILE entry for version merging in */
284 " chnged BOOLEAN," /* True if current version has been edited */
285 " ridv INTEGER," /* Record ID for current version */
@@ -289,11 +287,11 @@
289 " fnp TEXT," /* The filename in the pivot */
290 " fnm TEXT," /* the filename in the merged version */
291 " islinkv BOOLEAN," /* True if current version is a symlink */
292 " islinkm BOOLEAN" /* True if merged version in is a symlink */
293 ");",
294 caseSensitive ? "binary" : "nocase"
295 );
296
297 /* Add files found in V
298 */
299 db_multi_exec(
300
--- src/merge.c
+++ src/merge.c
@@ -113,11 +113,10 @@
113 int nChng; /* Number of file name changes */
114 int *aChng; /* An array of file name changes */
115 int i; /* Loop counter */
116 int nConflict = 0; /* Number of conflicts seen */
117 int nOverwrite = 0; /* Number of unmanaged files overwritten */
 
118 Stmt q;
119
120
121 /* Notation:
122 **
@@ -136,11 +135,10 @@
135 forceFlag = find_option("force","f",0)!=0;
136 zPivot = find_option("baseline",0,1);
137 capture_case_sensitive_option();
138 verify_all_options();
139 db_must_be_within_tree();
 
140 if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
141 vid = db_lget_int("checkout", 0);
142 if( vid==0 ){
143 fossil_fatal("nothing is checked out");
144 }
@@ -275,11 +273,11 @@
273 ** in the current checkout, the pivot, and the version being merged.
274 */
275 db_multi_exec(
276 "DROP TABLE IF EXISTS fv;"
277 "CREATE TEMP TABLE fv("
278 " fn TEXT PRIMARY KEY %s," /* The filename */
279 " idv INTEGER," /* VFILE entry for current version */
280 " idp INTEGER," /* VFILE entry for the pivot */
281 " idm INTEGER," /* VFILE entry for version merging in */
282 " chnged BOOLEAN," /* True if current version has been edited */
283 " ridv INTEGER," /* Record ID for current version */
@@ -289,11 +287,11 @@
287 " fnp TEXT," /* The filename in the pivot */
288 " fnm TEXT," /* the filename in the merged version */
289 " islinkv BOOLEAN," /* True if current version is a symlink */
290 " islinkm BOOLEAN" /* True if merged version in is a symlink */
291 ");",
292 filename_collation()
293 );
294
295 /* Add files found in V
296 */
297 db_multi_exec(
298
+3 -4
--- src/vfile.c
+++ src/vfile.c
@@ -432,12 +432,11 @@
432432
**
433433
** Any files or directories that match the glob pattern pIgnore are
434434
** excluded from the scan. Name matching occurs after the first
435435
** nPrefix characters are elided from the filename.
436436
*/
437
-void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore,
438
- int caseSensitive){
437
+void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){
439438
DIR *d;
440439
int origSize;
441440
const char *zDir;
442441
struct dirent *pEntry;
443442
int skipAll = 0;
@@ -455,11 +454,11 @@
455454
456455
if( depth==0 ){
457456
db_prepare(&ins,
458457
"INSERT OR IGNORE INTO sfile(x) SELECT :file"
459458
" WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
460
- " pathname=:file %s)", caseSensitive ? "" : "COLLATE nocase"
459
+ " pathname=:file %s)", filename_collation()
461460
);
462461
}
463462
depth++;
464463
465464
zDir = blob_str(pPath);
@@ -479,11 +478,11 @@
479478
zPath = blob_str(pPath);
480479
if( glob_match(pIgnore, &zPath[nPrefix+1]) ){
481480
/* do nothing */
482481
}else if( file_wd_isdir(zPath)==1 ){
483482
if( !vfile_top_of_checkout(zPath) ){
484
- vfile_scan(pPath, nPrefix, scanFlags, pIgnore, caseSensitive);
483
+ vfile_scan(pPath, nPrefix, scanFlags, pIgnore);
485484
}
486485
}else if( file_wd_isfile_or_link(zPath) ){
487486
if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
488487
db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
489488
db_step(&ins);
490489
--- src/vfile.c
+++ src/vfile.c
@@ -432,12 +432,11 @@
432 **
433 ** Any files or directories that match the glob pattern pIgnore are
434 ** excluded from the scan. Name matching occurs after the first
435 ** nPrefix characters are elided from the filename.
436 */
437 void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore,
438 int caseSensitive){
439 DIR *d;
440 int origSize;
441 const char *zDir;
442 struct dirent *pEntry;
443 int skipAll = 0;
@@ -455,11 +454,11 @@
455
456 if( depth==0 ){
457 db_prepare(&ins,
458 "INSERT OR IGNORE INTO sfile(x) SELECT :file"
459 " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
460 " pathname=:file %s)", caseSensitive ? "" : "COLLATE nocase"
461 );
462 }
463 depth++;
464
465 zDir = blob_str(pPath);
@@ -479,11 +478,11 @@
479 zPath = blob_str(pPath);
480 if( glob_match(pIgnore, &zPath[nPrefix+1]) ){
481 /* do nothing */
482 }else if( file_wd_isdir(zPath)==1 ){
483 if( !vfile_top_of_checkout(zPath) ){
484 vfile_scan(pPath, nPrefix, scanFlags, pIgnore, caseSensitive);
485 }
486 }else if( file_wd_isfile_or_link(zPath) ){
487 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
488 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
489 db_step(&ins);
490
--- src/vfile.c
+++ src/vfile.c
@@ -432,12 +432,11 @@
432 **
433 ** Any files or directories that match the glob pattern pIgnore are
434 ** excluded from the scan. Name matching occurs after the first
435 ** nPrefix characters are elided from the filename.
436 */
437 void vfile_scan(Blob *pPath, int nPrefix, unsigned scanFlags, Glob *pIgnore){
 
438 DIR *d;
439 int origSize;
440 const char *zDir;
441 struct dirent *pEntry;
442 int skipAll = 0;
@@ -455,11 +454,11 @@
454
455 if( depth==0 ){
456 db_prepare(&ins,
457 "INSERT OR IGNORE INTO sfile(x) SELECT :file"
458 " WHERE NOT EXISTS(SELECT 1 FROM vfile WHERE"
459 " pathname=:file %s)", filename_collation()
460 );
461 }
462 depth++;
463
464 zDir = blob_str(pPath);
@@ -479,11 +478,11 @@
478 zPath = blob_str(pPath);
479 if( glob_match(pIgnore, &zPath[nPrefix+1]) ){
480 /* do nothing */
481 }else if( file_wd_isdir(zPath)==1 ){
482 if( !vfile_top_of_checkout(zPath) ){
483 vfile_scan(pPath, nPrefix, scanFlags, pIgnore);
484 }
485 }else if( file_wd_isfile_or_link(zPath) ){
486 if( (scanFlags & SCAN_TEMP)==0 || is_temporary_file(zUtf8) ){
487 db_bind_text(&ins, ":file", &zPath[nPrefix+1]);
488 db_step(&ins);
489

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button