Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Initial draft of new unaddremove command (will be renamed once a suitable name is found), as discussed at [https://fossil-scm.org/forum/forumpost/b9b20b04bd|forumpost/b9b20b04bd]. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | unaddremove-command |
| Files: | files | file ages | folders |
| SHA3-256: |
369a14b33fb79ffca48f9de37ee95f18 |
| User & Date: | stephan 2020-04-22 23:45:20.357 |
Context
|
2020-04-23
| ||
| 00:06 | Pedantic cosmetic change: do un-rm before un-add. ... (check-in: 6e21c7d706 user: stephan tags: unaddremove-command) | |
|
2020-04-22
| ||
| 23:45 | Initial draft of new unaddremove command (will be renamed once a suitable name is found), as discussed at [https://fossil-scm.org/forum/forumpost/b9b20b04bd|forumpost/b9b20b04bd]. ... (check-in: 369a14b33f user: stephan tags: unaddremove-command) | |
| 18:01 | The post sequence numbers on the hierarchical display of a forum thread should be the sequence number of the original version of the post, not the final edit of the post. ... (check-in: c6890fd46a user: drh tags: trunk) | |
Changes
Changes to src/add.c.
| ︙ | ︙ | |||
709 710 711 712 713 714 715 716 717 718 719 720 721 722 |
db_finalize(&q);
/* show command summary */
fossil_print("added %d files, deleted %d files\n", nAdd, nDelete);
db_end_transaction(dryRunFlag);
}
/*
** Rename a single file.
**
** The original name of the file is zOrig. The new filename is zNew.
*/
static void mv_one_file(
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 |
db_finalize(&q);
/* show command summary */
fossil_print("added %d files, deleted %d files\n", nAdd, nDelete);
db_end_transaction(dryRunFlag);
}
/*
** COMMAND: unaddremove*
**
** Resets the ADD/REMOVE state of a checkout, such that all newly-added
** (but not yet committed) files are no longer added and newly-removed
** (but not yet committed) files are no longer removed.
**
** This command does not touch un-added files but restores any un-rm'd
** files which are missing from the checkout.
**
** Options:
**
** -v|--verbose Output name of each un-added/un-removed file.
**
*/
void unaddremove_cmd(void){
int nDeleted = 0; /* # of files which get un-rm'd */
int nAdded = 0; /* # of files which get un-added */
int fVerbose; /* true if --verbose */
Stmt stmt; /* vfile loop query */
db_must_be_within_tree();
fVerbose = find_option("verbose", "v", 0)!=0;
verify_all_options();
db_begin_transaction();
db_prepare(&stmt, "SELECT id, rid, deleted, pathname FROM vfile "
"ORDER BY deleted<>0, pathname");
while( db_step(&stmt)==SQLITE_ROW ){
/* This loop exists only so we can restore the contents of un-rm'd
** files. All manipulation of vfile's contents happens after the
** loop. */
int const rid = db_column_int(&stmt, 1);
int const deleted = db_column_int(&stmt, 2);
if(deleted!=0 || rid==0){
int const id = db_column_int(&stmt, 0);
char const * zPathname = db_column_text(&stmt, 3);
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
Blob relName = empty_blob;
file_relative_name(zFullName, &relName, 0);
fossil_free(zFullName);
zFullName = 0;
if(deleted!=0){
/* Restore contents of missing un-rm'd files. We don't do this
** unconditionally because we might cause data loss if a file
** is modified, rm'd, then un-rm'd.
*/
++nDeleted;
if(!file_isfile_or_link(blob_str(&relName))){
vfile_to_disk(0, id, 0, 0);
}
/* *Potential* corner case: relName refers to a directory,
** meaning the user rm'd the file and replaced it with a
** directory. In that case, vfile_to_disk() will fail fatally,
** which is arguably the best course of action.
*/
if(fVerbose){
fossil_print("Un-removed: %b\n", &relName);
}
}else if(rid==0){
++nAdded;
if(fVerbose){
fossil_print("Un-added: %b\n", &relName);
}
}
blob_reset(&relName);
}
}
db_finalize(&stmt);
if(nDeleted>0){
db_multi_exec("UPDATE vfile SET deleted=0 WHERE deleted<>0");
fossil_print("Un-removed %d file(s).\n", nDeleted);
}
if(nAdded>0){
db_multi_exec("DELETE FROM vfile WHERE rid=0");
fossil_print("Un-added %d file(s).\n", nAdded);
}
db_end_transaction(0);
}
/*
** Rename a single file.
**
** The original name of the file is zOrig. The new filename is zNew.
*/
static void mv_one_file(
|
| ︙ | ︙ |