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].
Commit
5bc5e88c86130400c184ba93b2470e7009f909c5
Parent
0b49e4afbaa1462…
1 file changed
+15
-1
+15
-1
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -27,10 +27,15 @@ | ||
| 27 | 27 | #include "config.h" |
| 28 | 28 | #include "add.h" |
| 29 | 29 | #include <assert.h> |
| 30 | 30 | #include <dirent.h> |
| 31 | 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; | |
| 32 | 37 | |
| 33 | 38 | /* |
| 34 | 39 | ** Add a single file |
| 35 | 40 | */ |
| 36 | 41 | static void add_one_file(const char *zName, int vid, Blob *pOmit){ |
| @@ -75,11 +80,15 @@ | ||
| 75 | 80 | origSize = blob_size(&path); |
| 76 | 81 | d = opendir(zDir); |
| 77 | 82 | if( d ){ |
| 78 | 83 | while( (pEntry=readdir(d))!=0 ){ |
| 79 | 84 | 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 | + } | |
| 81 | 90 | blob_appendf(&path, "/%s", pEntry->d_name); |
| 82 | 91 | zPath = blob_str(&path); |
| 83 | 92 | if( file_isdir(zPath)==1 ){ |
| 84 | 93 | add_directory_content(zPath); |
| 85 | 94 | }else if( file_isfile(zPath) ){ |
| @@ -112,16 +121,21 @@ | ||
| 112 | 121 | ** |
| 113 | 122 | ** Usage: %fossil add FILE... |
| 114 | 123 | ** |
| 115 | 124 | ** Make arrangements to add one or more files to the current checkout |
| 116 | 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. | |
| 117 | 130 | */ |
| 118 | 131 | void add_cmd(void){ |
| 119 | 132 | int i; |
| 120 | 133 | int vid; |
| 121 | 134 | Blob repo; |
| 122 | 135 | |
| 136 | + includeDotFiles = find_option("dotfiles",0,0)!=0; | |
| 123 | 137 | db_must_be_within_tree(); |
| 124 | 138 | vid = db_lget_int("checkout",0); |
| 125 | 139 | if( vid==0 ){ |
| 126 | 140 | fossil_panic("no checkout to add to"); |
| 127 | 141 | } |
| 128 | 142 |
| --- 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 |