Fossil SCM

Fix the rmdir-on-update so that it works even if the update is occurring in a subdirectory of the repository. Do not remove the subdirectory that is the current working directory even if it is empty.

drh 2019-02-26 20:03 UTC rmdir-on-update
Commit 3275a94436cd9ea56707508709cac95eedb64b181278794d03f5991d9a15719a
1 file changed +6 -1
+6 -1
--- src/update.c
+++ src/update.c
@@ -582,15 +582,20 @@
582582
** Clean up the mid and pid VFILE entries. Then commit the changes.
583583
*/
584584
if( dryRunFlag ){
585585
db_end_transaction(1); /* With --dry-run, rollback changes */
586586
}else{
587
+ char zPwd[2000];
587588
ensure_empty_dirs_created(1);
588589
sqlite3_create_function(g.db, "rmdir", 1, SQLITE_UTF8, 0,
589590
file_rmdir_sql_function, 0, 0);
591
+ zPwd[0] = 0;
592
+ file_getcwd(zPwd, sizeof(zPwd));
590593
db_multi_exec(
591
- "SELECT rmdir(name) FROM dir_to_delete ORDER BY name DESC"
594
+ "SELECT rmdir(%Q||name) FROM dir_to_delete"
595
+ " WHERE (%Q||name)<>%Q ORDER BY name DESC",
596
+ g.zLocalRoot, g.zLocalRoot, zPwd
592597
);
593598
if( g.argc<=3 ){
594599
/* All files updated. Shift the current checkout to the target. */
595600
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
596601
checkout_set_all_exe(tid);
597602
--- src/update.c
+++ src/update.c
@@ -582,15 +582,20 @@
582 ** Clean up the mid and pid VFILE entries. Then commit the changes.
583 */
584 if( dryRunFlag ){
585 db_end_transaction(1); /* With --dry-run, rollback changes */
586 }else{
 
587 ensure_empty_dirs_created(1);
588 sqlite3_create_function(g.db, "rmdir", 1, SQLITE_UTF8, 0,
589 file_rmdir_sql_function, 0, 0);
 
 
590 db_multi_exec(
591 "SELECT rmdir(name) FROM dir_to_delete ORDER BY name DESC"
 
 
592 );
593 if( g.argc<=3 ){
594 /* All files updated. Shift the current checkout to the target. */
595 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
596 checkout_set_all_exe(tid);
597
--- src/update.c
+++ src/update.c
@@ -582,15 +582,20 @@
582 ** Clean up the mid and pid VFILE entries. Then commit the changes.
583 */
584 if( dryRunFlag ){
585 db_end_transaction(1); /* With --dry-run, rollback changes */
586 }else{
587 char zPwd[2000];
588 ensure_empty_dirs_created(1);
589 sqlite3_create_function(g.db, "rmdir", 1, SQLITE_UTF8, 0,
590 file_rmdir_sql_function, 0, 0);
591 zPwd[0] = 0;
592 file_getcwd(zPwd, sizeof(zPwd));
593 db_multi_exec(
594 "SELECT rmdir(%Q||name) FROM dir_to_delete"
595 " WHERE (%Q||name)<>%Q ORDER BY name DESC",
596 g.zLocalRoot, g.zLocalRoot, zPwd
597 );
598 if( g.argc<=3 ){
599 /* All files updated. Shift the current checkout to the target. */
600 db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid);
601 checkout_set_all_exe(tid);
602

Keyboard Shortcuts

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