Fossil SCM

When the case-sensitive setting is off, refuse a checkout, open or update that would leave two tracked pathnames differing only in case. This causes one of the files to be overwritten.

danshearer 2026-11-16 11:44 UTC unicode-fixes
Commit c37ee27db4f777f14f8b5eb93ef33bb189b4ce59fbb5c3772d1089922611d0d4
--- src/checkout.c
+++ src/checkout.c
@@ -350,10 +350,12 @@
350350
if( prior==vid ){
351351
if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME);
352352
db_end_transaction(0);
353353
return;
354354
}
355
+ vfile_check_case_collisions(
356
+ "SELECT pathname FROM vfile WHERE vid=%d AND NOT deleted", vid);
355357
if( !keepFlag ){
356358
uncheckout(prior);
357359
}
358360
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
359361
if( !keepFlag ){
360362
--- src/checkout.c
+++ src/checkout.c
@@ -350,10 +350,12 @@
350 if( prior==vid ){
351 if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME);
352 db_end_transaction(0);
353 return;
354 }
 
 
355 if( !keepFlag ){
356 uncheckout(prior);
357 }
358 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
359 if( !keepFlag ){
360
--- src/checkout.c
+++ src/checkout.c
@@ -350,10 +350,12 @@
350 if( prior==vid ){
351 if( setmtimeFlag ) vfile_check_signature(vid, CKSIG_SETMTIME);
352 db_end_transaction(0);
353 return;
354 }
355 vfile_check_case_collisions(
356 "SELECT pathname FROM vfile WHERE vid=%d AND NOT deleted", vid);
357 if( !keepFlag ){
358 uncheckout(prior);
359 }
360 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
361 if( !keepFlag ){
362
--- src/update.c
+++ src/update.c
@@ -258,10 +258,16 @@
258258
vfile_check_signature(vid, CKSIG_ENOTFILE);
259259
if( !dryRunFlag && !internalUpdate ) undo_begin();
260260
if( load_vfile_from_rid(tid) && !forceMissingFlag ){
261261
fossil_fatal("missing content, unable to update");
262262
};
263
+ /* Names after the update: the target version filename, and files added
264
+ ** to the check-out but not yet committed. */
265
+ vfile_check_case_collisions(
266
+ "SELECT pathname FROM vfile WHERE vid=%d"
267
+ " UNION SELECT pathname FROM vfile"
268
+ " WHERE vid=%d AND rid=0 AND NOT deleted", tid, vid);
263269
264270
/*
265271
** The record.fn field is used to match files against each other. The
266272
** FV table contains one row for each unique filename in
267273
** in the current check-out, the pivot, and the version being merged.
268274
--- src/update.c
+++ src/update.c
@@ -258,10 +258,16 @@
258 vfile_check_signature(vid, CKSIG_ENOTFILE);
259 if( !dryRunFlag && !internalUpdate ) undo_begin();
260 if( load_vfile_from_rid(tid) && !forceMissingFlag ){
261 fossil_fatal("missing content, unable to update");
262 };
 
 
 
 
 
 
263
264 /*
265 ** The record.fn field is used to match files against each other. The
266 ** FV table contains one row for each unique filename in
267 ** in the current check-out, the pivot, and the version being merged.
268
--- src/update.c
+++ src/update.c
@@ -258,10 +258,16 @@
258 vfile_check_signature(vid, CKSIG_ENOTFILE);
259 if( !dryRunFlag && !internalUpdate ) undo_begin();
260 if( load_vfile_from_rid(tid) && !forceMissingFlag ){
261 fossil_fatal("missing content, unable to update");
262 };
263 /* Names after the update: the target version filename, and files added
264 ** to the check-out but not yet committed. */
265 vfile_check_case_collisions(
266 "SELECT pathname FROM vfile WHERE vid=%d"
267 " UNION SELECT pathname FROM vfile"
268 " WHERE vid=%d AND rid=0 AND NOT deleted", tid, vid);
269
270 /*
271 ** The record.fn field is used to match files against each other. The
272 ** FV table contains one row for each unique filename in
273 ** in the current check-out, the pivot, and the version being merged.
274
+37
--- src/vfile.c
+++ src/vfile.c
@@ -280,10 +280,47 @@
280280
}
281281
db_finalize(&q);
282282
if( nErr ) fossil_fatal("abort due to prior errors");
283283
db_end_transaction(0);
284284
}
285
+
286
+/*
287
+** For a case-insenstive checkout, abort if two pathnames we are about
288
+** to write differ only letter case. These would be just one file on
289
+** disk so one will otherwise get overwritten.
290
+*/
291
+void vfile_check_case_collisions(const char *zFormat, ...){
292
+ Stmt q;
293
+ Blob bad;
294
+ char *zSql;
295
+ va_list ap;
296
+ if( filenames_are_case_sensitive() ) return;
297
+ va_start(ap, zFormat);
298
+ zSql = vmprintf(zFormat, ap);
299
+ va_end(ap);
300
+ blob_init(&bad, 0, 0);
301
+ db_prepare(&q,
302
+ "SELECT group_concat(DISTINCT pathname) FROM (%s)"
303
+ " GROUP BY pathname %s HAVING count(DISTINCT pathname)>1"
304
+ " ORDER BY 1",
305
+ zSql /*safe-for-%s*/, filename_collation()
306
+ );
307
+ while( db_step(&q)==SQLITE_ROW ){
308
+ blob_appendf(&bad, "\n %s", db_column_text(&q, 0));
309
+ }
310
+ db_finalize(&q);
311
+ fossil_free(zSql);
312
+ if( blob_size(&bad) ){
313
+ fossil_fatal("these filenames differ only in case, so this"
314
+ " check-out can hold only one file of each group:%s\n"
315
+ "No files were changed. Rename the files in the"
316
+ " repository to be distinc, or, if this file system has"
317
+ " the ability, turn the case-sensitive setting on.",
318
+ blob_str(&bad));
319
+ }
320
+ blob_reset(&bad);
321
+}
285322
286323
/*
287324
** Write all files from vid to the disk. Or if vid==0 and id!=0
288325
** write just the specific file where VFILE.ID=id.
289326
*/
290327
--- src/vfile.c
+++ src/vfile.c
@@ -280,10 +280,47 @@
280 }
281 db_finalize(&q);
282 if( nErr ) fossil_fatal("abort due to prior errors");
283 db_end_transaction(0);
284 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
286 /*
287 ** Write all files from vid to the disk. Or if vid==0 and id!=0
288 ** write just the specific file where VFILE.ID=id.
289 */
290
--- src/vfile.c
+++ src/vfile.c
@@ -280,10 +280,47 @@
280 }
281 db_finalize(&q);
282 if( nErr ) fossil_fatal("abort due to prior errors");
283 db_end_transaction(0);
284 }
285
286 /*
287 ** For a case-insenstive checkout, abort if two pathnames we are about
288 ** to write differ only letter case. These would be just one file on
289 ** disk so one will otherwise get overwritten.
290 */
291 void vfile_check_case_collisions(const char *zFormat, ...){
292 Stmt q;
293 Blob bad;
294 char *zSql;
295 va_list ap;
296 if( filenames_are_case_sensitive() ) return;
297 va_start(ap, zFormat);
298 zSql = vmprintf(zFormat, ap);
299 va_end(ap);
300 blob_init(&bad, 0, 0);
301 db_prepare(&q,
302 "SELECT group_concat(DISTINCT pathname) FROM (%s)"
303 " GROUP BY pathname %s HAVING count(DISTINCT pathname)>1"
304 " ORDER BY 1",
305 zSql /*safe-for-%s*/, filename_collation()
306 );
307 while( db_step(&q)==SQLITE_ROW ){
308 blob_appendf(&bad, "\n %s", db_column_text(&q, 0));
309 }
310 db_finalize(&q);
311 fossil_free(zSql);
312 if( blob_size(&bad) ){
313 fossil_fatal("these filenames differ only in case, so this"
314 " check-out can hold only one file of each group:%s\n"
315 "No files were changed. Rename the files in the"
316 " repository to be distinc, or, if this file system has"
317 " the ability, turn the case-sensitive setting on.",
318 blob_str(&bad));
319 }
320 blob_reset(&bad);
321 }
322
323 /*
324 ** Write all files from vid to the disk. Or if vid==0 and id!=0
325 ** write just the specific file where VFILE.ID=id.
326 */
327

Keyboard Shortcuts

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