Fossil SCM

Add the --dotfiles option to the "add" command to cause fossil to include files whose name begins with "." which recursively adding files. Ticket [2e924cf9b74e].

drh 2009-08-14 16:19 trunk
Commit 5bc5e88c86130400c184ba93b2470e7009f909c5
1 file changed +15 -1
+15 -1
--- src/add.c
+++ src/add.c
@@ -27,10 +27,15 @@
2727
#include "config.h"
2828
#include "add.h"
2929
#include <assert.h>
3030
#include <dirent.h>
3131
32
+/*
33
+** Set to true if files whose names begin with "." should be
34
+** included when processing a recursive "add" command.
35
+*/
36
+static int includeDotFiles = 0;
3237
3338
/*
3439
** Add a single file
3540
*/
3641
static void add_one_file(const char *zName, int vid, Blob *pOmit){
@@ -75,11 +80,15 @@
7580
origSize = blob_size(&path);
7681
d = opendir(zDir);
7782
if( d ){
7883
while( (pEntry=readdir(d))!=0 ){
7984
char *zPath;
80
- if( pEntry->d_name[0]=='.' ) continue;
85
+ if( pEntry->d_name[0]=='.' ){
86
+ if( !includeDotFiles ) continue;
87
+ if( pEntry->d_name[1]==0 ) continue;
88
+ if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
89
+ }
8190
blob_appendf(&path, "/%s", pEntry->d_name);
8291
zPath = blob_str(&path);
8392
if( file_isdir(zPath)==1 ){
8493
add_directory_content(zPath);
8594
}else if( file_isfile(zPath) ){
@@ -112,16 +121,21 @@
112121
**
113122
** Usage: %fossil add FILE...
114123
**
115124
** Make arrangements to add one or more files to the current checkout
116125
** at the next commit.
126
+**
127
+** When adding files recursively, filenames that begin with "." are
128
+** excluded by default. To include such files, add the "--dotfiles"
129
+** option to the command-line.
117130
*/
118131
void add_cmd(void){
119132
int i;
120133
int vid;
121134
Blob repo;
122135
136
+ includeDotFiles = find_option("dotfiles",0,0)!=0;
123137
db_must_be_within_tree();
124138
vid = db_lget_int("checkout",0);
125139
if( vid==0 ){
126140
fossil_panic("no checkout to add to");
127141
}
128142
--- src/add.c
+++ src/add.c
@@ -27,10 +27,15 @@
27 #include "config.h"
28 #include "add.h"
29 #include <assert.h>
30 #include <dirent.h>
31
 
 
 
 
 
32
33 /*
34 ** Add a single file
35 */
36 static void add_one_file(const char *zName, int vid, Blob *pOmit){
@@ -75,11 +80,15 @@
75 origSize = blob_size(&path);
76 d = opendir(zDir);
77 if( d ){
78 while( (pEntry=readdir(d))!=0 ){
79 char *zPath;
80 if( pEntry->d_name[0]=='.' ) continue;
 
 
 
 
81 blob_appendf(&path, "/%s", pEntry->d_name);
82 zPath = blob_str(&path);
83 if( file_isdir(zPath)==1 ){
84 add_directory_content(zPath);
85 }else if( file_isfile(zPath) ){
@@ -112,16 +121,21 @@
112 **
113 ** Usage: %fossil add FILE...
114 **
115 ** Make arrangements to add one or more files to the current checkout
116 ** at the next commit.
 
 
 
 
117 */
118 void add_cmd(void){
119 int i;
120 int vid;
121 Blob repo;
122
 
123 db_must_be_within_tree();
124 vid = db_lget_int("checkout",0);
125 if( vid==0 ){
126 fossil_panic("no checkout to add to");
127 }
128
--- src/add.c
+++ src/add.c
@@ -27,10 +27,15 @@
27 #include "config.h"
28 #include "add.h"
29 #include <assert.h>
30 #include <dirent.h>
31
32 /*
33 ** Set to true if files whose names begin with "." should be
34 ** included when processing a recursive "add" command.
35 */
36 static int includeDotFiles = 0;
37
38 /*
39 ** Add a single file
40 */
41 static void add_one_file(const char *zName, int vid, Blob *pOmit){
@@ -75,11 +80,15 @@
80 origSize = blob_size(&path);
81 d = opendir(zDir);
82 if( d ){
83 while( (pEntry=readdir(d))!=0 ){
84 char *zPath;
85 if( pEntry->d_name[0]=='.' ){
86 if( !includeDotFiles ) continue;
87 if( pEntry->d_name[1]==0 ) continue;
88 if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
89 }
90 blob_appendf(&path, "/%s", pEntry->d_name);
91 zPath = blob_str(&path);
92 if( file_isdir(zPath)==1 ){
93 add_directory_content(zPath);
94 }else if( file_isfile(zPath) ){
@@ -112,16 +121,21 @@
121 **
122 ** Usage: %fossil add FILE...
123 **
124 ** Make arrangements to add one or more files to the current checkout
125 ** at the next commit.
126 **
127 ** When adding files recursively, filenames that begin with "." are
128 ** excluded by default. To include such files, add the "--dotfiles"
129 ** option to the command-line.
130 */
131 void add_cmd(void){
132 int i;
133 int vid;
134 Blob repo;
135
136 includeDotFiles = find_option("dotfiles",0,0)!=0;
137 db_must_be_within_tree();
138 vid = db_lget_int("checkout",0);
139 if( vid==0 ){
140 fossil_panic("no checkout to add to");
141 }
142

Keyboard Shortcuts

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