Fossil SCM

Some case insensitive filesystems notice when they are about to overwrite a file due to case folding, and change the name. Fossil then thinks a file is missing, so this warning helps when writing files for checkout, update and merge. From libfossil Unicode work.

danshearer 2026-11-16 12:05 UTC unicode-fixes
Commit 53228924e443e7373f9bfc0fda99c6df29ec7c075a0e734618becb6b11a21405
--- src/checkout.c
+++ src/checkout.c
@@ -358,10 +358,11 @@
358358
uncheckout(prior);
359359
}
360360
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
361361
if( !keepFlag ){
362362
vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
363
+ vfile_check_names_on_disk(vid);
363364
}
364365
checkout_set_all_exe(vid);
365366
ensure_empty_dirs_created(0);
366367
db_set_checkout(vid, 1);
367368
undo_reset();
368369
--- src/checkout.c
+++ src/checkout.c
@@ -358,10 +358,11 @@
358 uncheckout(prior);
359 }
360 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
361 if( !keepFlag ){
362 vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
 
363 }
364 checkout_set_all_exe(vid);
365 ensure_empty_dirs_created(0);
366 db_set_checkout(vid, 1);
367 undo_reset();
368
--- src/checkout.c
+++ src/checkout.c
@@ -358,10 +358,11 @@
358 uncheckout(prior);
359 }
360 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
361 if( !keepFlag ){
362 vfile_to_disk(vid, 0, !g.fQuiet, promptFlag);
363 vfile_check_names_on_disk(vid);
364 }
365 checkout_set_all_exe(vid);
366 ensure_empty_dirs_created(0);
367 db_set_checkout(vid, 1);
368 undo_reset();
369
--- src/merge.c
+++ src/merge.c
@@ -1757,9 +1757,10 @@
17571757
}
17581758
if( bMultiMerge && nConflict==0 ){
17591759
nMerge++;
17601760
goto merge_next_child;
17611761
}
1762
+ if( !dryRunFlag ) vfile_check_names_on_disk(vid);
17621763
if( useUndo ) undo_finish();
17631764
17641765
db_end_transaction(dryRunFlag);
17651766
}
17661767
--- src/merge.c
+++ src/merge.c
@@ -1757,9 +1757,10 @@
1757 }
1758 if( bMultiMerge && nConflict==0 ){
1759 nMerge++;
1760 goto merge_next_child;
1761 }
 
1762 if( useUndo ) undo_finish();
1763
1764 db_end_transaction(dryRunFlag);
1765 }
1766
--- src/merge.c
+++ src/merge.c
@@ -1757,9 +1757,10 @@
1757 }
1758 if( bMultiMerge && nConflict==0 ){
1759 nMerge++;
1760 goto merge_next_child;
1761 }
1762 if( !dryRunFlag ) vfile_check_names_on_disk(vid);
1763 if( useUndo ) undo_finish();
1764
1765 db_end_transaction(dryRunFlag);
1766 }
1767
--- src/update.c
+++ src/update.c
@@ -700,10 +700,11 @@
700700
);
701701
fossil_free(zPwd);
702702
if( g.argc<=3 ){
703703
/* All files updated. Shift the current check-out to the target. */
704704
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
705
+ vfile_check_names_on_disk(tid);
705706
checkout_set_all_exe(tid);
706707
db_set_checkout(tid, 1);
707708
}else{
708709
/* A subset of files have been checked out. Keep the current
709710
** check-out unchanged. */
710711
--- src/update.c
+++ src/update.c
@@ -700,10 +700,11 @@
700 );
701 fossil_free(zPwd);
702 if( g.argc<=3 ){
703 /* All files updated. Shift the current check-out to the target. */
704 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
 
705 checkout_set_all_exe(tid);
706 db_set_checkout(tid, 1);
707 }else{
708 /* A subset of files have been checked out. Keep the current
709 ** check-out unchanged. */
710
--- src/update.c
+++ src/update.c
@@ -700,10 +700,11 @@
700 );
701 fossil_free(zPwd);
702 if( g.argc<=3 ){
703 /* All files updated. Shift the current check-out to the target. */
704 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
705 vfile_check_names_on_disk(tid);
706 checkout_set_all_exe(tid);
707 db_set_checkout(tid, 1);
708 }else{
709 /* A subset of files have been checked out. Keep the current
710 ** check-out unchanged. */
711
+68
--- src/vfile.c
+++ src/vfile.c
@@ -339,10 +339,78 @@
339339
" the ability, turn the case-sensitive setting on.",
340340
blob_str(&bad));
341341
}
342342
blob_reset(&bad);
343343
}
344
+
345
+/*
346
+** After files of check-out vid have been written to disk, warn about
347
+** if the filesystem has changed any names. Some case-insensitive
348
+** filesystems do this when they notice that they would treats
349
+** two names as one file. Fossil will then report a missing file,
350
+** which this warning explains.
351
+*/
352
+void vfile_check_names_on_disk(int vid){
353
+ Stmt q, ins;
354
+ db_multi_exec(
355
+ "CREATE TEMP TABLE IF NOT EXISTS ondisk(dir TEXT, name TEXT);"
356
+ "DELETE FROM ondisk;"
357
+ "CREATE TEMP TABLE IF NOT EXISTS namecheck(pathname TEXT, dir TEXT,"
358
+ " tail TEXT);"
359
+ "DELETE FROM namecheck;"
360
+ "INSERT INTO namecheck(pathname,dir,tail)"
361
+ " SELECT pathname,"
362
+ " rtrim(pathname, replace(pathname,'/','')),"
363
+ " replace(pathname, rtrim(pathname, replace(pathname,'/','')), '')"
364
+ " FROM vfile"
365
+ " WHERE vid=%d AND NOT deleted"
366
+ " AND (pathname GLOB '*[^ -~]*'"
367
+ " OR unicode_casefold(pathname) IN"
368
+ " (SELECT unicode_casefold(pathname) FROM vfile"
369
+ " WHERE vid=%d AND NOT deleted"
370
+ " GROUP BY 1 HAVING count(*)>1));",
371
+ vid, vid
372
+ );
373
+ db_prepare(&ins, "INSERT INTO ondisk(dir,name) VALUES(:dir,:name)");
374
+ db_prepare(&q, "SELECT DISTINCT dir FROM namecheck ORDER BY dir");
375
+ while( db_step(&q)==SQLITE_ROW ){
376
+ const char *zDir = db_column_text(&q, 0);
377
+ char *zFull = mprintf("%s%s", g.zLocalRoot, zDir);
378
+ void *zNative = fossil_utf8_to_path(zFull, 1);
379
+ DIR *d = opendir(zNative);
380
+ if( d ){
381
+ struct dirent *pEntry;
382
+ while( (pEntry=readdir(d))!=0 ){
383
+ char *zUtf8 = fossil_path_to_utf8(pEntry->d_name);
384
+ db_bind_text(&ins, ":dir", zDir);
385
+ db_bind_text(&ins, ":name", zUtf8);
386
+ db_step(&ins);
387
+ db_reset(&ins);
388
+ fossil_path_free(zUtf8);
389
+ }
390
+ closedir(d);
391
+ }
392
+ fossil_path_free(zNative);
393
+ fossil_free(zFull);
394
+ }
395
+ db_finalize(&q);
396
+ db_finalize(&ins);
397
+ db_prepare(&q,
398
+ "SELECT pathname FROM namecheck"
399
+ " WHERE NOT EXISTS(SELECT 1 FROM ondisk"
400
+ " WHERE ondisk.dir=namecheck.dir"
401
+ " AND ondisk.name=namecheck.tail)"
402
+ " ORDER BY pathname");
403
+ while( db_step(&q)==SQLITE_ROW ){
404
+ fossil_warning("WARNING: the file system did not keep the name \"%s\""
405
+ " as written. It may treat the name as the same file as"
406
+ " another name that differs only in letter case or"
407
+ " Unicode normalization.",
408
+ db_column_text(&q, 0));
409
+ }
410
+ db_finalize(&q);
411
+}
344412
345413
/*
346414
** Write all files from vid to the disk. Or if vid==0 and id!=0
347415
** write just the specific file where VFILE.ID=id.
348416
*/
349417
--- src/vfile.c
+++ src/vfile.c
@@ -339,10 +339,78 @@
339 " the ability, turn the case-sensitive setting on.",
340 blob_str(&bad));
341 }
342 blob_reset(&bad);
343 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
345 /*
346 ** Write all files from vid to the disk. Or if vid==0 and id!=0
347 ** write just the specific file where VFILE.ID=id.
348 */
349
--- src/vfile.c
+++ src/vfile.c
@@ -339,10 +339,78 @@
339 " the ability, turn the case-sensitive setting on.",
340 blob_str(&bad));
341 }
342 blob_reset(&bad);
343 }
344
345 /*
346 ** After files of check-out vid have been written to disk, warn about
347 ** if the filesystem has changed any names. Some case-insensitive
348 ** filesystems do this when they notice that they would treats
349 ** two names as one file. Fossil will then report a missing file,
350 ** which this warning explains.
351 */
352 void vfile_check_names_on_disk(int vid){
353 Stmt q, ins;
354 db_multi_exec(
355 "CREATE TEMP TABLE IF NOT EXISTS ondisk(dir TEXT, name TEXT);"
356 "DELETE FROM ondisk;"
357 "CREATE TEMP TABLE IF NOT EXISTS namecheck(pathname TEXT, dir TEXT,"
358 " tail TEXT);"
359 "DELETE FROM namecheck;"
360 "INSERT INTO namecheck(pathname,dir,tail)"
361 " SELECT pathname,"
362 " rtrim(pathname, replace(pathname,'/','')),"
363 " replace(pathname, rtrim(pathname, replace(pathname,'/','')), '')"
364 " FROM vfile"
365 " WHERE vid=%d AND NOT deleted"
366 " AND (pathname GLOB '*[^ -~]*'"
367 " OR unicode_casefold(pathname) IN"
368 " (SELECT unicode_casefold(pathname) FROM vfile"
369 " WHERE vid=%d AND NOT deleted"
370 " GROUP BY 1 HAVING count(*)>1));",
371 vid, vid
372 );
373 db_prepare(&ins, "INSERT INTO ondisk(dir,name) VALUES(:dir,:name)");
374 db_prepare(&q, "SELECT DISTINCT dir FROM namecheck ORDER BY dir");
375 while( db_step(&q)==SQLITE_ROW ){
376 const char *zDir = db_column_text(&q, 0);
377 char *zFull = mprintf("%s%s", g.zLocalRoot, zDir);
378 void *zNative = fossil_utf8_to_path(zFull, 1);
379 DIR *d = opendir(zNative);
380 if( d ){
381 struct dirent *pEntry;
382 while( (pEntry=readdir(d))!=0 ){
383 char *zUtf8 = fossil_path_to_utf8(pEntry->d_name);
384 db_bind_text(&ins, ":dir", zDir);
385 db_bind_text(&ins, ":name", zUtf8);
386 db_step(&ins);
387 db_reset(&ins);
388 fossil_path_free(zUtf8);
389 }
390 closedir(d);
391 }
392 fossil_path_free(zNative);
393 fossil_free(zFull);
394 }
395 db_finalize(&q);
396 db_finalize(&ins);
397 db_prepare(&q,
398 "SELECT pathname FROM namecheck"
399 " WHERE NOT EXISTS(SELECT 1 FROM ondisk"
400 " WHERE ondisk.dir=namecheck.dir"
401 " AND ondisk.name=namecheck.tail)"
402 " ORDER BY pathname");
403 while( db_step(&q)==SQLITE_ROW ){
404 fossil_warning("WARNING: the file system did not keep the name \"%s\""
405 " as written. It may treat the name as the same file as"
406 " another name that differs only in letter case or"
407 " Unicode normalization.",
408 db_column_text(&q, 0));
409 }
410 db_finalize(&q);
411 }
412
413 /*
414 ** Write all files from vid to the disk. Or if vid==0 and id!=0
415 ** write just the specific file where VFILE.ID=id.
416 */
417

Keyboard Shortcuts

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