Differences From:
File
src/add.c
part of check-in
[8c4e72e223]
- Enhance the "fossil add" command so that when a directory is named, all
contents of that directory are added recursively.
Ticket e02ffabcdaaaf606099ac09227833ba282fdaace
by
drh on
2008-12-07 18:11:09.
[view]
To:
File
src/add.c
part of check-in
[7a2c37063a]
- merge trunk into creole branch
by
bob on
2009-09-22 07:49:39.
Also file
src/add.c
part of check-in
[5bc5e88c86]
- Add the --dotfiles option to the "add" command to cause fossil to include
files whose name begins with "." which recursively adding files.
Ticket 2e924cf9b74e.
by
drh on
2009-08-14 16:19:53.
[view]
@@ -28,8 +28,13 @@
#include "add.h"
#include <assert.h>
#include <dirent.h>
+/*
+** Set to true if files whose names begin with "." should be
+** included when processing a recursive "add" command.
+*/
+static int includeDotFiles = 0;
/*
** Add a single file
*/
@@ -76,9 +81,13 @@
d = opendir(zDir);
if( d ){
while( (pEntry=readdir(d))!=0 ){
char *zPath;
- if( pEntry->d_name[0]=='.' ) continue;
+ if( pEntry->d_name[0]=='.' ){
+ if( !includeDotFiles ) continue;
+ if( pEntry->d_name[1]==0 ) continue;
+ if( pEntry->d_name[1]=='.' && pEntry->d_name[2]==0 ) continue;
+ }
blob_appendf(&path, "/%s", pEntry->d_name);
zPath = blob_str(&path);
if( file_isdir(zPath)==1 ){
add_directory_content(zPath);
@@ -113,14 +122,19 @@
** Usage: %fossil add FILE...
**
** Make arrangements to add one or more files to the current checkout
** at the next commit.
+**
+** When adding files recursively, filenames that begin with "." are
+** excluded by default. To include such files, add the "--dotfiles"
+** option to the command-line.
*/
void add_cmd(void){
int i;
int vid;
Blob repo;
+ includeDotFiles = find_option("dotfiles",0,0)!=0;
db_must_be_within_tree();
vid = db_lget_int("checkout",0);
if( vid==0 ){
fossil_panic("no checkout to add to");