Fossil SCM

Switched the empty-dirs setting handler from a one-off parser to glob_create() both so we get consistent behavior across the settings and because glob_create() allows quoted whitespace, needed when asking it to create directories with spaces in them. Addresses [forum:/forumpost/bdbb295ee308c9d6 | this forum report].

wyoung 2023-05-22 22:11 trunk
Commit f12609fcaa95ac4ce6147a1fbd1e229d14606cd4158caf3f050e998d0d86b707
+4 -4
--- src/db.c
+++ src/db.c
@@ -4266,14 +4266,14 @@
42664266
** The value is an external command that will launch the
42674267
** text editor command used for check-in comments.
42684268
*/
42694269
/*
42704270
** SETTING: empty-dirs width=40 versionable block-text
4271
-** The value is a comma or newline-separated list of pathnames. On
4272
-** update and checkout commands, if no file or directory
4273
-** exists with that name, an empty directory will be
4274
-** created.
4271
+** The value is a list of pathnames parsed according to the same rules as
4272
+** the *-glob settings. On update and checkout commands, if no directory
4273
+** exists with that name, an empty directory will be be created, even if
4274
+** it must create one or more parent directories.
42754275
*/
42764276
/*
42774277
** SETTING: encoding-glob width=40 versionable block-text
42784278
** The value is a comma or newline-separated list of GLOB
42794279
** patterns specifying files that the "commit" command will
42804280
--- src/db.c
+++ src/db.c
@@ -4266,14 +4266,14 @@
4266 ** The value is an external command that will launch the
4267 ** text editor command used for check-in comments.
4268 */
4269 /*
4270 ** SETTING: empty-dirs width=40 versionable block-text
4271 ** The value is a comma or newline-separated list of pathnames. On
4272 ** update and checkout commands, if no file or directory
4273 ** exists with that name, an empty directory will be
4274 ** created.
4275 */
4276 /*
4277 ** SETTING: encoding-glob width=40 versionable block-text
4278 ** The value is a comma or newline-separated list of GLOB
4279 ** patterns specifying files that the "commit" command will
4280
--- src/db.c
+++ src/db.c
@@ -4266,14 +4266,14 @@
4266 ** The value is an external command that will launch the
4267 ** text editor command used for check-in comments.
4268 */
4269 /*
4270 ** SETTING: empty-dirs width=40 versionable block-text
4271 ** The value is a list of pathnames parsed according to the same rules as
4272 ** the *-glob settings. On update and checkout commands, if no directory
4273 ** exists with that name, an empty directory will be be created, even if
4274 ** it must create one or more parent directories.
4275 */
4276 /*
4277 ** SETTING: encoding-glob width=40 versionable block-text
4278 ** The value is a comma or newline-separated list of GLOB
4279 ** patterns specifying files that the "commit" command will
4280
+5 -13
--- src/update.c
+++ src/update.c
@@ -652,20 +652,14 @@
652652
*/
653653
void ensure_empty_dirs_created(int clearDirTable){
654654
char *zEmptyDirs = db_get("empty-dirs", 0);
655655
if( zEmptyDirs!=0 ){
656656
int i;
657
- Blob dirName;
658
- Blob dirsList;
659
-
660
- zEmptyDirs = fossil_strdup(zEmptyDirs);
661
- for(i=0; zEmptyDirs[i]; i++){
662
- if( zEmptyDirs[i]==',' ) zEmptyDirs[i] = ' ';
663
- }
664
- blob_init(&dirsList, zEmptyDirs, -1);
665
- while( blob_token(&dirsList, &dirName) ){
666
- char *zDir = blob_str(&dirName);
657
+ Glob *pGlob = glob_create(zEmptyDirs);
658
+
659
+ for(i=0; i<pGlob->nPattern; i++){
660
+ const char *zDir = pGlob->azPattern[i];
667661
char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir);
668662
switch( file_isdir(zPath, RepoFILE) ){
669663
case 0: { /* doesn't exist */
670664
fossil_free(zPath);
671665
zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir);
@@ -688,14 +682,12 @@
688682
fossil_warning("file %s found, but a directory is required "
689683
"by empty-dirs setting", zDir);
690684
}
691685
}
692686
fossil_free(zPath);
693
- blob_reset(&dirName);
694687
}
695
- blob_reset(&dirsList);
696
- fossil_free(zEmptyDirs);
688
+ glob_free(pGlob);
697689
}
698690
}
699691
700692
/*
701693
** Get the manifest record for a given revision, or the current check-out if
702694
--- src/update.c
+++ src/update.c
@@ -652,20 +652,14 @@
652 */
653 void ensure_empty_dirs_created(int clearDirTable){
654 char *zEmptyDirs = db_get("empty-dirs", 0);
655 if( zEmptyDirs!=0 ){
656 int i;
657 Blob dirName;
658 Blob dirsList;
659
660 zEmptyDirs = fossil_strdup(zEmptyDirs);
661 for(i=0; zEmptyDirs[i]; i++){
662 if( zEmptyDirs[i]==',' ) zEmptyDirs[i] = ' ';
663 }
664 blob_init(&dirsList, zEmptyDirs, -1);
665 while( blob_token(&dirsList, &dirName) ){
666 char *zDir = blob_str(&dirName);
667 char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir);
668 switch( file_isdir(zPath, RepoFILE) ){
669 case 0: { /* doesn't exist */
670 fossil_free(zPath);
671 zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir);
@@ -688,14 +682,12 @@
688 fossil_warning("file %s found, but a directory is required "
689 "by empty-dirs setting", zDir);
690 }
691 }
692 fossil_free(zPath);
693 blob_reset(&dirName);
694 }
695 blob_reset(&dirsList);
696 fossil_free(zEmptyDirs);
697 }
698 }
699
700 /*
701 ** Get the manifest record for a given revision, or the current check-out if
702
--- src/update.c
+++ src/update.c
@@ -652,20 +652,14 @@
652 */
653 void ensure_empty_dirs_created(int clearDirTable){
654 char *zEmptyDirs = db_get("empty-dirs", 0);
655 if( zEmptyDirs!=0 ){
656 int i;
657 Glob *pGlob = glob_create(zEmptyDirs);
658
659 for(i=0; i<pGlob->nPattern; i++){
660 const char *zDir = pGlob->azPattern[i];
 
 
 
 
 
 
661 char *zPath = mprintf("%s/%s", g.zLocalRoot, zDir);
662 switch( file_isdir(zPath, RepoFILE) ){
663 case 0: { /* doesn't exist */
664 fossil_free(zPath);
665 zPath = mprintf("%s/%s/x", g.zLocalRoot, zDir);
@@ -688,14 +682,12 @@
682 fossil_warning("file %s found, but a directory is required "
683 "by empty-dirs setting", zDir);
684 }
685 }
686 fossil_free(zPath);
 
687 }
688 glob_free(pGlob);
 
689 }
690 }
691
692 /*
693 ** Get the manifest record for a given revision, or the current check-out if
694
--- www/changes.wiki
+++ www/changes.wiki
@@ -30,10 +30,13 @@
3030
* Default permissions for anonymous users in new repositories is
3131
changed to "hz".
3232
* The [/help?cmd=status|fossil status] command now detects when a
3333
file used to be a symlink and has been replaced by a regular file.
3434
(It previously checked for the inverse case only.)
35
+ * The [/help?cmd=empty-dirs|empty-dirs setting] now reuses the same
36
+ parser as the *-glob settings instead of its prior idiosyncratic
37
+ parser, allowing quoted whitespace in patterns.
3538
3639
<h2 id='v2_21'>Changes for version 2.21 (2023-02-25)</h2>
3740
* Users can request a password reset. This feature is disabledby default. Use
3841
the new [/help?cmd=self-pw-reset|self-pw-reset property] to enable it.
3942
New web pages [/help?cmd=/resetpw|/resetpw] and
4043
--- www/changes.wiki
+++ www/changes.wiki
@@ -30,10 +30,13 @@
30 * Default permissions for anonymous users in new repositories is
31 changed to "hz".
32 * The [/help?cmd=status|fossil status] command now detects when a
33 file used to be a symlink and has been replaced by a regular file.
34 (It previously checked for the inverse case only.)
 
 
 
35
36 <h2 id='v2_21'>Changes for version 2.21 (2023-02-25)</h2>
37 * Users can request a password reset. This feature is disabledby default. Use
38 the new [/help?cmd=self-pw-reset|self-pw-reset property] to enable it.
39 New web pages [/help?cmd=/resetpw|/resetpw] and
40
--- www/changes.wiki
+++ www/changes.wiki
@@ -30,10 +30,13 @@
30 * Default permissions for anonymous users in new repositories is
31 changed to "hz".
32 * The [/help?cmd=status|fossil status] command now detects when a
33 file used to be a symlink and has been replaced by a regular file.
34 (It previously checked for the inverse case only.)
35 * The [/help?cmd=empty-dirs|empty-dirs setting] now reuses the same
36 parser as the *-glob settings instead of its prior idiosyncratic
37 parser, allowing quoted whitespace in patterns.
38
39 <h2 id='v2_21'>Changes for version 2.21 (2023-02-25)</h2>
40 * Users can request a password reset. This feature is disabledby default. Use
41 the new [/help?cmd=self-pw-reset|self-pw-reset property] to enable it.
42 New web pages [/help?cmd=/resetpw|/resetpw] and
43

Keyboard Shortcuts

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