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.
Commit
3275a94436cd9ea56707508709cac95eedb64b181278794d03f5991d9a15719a
Parent
43111aa93925ca1…
1 file changed
+6
-1
+6
-1
| --- src/update.c | ||
| +++ src/update.c | ||
| @@ -582,15 +582,20 @@ | ||
| 582 | 582 | ** Clean up the mid and pid VFILE entries. Then commit the changes. |
| 583 | 583 | */ |
| 584 | 584 | if( dryRunFlag ){ |
| 585 | 585 | db_end_transaction(1); /* With --dry-run, rollback changes */ |
| 586 | 586 | }else{ |
| 587 | + char zPwd[2000]; | |
| 587 | 588 | ensure_empty_dirs_created(1); |
| 588 | 589 | sqlite3_create_function(g.db, "rmdir", 1, SQLITE_UTF8, 0, |
| 589 | 590 | file_rmdir_sql_function, 0, 0); |
| 591 | + zPwd[0] = 0; | |
| 592 | + file_getcwd(zPwd, sizeof(zPwd)); | |
| 590 | 593 | 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 | |
| 592 | 597 | ); |
| 593 | 598 | if( g.argc<=3 ){ |
| 594 | 599 | /* All files updated. Shift the current checkout to the target. */ |
| 595 | 600 | db_multi_exec("DELETE FROM vfile WHERE vid!=%d", tid); |
| 596 | 601 | checkout_set_all_exe(tid); |
| 597 | 602 |
| --- 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 |