Fossil SCM

Make "fossil mv src/FOO.c src/bar.c" work as expected on case-insensitive filesystems. Add --case-sensitive option to "fossil mv".

jan.nijtmans 2013-05-31 12:50 trunk
Commit 93f370a80c5f4cc98d23140fee290cfe3432511e
1 file changed +10 -5
+10 -5
--- src/add.c
+++ src/add.c
@@ -562,11 +562,12 @@
562562
** Rename a single file.
563563
**
564564
** The original name of the file is zOrig. The new filename is zNew.
565565
*/
566566
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
567
- int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q", zNew);
567
+ int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
568
+ zNew, filename_collation());
568569
if( x>=0 ){
569570
if( x==0 ){
570571
fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'"
571572
" is currently under management", zOrig, zNew, zNew);
572573
}else{
@@ -574,12 +575,12 @@
574575
"not yet been committed", zOrig, zNew, zNew);
575576
}
576577
}
577578
fossil_print("RENAME %s %s\n", zOrig, zNew);
578579
db_multi_exec(
579
- "UPDATE vfile SET pathname='%q' WHERE pathname='%q' AND vid=%d",
580
- zNew, zOrig, vid
580
+ "UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
581
+ zNew, zOrig, filename_collation(), vid
581582
);
582583
}
583584
584585
/*
585586
** COMMAND: mv
@@ -593,19 +594,23 @@
593594
**
594595
** This command does NOT rename or move the files on disk. This command merely
595596
** records the fact that filenames have changed so that appropriate notations
596597
** can be made at the next commit/checkin.
597598
**
599
+** Options:
600
+** --case-sensitive <BOOL> override case-sensitive setting
601
+**
598602
** See also: changes, status
599603
*/
600604
void mv_cmd(void){
601605
int i;
602606
int vid;
603607
char *zDest;
604608
Blob dest;
605609
Stmt q;
606610
611
+ capture_case_sensitive_option();
607612
db_must_be_within_tree();
608613
vid = db_lget_int("checkout", 0);
609614
if( vid==0 ){
610615
fossil_panic("no checkout rename files in");
611616
}
@@ -644,13 +649,13 @@
644649
zOrig = blob_str(&orig);
645650
nOrig = blob_size(&orig);
646651
db_prepare(&q,
647652
"SELECT pathname FROM vfile"
648653
" WHERE vid=%d"
649
- " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))"
654
+ " AND (pathname='%q' %s OR (pathname>'%q/' AND pathname<'%q0'))"
650655
" ORDER BY 1",
651
- vid, zOrig, zOrig, zOrig
656
+ vid, zOrig, filename_collation(), zOrig, zOrig
652657
);
653658
while( db_step(&q)==SQLITE_ROW ){
654659
const char *zPath = db_column_text(&q, 0);
655660
int nPath = db_column_bytes(&q, 0);
656661
const char *zTail;
657662
--- src/add.c
+++ src/add.c
@@ -562,11 +562,12 @@
562 ** Rename a single file.
563 **
564 ** The original name of the file is zOrig. The new filename is zNew.
565 */
566 static void mv_one_file(int vid, const char *zOrig, const char *zNew){
567 int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q", zNew);
 
568 if( x>=0 ){
569 if( x==0 ){
570 fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'"
571 " is currently under management", zOrig, zNew, zNew);
572 }else{
@@ -574,12 +575,12 @@
574 "not yet been committed", zOrig, zNew, zNew);
575 }
576 }
577 fossil_print("RENAME %s %s\n", zOrig, zNew);
578 db_multi_exec(
579 "UPDATE vfile SET pathname='%q' WHERE pathname='%q' AND vid=%d",
580 zNew, zOrig, vid
581 );
582 }
583
584 /*
585 ** COMMAND: mv
@@ -593,19 +594,23 @@
593 **
594 ** This command does NOT rename or move the files on disk. This command merely
595 ** records the fact that filenames have changed so that appropriate notations
596 ** can be made at the next commit/checkin.
597 **
 
 
 
598 ** See also: changes, status
599 */
600 void mv_cmd(void){
601 int i;
602 int vid;
603 char *zDest;
604 Blob dest;
605 Stmt q;
606
 
607 db_must_be_within_tree();
608 vid = db_lget_int("checkout", 0);
609 if( vid==0 ){
610 fossil_panic("no checkout rename files in");
611 }
@@ -644,13 +649,13 @@
644 zOrig = blob_str(&orig);
645 nOrig = blob_size(&orig);
646 db_prepare(&q,
647 "SELECT pathname FROM vfile"
648 " WHERE vid=%d"
649 " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))"
650 " ORDER BY 1",
651 vid, zOrig, zOrig, zOrig
652 );
653 while( db_step(&q)==SQLITE_ROW ){
654 const char *zPath = db_column_text(&q, 0);
655 int nPath = db_column_bytes(&q, 0);
656 const char *zTail;
657
--- src/add.c
+++ src/add.c
@@ -562,11 +562,12 @@
562 ** Rename a single file.
563 **
564 ** The original name of the file is zOrig. The new filename is zNew.
565 */
566 static void mv_one_file(int vid, const char *zOrig, const char *zNew){
567 int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
568 zNew, filename_collation());
569 if( x>=0 ){
570 if( x==0 ){
571 fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'"
572 " is currently under management", zOrig, zNew, zNew);
573 }else{
@@ -574,12 +575,12 @@
575 "not yet been committed", zOrig, zNew, zNew);
576 }
577 }
578 fossil_print("RENAME %s %s\n", zOrig, zNew);
579 db_multi_exec(
580 "UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
581 zNew, zOrig, filename_collation(), vid
582 );
583 }
584
585 /*
586 ** COMMAND: mv
@@ -593,19 +594,23 @@
594 **
595 ** This command does NOT rename or move the files on disk. This command merely
596 ** records the fact that filenames have changed so that appropriate notations
597 ** can be made at the next commit/checkin.
598 **
599 ** Options:
600 ** --case-sensitive <BOOL> override case-sensitive setting
601 **
602 ** See also: changes, status
603 */
604 void mv_cmd(void){
605 int i;
606 int vid;
607 char *zDest;
608 Blob dest;
609 Stmt q;
610
611 capture_case_sensitive_option();
612 db_must_be_within_tree();
613 vid = db_lget_int("checkout", 0);
614 if( vid==0 ){
615 fossil_panic("no checkout rename files in");
616 }
@@ -644,13 +649,13 @@
649 zOrig = blob_str(&orig);
650 nOrig = blob_size(&orig);
651 db_prepare(&q,
652 "SELECT pathname FROM vfile"
653 " WHERE vid=%d"
654 " AND (pathname='%q' %s OR (pathname>'%q/' AND pathname<'%q0'))"
655 " ORDER BY 1",
656 vid, zOrig, filename_collation(), zOrig, zOrig
657 );
658 while( db_step(&q)==SQLITE_ROW ){
659 const char *zPath = db_column_text(&q, 0);
660 int nPath = db_column_bytes(&q, 0);
661 const char *zTail;
662

Keyboard Shortcuts

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