Fossil SCM
Added better error message when trying to remove a directory.
Commit
1761fee0556d5e1b554e29a67462d18dceb5db83
Parent
4027ad4b7e5d182…
1 file changed
+10
-5
+10
-5
| --- src/add.c | ||
| +++ src/add.c | ||
| @@ -7,11 +7,11 @@ | ||
| 7 | 7 | ** |
| 8 | 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | 9 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | 10 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | 11 | ** General Public License for more details. |
| 12 | -** | |
| 12 | +** | |
| 13 | 13 | ** You should have received a copy of the GNU General Public |
| 14 | 14 | ** License along with this library; if not, write to the |
| 15 | 15 | ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | 16 | ** Boston, MA 02111-1307, USA. |
| 17 | 17 | ** |
| @@ -32,18 +32,18 @@ | ||
| 32 | 32 | /* |
| 33 | 33 | ** Set to true if files whose names begin with "." should be |
| 34 | 34 | ** included when processing a recursive "add" command. |
| 35 | 35 | */ |
| 36 | 36 | static int includeDotFiles = 0; |
| 37 | - | |
| 37 | + | |
| 38 | 38 | /* |
| 39 | 39 | ** Add a single file |
| 40 | 40 | */ |
| 41 | 41 | static void add_one_file(const char *zName, int vid, Blob *pOmit){ |
| 42 | 42 | Blob pathname; |
| 43 | 43 | const char *zPath; |
| 44 | - | |
| 44 | + | |
| 45 | 45 | file_tree_name(zName, &pathname, 1); |
| 46 | 46 | zPath = blob_str(&pathname); |
| 47 | 47 | if( strcmp(zPath, "manifest")==0 |
| 48 | 48 | || strcmp(zPath, "_FOSSIL_")==0 |
| 49 | 49 | || strcmp(zPath, "manifest.uuid")==0 |
| @@ -126,11 +126,11 @@ | ||
| 126 | 126 | /* |
| 127 | 127 | ** COMMAND: add |
| 128 | 128 | ** |
| 129 | 129 | ** Usage: %fossil add FILE... |
| 130 | 130 | ** |
| 131 | -** Make arrangements to add one or more files to the current checkout | |
| 131 | +** Make arrangements to add one or more files to the current checkout | |
| 132 | 132 | ** at the next commit. |
| 133 | 133 | ** |
| 134 | 134 | ** When adding files recursively, filenames that begin with "." are |
| 135 | 135 | ** excluded by default. To include such files, add the "--dotfiles" |
| 136 | 136 | ** option to the command-line. |
| @@ -201,13 +201,18 @@ | ||
| 201 | 201 | } |
| 202 | 202 | db_begin_transaction(); |
| 203 | 203 | for(i=2; i<g.argc; i++){ |
| 204 | 204 | char *zName; |
| 205 | 205 | char *zPath; |
| 206 | + int isDir; | |
| 206 | 207 | Blob pathname; |
| 207 | 208 | |
| 208 | 209 | zName = mprintf("%/", g.argv[i]); |
| 210 | + isDir = file_isdir(zName); | |
| 211 | + if( isDir==1 ){ | |
| 212 | + fossil_fatal("cannot remove directories. Please remove individual files instead."); | |
| 213 | + } | |
| 209 | 214 | file_tree_name(zName, &pathname, 1); |
| 210 | 215 | zPath = blob_str(&pathname); |
| 211 | 216 | if( !db_exists( |
| 212 | 217 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ |
| 213 | 218 | fossil_fatal("not in the repository: %s", zName); |
| @@ -221,11 +226,11 @@ | ||
| 221 | 226 | db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); |
| 222 | 227 | db_end_transaction(0); |
| 223 | 228 | } |
| 224 | 229 | |
| 225 | 230 | /* |
| 226 | -** Rename a single file. | |
| 231 | +** Rename a single file. | |
| 227 | 232 | ** |
| 228 | 233 | ** The original name of the file is zOrig. The new filename is zNew. |
| 229 | 234 | */ |
| 230 | 235 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 231 | 236 | printf("RENAME %s %s\n", zOrig, zNew); |
| 232 | 237 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -7,11 +7,11 @@ | |
| 7 | ** |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | ** General Public License for more details. |
| 12 | ** |
| 13 | ** You should have received a copy of the GNU General Public |
| 14 | ** License along with this library; if not, write to the |
| 15 | ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | ** Boston, MA 02111-1307, USA. |
| 17 | ** |
| @@ -32,18 +32,18 @@ | |
| 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){ |
| 42 | Blob pathname; |
| 43 | const char *zPath; |
| 44 | |
| 45 | file_tree_name(zName, &pathname, 1); |
| 46 | zPath = blob_str(&pathname); |
| 47 | if( strcmp(zPath, "manifest")==0 |
| 48 | || strcmp(zPath, "_FOSSIL_")==0 |
| 49 | || strcmp(zPath, "manifest.uuid")==0 |
| @@ -126,11 +126,11 @@ | |
| 126 | /* |
| 127 | ** COMMAND: add |
| 128 | ** |
| 129 | ** Usage: %fossil add FILE... |
| 130 | ** |
| 131 | ** Make arrangements to add one or more files to the current checkout |
| 132 | ** at the next commit. |
| 133 | ** |
| 134 | ** When adding files recursively, filenames that begin with "." are |
| 135 | ** excluded by default. To include such files, add the "--dotfiles" |
| 136 | ** option to the command-line. |
| @@ -201,13 +201,18 @@ | |
| 201 | } |
| 202 | db_begin_transaction(); |
| 203 | for(i=2; i<g.argc; i++){ |
| 204 | char *zName; |
| 205 | char *zPath; |
| 206 | Blob pathname; |
| 207 | |
| 208 | zName = mprintf("%/", g.argv[i]); |
| 209 | file_tree_name(zName, &pathname, 1); |
| 210 | zPath = blob_str(&pathname); |
| 211 | if( !db_exists( |
| 212 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ |
| 213 | fossil_fatal("not in the repository: %s", zName); |
| @@ -221,11 +226,11 @@ | |
| 221 | db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); |
| 222 | db_end_transaction(0); |
| 223 | } |
| 224 | |
| 225 | /* |
| 226 | ** Rename a single file. |
| 227 | ** |
| 228 | ** The original name of the file is zOrig. The new filename is zNew. |
| 229 | */ |
| 230 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 231 | printf("RENAME %s %s\n", zOrig, zNew); |
| 232 |
| --- src/add.c | |
| +++ src/add.c | |
| @@ -7,11 +7,11 @@ | |
| 7 | ** |
| 8 | ** This program is distributed in the hope that it will be useful, |
| 9 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | ** General Public License for more details. |
| 12 | ** |
| 13 | ** You should have received a copy of the GNU General Public |
| 14 | ** License along with this library; if not, write to the |
| 15 | ** Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 16 | ** Boston, MA 02111-1307, USA. |
| 17 | ** |
| @@ -32,18 +32,18 @@ | |
| 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){ |
| 42 | Blob pathname; |
| 43 | const char *zPath; |
| 44 | |
| 45 | file_tree_name(zName, &pathname, 1); |
| 46 | zPath = blob_str(&pathname); |
| 47 | if( strcmp(zPath, "manifest")==0 |
| 48 | || strcmp(zPath, "_FOSSIL_")==0 |
| 49 | || strcmp(zPath, "manifest.uuid")==0 |
| @@ -126,11 +126,11 @@ | |
| 126 | /* |
| 127 | ** COMMAND: add |
| 128 | ** |
| 129 | ** Usage: %fossil add FILE... |
| 130 | ** |
| 131 | ** Make arrangements to add one or more files to the current checkout |
| 132 | ** at the next commit. |
| 133 | ** |
| 134 | ** When adding files recursively, filenames that begin with "." are |
| 135 | ** excluded by default. To include such files, add the "--dotfiles" |
| 136 | ** option to the command-line. |
| @@ -201,13 +201,18 @@ | |
| 201 | } |
| 202 | db_begin_transaction(); |
| 203 | for(i=2; i<g.argc; i++){ |
| 204 | char *zName; |
| 205 | char *zPath; |
| 206 | int isDir; |
| 207 | Blob pathname; |
| 208 | |
| 209 | zName = mprintf("%/", g.argv[i]); |
| 210 | isDir = file_isdir(zName); |
| 211 | if( isDir==1 ){ |
| 212 | fossil_fatal("cannot remove directories. Please remove individual files instead."); |
| 213 | } |
| 214 | file_tree_name(zName, &pathname, 1); |
| 215 | zPath = blob_str(&pathname); |
| 216 | if( !db_exists( |
| 217 | "SELECT 1 FROM vfile WHERE pathname=%Q AND NOT deleted", zPath) ){ |
| 218 | fossil_fatal("not in the repository: %s", zName); |
| @@ -221,11 +226,11 @@ | |
| 226 | db_multi_exec("DELETE FROM vfile WHERE deleted AND rid=0"); |
| 227 | db_end_transaction(0); |
| 228 | } |
| 229 | |
| 230 | /* |
| 231 | ** Rename a single file. |
| 232 | ** |
| 233 | ** The original name of the file is zOrig. The new filename is zNew. |
| 234 | */ |
| 235 | static void mv_one_file(int vid, const char *zOrig, const char *zNew){ |
| 236 | printf("RENAME %s %s\n", zOrig, zNew); |
| 237 |