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".
Commit
93f370a80c5f4cc98d23140fee290cfe3432511e
Parent
7ae19e56ba36cd3…
1 file changed
+10
-5
+10
-5
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -562,11 +562,12 @@ | ||
| 562 | 562 | ** Rename a single file. |
| 563 | 563 | ** |
| 564 | 564 | ** The original name of the file is zOrig. The new filename is zNew. |
| 565 | 565 | */ |
| 566 | 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); | |
| 567 | + int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s", | |
| 568 | + zNew, filename_collation()); | |
| 568 | 569 | if( x>=0 ){ |
| 569 | 570 | if( x==0 ){ |
| 570 | 571 | fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'" |
| 571 | 572 | " is currently under management", zOrig, zNew, zNew); |
| 572 | 573 | }else{ |
| @@ -574,12 +575,12 @@ | ||
| 574 | 575 | "not yet been committed", zOrig, zNew, zNew); |
| 575 | 576 | } |
| 576 | 577 | } |
| 577 | 578 | fossil_print("RENAME %s %s\n", zOrig, zNew); |
| 578 | 579 | 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 | |
| 581 | 582 | ); |
| 582 | 583 | } |
| 583 | 584 | |
| 584 | 585 | /* |
| 585 | 586 | ** COMMAND: mv |
| @@ -593,19 +594,23 @@ | ||
| 593 | 594 | ** |
| 594 | 595 | ** This command does NOT rename or move the files on disk. This command merely |
| 595 | 596 | ** records the fact that filenames have changed so that appropriate notations |
| 596 | 597 | ** can be made at the next commit/checkin. |
| 597 | 598 | ** |
| 599 | +** Options: | |
| 600 | +** --case-sensitive <BOOL> override case-sensitive setting | |
| 601 | +** | |
| 598 | 602 | ** See also: changes, status |
| 599 | 603 | */ |
| 600 | 604 | void mv_cmd(void){ |
| 601 | 605 | int i; |
| 602 | 606 | int vid; |
| 603 | 607 | char *zDest; |
| 604 | 608 | Blob dest; |
| 605 | 609 | Stmt q; |
| 606 | 610 | |
| 611 | + capture_case_sensitive_option(); | |
| 607 | 612 | db_must_be_within_tree(); |
| 608 | 613 | vid = db_lget_int("checkout", 0); |
| 609 | 614 | if( vid==0 ){ |
| 610 | 615 | fossil_panic("no checkout rename files in"); |
| 611 | 616 | } |
| @@ -644,13 +649,13 @@ | ||
| 644 | 649 | zOrig = blob_str(&orig); |
| 645 | 650 | nOrig = blob_size(&orig); |
| 646 | 651 | db_prepare(&q, |
| 647 | 652 | "SELECT pathname FROM vfile" |
| 648 | 653 | " WHERE vid=%d" |
| 649 | - " AND (pathname='%q' OR (pathname>'%q/' AND pathname<'%q0'))" | |
| 654 | + " AND (pathname='%q' %s OR (pathname>'%q/' AND pathname<'%q0'))" | |
| 650 | 655 | " ORDER BY 1", |
| 651 | - vid, zOrig, zOrig, zOrig | |
| 656 | + vid, zOrig, filename_collation(), zOrig, zOrig | |
| 652 | 657 | ); |
| 653 | 658 | while( db_step(&q)==SQLITE_ROW ){ |
| 654 | 659 | const char *zPath = db_column_text(&q, 0); |
| 655 | 660 | int nPath = db_column_bytes(&q, 0); |
| 656 | 661 | const char *zTail; |
| 657 | 662 |
| --- 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 |