Check-in [a2749215b7]
Not logged in
Overview

SHA1 Hash:a2749215b71b297780c2b787a938eae82edf32b7
Date: 2009-09-19 15:32:14
User: drh
Comment:Add the --dotfiles option to the "extra" and "clean" commands. Ticket 4de876322f066.
Timelines: ancestors | descendants | both | trunk
Other Links: files | ZIP archive | manifest

Tags And Properties
Changes
[hide diffs]

Modified src/checkin.c from [6bbed2063d] to [2e4a6e1c0f].

@@ -164,25 +164,29 @@
   db_finalize(&q);
 }
 
 /*
 ** COMMAND: extras
-** Usage: %fossil extras
+** Usage: %fossil extras ?--dotfiles?
 **
 ** Print a list of all files in the source tree that are not part of
 ** the current checkout.  See also the "clean" command.
+**
+** Files and subdirectories whose names begin with "." are normally
+** ignored but can be included by adding the --dotfiles option.
 */
 void extra_cmd(void){
   Blob path;
   Blob repo;
   Stmt q;
   int n;
+  int allFlag = find_option("dotfiles",0,0)!=0;
   db_must_be_within_tree();
   db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
   n = strlen(g.zLocalRoot);
   blob_init(&path, g.zLocalRoot, n-1);
-  vfile_scan(0, &path, blob_size(&path));
+  vfile_scan(0, &path, blob_size(&path), allFlag);
   db_prepare(&q,
       "SELECT x FROM sfile"
       " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
       " ORDER BY 1");
   if( file_tree_name(g.zRepositoryName, &repo, 0) ){
@@ -194,31 +198,37 @@
   db_finalize(&q);
 }
 
 /*
 ** COMMAND: clean
-** Usage: %fossil clean ?-all?
+** Usage: %fossil clean ?--force? ?--dotfiles?
 **
 ** Delete all "extra" files in the source tree.  "Extra" files are
 ** files that are not officially part of the checkout.  See also
 ** the "extra" command. This operation cannot be undone.
 **
 ** You will be prompted before removing each file. If you are
 ** sure you wish to remove all "extra" files you can specify the
-** optional -all flag.
+** optional --force flag and no prmpts will be issued.
+**
+** Files and subdirectories whose names begin with "." are
+** normally ignored.  They are included if the "--dotfiles" option
+** is used.
 */
 void clean_cmd(void){
   int allFlag;
+  int dotfilesFlag;
   Blob path, repo;
   Stmt q;
   int n;
   allFlag = find_option("all","a",0)!=0;
+  dotfilesFlag = find_option("dotfiles",0,0)!=0;
   db_must_be_within_tree();
   db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY)");
   n = strlen(g.zLocalRoot);
   blob_init(&path, g.zLocalRoot, n-1);
-  vfile_scan(0, &path, blob_size(&path));
+  vfile_scan(0, &path, blob_size(&path), dotfilesFlag);
   db_prepare(&q,
       "SELECT %Q || x FROM sfile"
       " WHERE x NOT IN ('manifest','manifest.uuid','_FOSSIL_')"
       " ORDER BY 1", g.zLocalRoot);
   if( file_tree_name(g.zRepositoryName, &repo, 0) ){

Modified src/vfile.c from [eb6d72e4f4] to [5504b327f7].

@@ -259,11 +259,11 @@
 ** of pPath when inserting into the SFILE table.
 **
 ** Subdirectories are scanned recursively.
 ** Omit files named in VFILE.vid
 */
-void vfile_scan(int vid, Blob *pPath, int nPrefix){
+void vfile_scan(int vid, Blob *pPath, int nPrefix, int allFlag){
   DIR *d;
   int origSize;
   const char *zDir;
   struct dirent *pEntry;
   static const char *zSql = "SELECT 1 FROM vfile "
@@ -273,15 +273,19 @@
   zDir = blob_str(pPath);
   d = opendir(zDir);
   if( d ){
     while( (pEntry=readdir(d))!=0 ){
       char *zPath;
-      if( pEntry->d_name[0]=='.' ) continue;
+      if( pEntry->d_name[0]=='.' ){
+        if( !allFlag ) continue;
+        if( pEntry->d_name[1]==0 ) continue;
+        if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
+      }
       blob_appendf(pPath, "/%s", pEntry->d_name);
       zPath = blob_str(pPath);
       if( file_isdir(zPath)==1 ){
-        vfile_scan(vid, pPath, nPrefix);
+        vfile_scan(vid, pPath, nPrefix, allFlag);
       }else if( file_isfile(zPath) && !db_exists(zSql, &zPath[nPrefix+1]) ){
         db_multi_exec("INSERT INTO sfile VALUES(%Q)", &zPath[nPrefix+1]);
       }
       blob_resize(pPath, origSize);
     }