Fossil SCM

Allow the check-in of files show names begin with ".". Add the "private" table to repository schema but do not yet do anything with it.

drh 2008-05-17 08:53 trunk
Commit 525cc35bf3896727c9c6165e183da5f4c0e2d48d
3 files changed +12 -5 +18 -13 +12 -1
+12 -5
--- src/file.c
+++ src/file.c
@@ -73,10 +73,11 @@
7373
int file_isexe(const char *zFilename){
7474
struct stat buf;
7575
if( stat(zFilename, &buf)!=0 ){
7676
return 0;
7777
}
78
+ if( !S_ISREG(buf.st_mode) ) return 0;
7879
#ifdef __MINGW32__
7980
return ((S_IXUSR)&buf.st_mode)!=0;
8081
#else
8182
return ((S_IXUSR|S_IXGRP|S_IXOTH)&buf.st_mode)!=0;
8283
#endif
@@ -88,11 +89,11 @@
8889
void file_setexe(const char *zFilename, int onoff){
8990
#ifndef __MINGW32__
9091
struct stat buf;
9192
if( stat(zFilename, &buf)!=0 ) return;
9293
if( onoff ){
93
- if( (buf.st_mode & 0111)==0 ){
94
+ if( (buf.st_mode & 0111)!=0111 ){
9495
chmod(zFilename, buf.st_mode | 0111);
9596
}
9697
}else{
9798
if( (buf.st_mode & 0111)!=0 ){
9899
chmod(zFilename, buf.st_mode & ~0111);
@@ -141,26 +142,32 @@
141142
** Return true if the filename given is a valid filename for
142143
** a file in a repository. Valid filenames follow all of the
143144
** following rules:
144145
**
145146
** * Does not begin with "/"
146
-** * Does not contain any path element that begins with "."
147
+** * Does not contain any path element named "." or ".."
147148
** * Does not contain any of these characters in the path: "\*[]?"
148149
** * Does not end with "/".
149150
** * Does not contain two or more "/" characters in a row.
150151
** * Contains at least one character
151152
*/
152153
int file_is_simple_pathname(const char *z){
153154
int i;
154
- if( *z=='.' || *z=='/' || *z==0 ) return 0;
155
+ if( *z=='/' || *z==0 ) return 0;
156
+ if( *z=='.' ){
157
+ if( z[1]=='/' || z[1]==0 ) return 0;
158
+ if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0;
159
+ }
155160
for(i=0; z[i]; i++){
156161
if( z[i]=='\\' || z[i]=='*' || z[i]=='[' || z[i]==']' || z[i]=='?' ){
157162
return 0;
158163
}
159164
if( z[i]=='/' ){
160
- if( z[i+1]=='/' || z[i+1]=='.' ){
161
- return 0;
165
+ if( z[i+1]=='/' ) return 0;
166
+ if( z[i+1]=='.' ){
167
+ if( z[i+2]=='/' || z[i+2]==0 ) return 0;
168
+ if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
162169
}
163170
}
164171
}
165172
if( z[i-1]=='/' ) return 0;
166173
return 1;
167174
--- src/file.c
+++ src/file.c
@@ -73,10 +73,11 @@
73 int file_isexe(const char *zFilename){
74 struct stat buf;
75 if( stat(zFilename, &buf)!=0 ){
76 return 0;
77 }
 
78 #ifdef __MINGW32__
79 return ((S_IXUSR)&buf.st_mode)!=0;
80 #else
81 return ((S_IXUSR|S_IXGRP|S_IXOTH)&buf.st_mode)!=0;
82 #endif
@@ -88,11 +89,11 @@
88 void file_setexe(const char *zFilename, int onoff){
89 #ifndef __MINGW32__
90 struct stat buf;
91 if( stat(zFilename, &buf)!=0 ) return;
92 if( onoff ){
93 if( (buf.st_mode & 0111)==0 ){
94 chmod(zFilename, buf.st_mode | 0111);
95 }
96 }else{
97 if( (buf.st_mode & 0111)!=0 ){
98 chmod(zFilename, buf.st_mode & ~0111);
@@ -141,26 +142,32 @@
141 ** Return true if the filename given is a valid filename for
142 ** a file in a repository. Valid filenames follow all of the
143 ** following rules:
144 **
145 ** * Does not begin with "/"
146 ** * Does not contain any path element that begins with "."
147 ** * Does not contain any of these characters in the path: "\*[]?"
148 ** * Does not end with "/".
149 ** * Does not contain two or more "/" characters in a row.
150 ** * Contains at least one character
151 */
152 int file_is_simple_pathname(const char *z){
153 int i;
154 if( *z=='.' || *z=='/' || *z==0 ) return 0;
 
 
 
 
155 for(i=0; z[i]; i++){
156 if( z[i]=='\\' || z[i]=='*' || z[i]=='[' || z[i]==']' || z[i]=='?' ){
157 return 0;
158 }
159 if( z[i]=='/' ){
160 if( z[i+1]=='/' || z[i+1]=='.' ){
161 return 0;
 
 
162 }
163 }
164 }
165 if( z[i-1]=='/' ) return 0;
166 return 1;
167
--- src/file.c
+++ src/file.c
@@ -73,10 +73,11 @@
73 int file_isexe(const char *zFilename){
74 struct stat buf;
75 if( stat(zFilename, &buf)!=0 ){
76 return 0;
77 }
78 if( !S_ISREG(buf.st_mode) ) return 0;
79 #ifdef __MINGW32__
80 return ((S_IXUSR)&buf.st_mode)!=0;
81 #else
82 return ((S_IXUSR|S_IXGRP|S_IXOTH)&buf.st_mode)!=0;
83 #endif
@@ -88,11 +89,11 @@
89 void file_setexe(const char *zFilename, int onoff){
90 #ifndef __MINGW32__
91 struct stat buf;
92 if( stat(zFilename, &buf)!=0 ) return;
93 if( onoff ){
94 if( (buf.st_mode & 0111)!=0111 ){
95 chmod(zFilename, buf.st_mode | 0111);
96 }
97 }else{
98 if( (buf.st_mode & 0111)!=0 ){
99 chmod(zFilename, buf.st_mode & ~0111);
@@ -141,26 +142,32 @@
142 ** Return true if the filename given is a valid filename for
143 ** a file in a repository. Valid filenames follow all of the
144 ** following rules:
145 **
146 ** * Does not begin with "/"
147 ** * Does not contain any path element named "." or ".."
148 ** * Does not contain any of these characters in the path: "\*[]?"
149 ** * Does not end with "/".
150 ** * Does not contain two or more "/" characters in a row.
151 ** * Contains at least one character
152 */
153 int file_is_simple_pathname(const char *z){
154 int i;
155 if( *z=='/' || *z==0 ) return 0;
156 if( *z=='.' ){
157 if( z[1]=='/' || z[1]==0 ) return 0;
158 if( z[1]=='.' && (z[2]=='/' || z[2]==0) ) return 0;
159 }
160 for(i=0; z[i]; i++){
161 if( z[i]=='\\' || z[i]=='*' || z[i]=='[' || z[i]==']' || z[i]=='?' ){
162 return 0;
163 }
164 if( z[i]=='/' ){
165 if( z[i+1]=='/' ) return 0;
166 if( z[i+1]=='.' ){
167 if( z[i+2]=='/' || z[i+2]==0 ) return 0;
168 if( z[i+2]=='.' && (z[i+3]=='/' || z[i+3]==0) ) return 0;
169 }
170 }
171 }
172 if( z[i-1]=='/' ) return 0;
173 return 1;
174
+18 -13
--- src/rebuild.c
+++ src/rebuild.c
@@ -35,14 +35,24 @@
3535
@ --
3636
@ CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);
3737
@
3838
@ -- Artifacts that should not be processed are identified in the
3939
@ -- "shun" table. Artifacts that are control-file forgeries or
40
-@ -- spam can be shunned in order to prevent them from contaminating
40
+@ -- spam or artifacts whose contents violate administrative policy
41
+@ -- can be shunned in order to prevent them from contaminating
4142
@ -- the repository.
43
+@ --
44
+@ -- Shunned artifacts do not exist in the blob table. Hence they
45
+@ -- have not artifact ID (rid) and we thus must store their full
46
+@ -- UUID.
4247
@ --
4348
@ CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);
49
+@
50
+@ -- Artifacts that should not be pushed are stored in the "private"
51
+@ -- table.
52
+@ --
53
+@ CREATE TABLE IF NOT EXISTS private(rid INTEGER PRIMARY KEY);
4454
@
4555
@ -- An entry in this table describes a database query that generates a
4656
@ -- table of tickets.
4757
@ --
4858
@ CREATE TABLE IF NOT EXISTS reportfmt(
@@ -50,20 +60,10 @@
5060
@ owner text, -- Owner of this report format (not used)
5161
@ title text, -- Title of this report
5262
@ cols text, -- A color-key specification
5363
@ sqlcode text -- An SQL SELECT statement for this report
5464
@ );
55
-@
56
-@ -- A cache for mapping baseline artifact ID + filename into file
57
-@ -- artifact ID. Used by the /doc method.
58
-@ --
59
-@ CREATE TABLE IF NOT EXISTS vcache(
60
-@ vid integer, -- Baseline artifact ID
61
-@ fname text, -- Filename
62
-@ rid integer, -- File artifact ID
63
-@ UNIQUE(vid,fname,rid)
64
-@ );
6565
;
6666
6767
/*
6868
** Variables used for progress information
6969
*/
@@ -170,19 +170,24 @@
170170
db_multi_exec(zSchemaUpdates);
171171
for(;;){
172172
zTable = db_text(0,
173173
"SELECT name FROM sqlite_master"
174174
" WHERE type='table'"
175
- " AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')");
175
+ " AND name NOT IN ('blob','delta','rcvfrom','user',"
176
+ "'config','shun','private')"
177
+ );
176178
if( zTable==0 ) break;
177179
db_multi_exec("DROP TABLE %Q", zTable);
178180
free(zTable);
179181
}
180182
db_multi_exec(zRepositorySchema2);
181183
ticket_create_table(0);
182184
183
- db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob");
185
+ db_multi_exec(
186
+ "INSERT INTO unclustered"
187
+ " SELECT rid FROM blob EXCEPT SELECT rid FROM private"
188
+ );
184189
db_multi_exec(
185190
"DELETE FROM unclustered"
186191
" WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
187192
);
188193
db_multi_exec(
189194
--- src/rebuild.c
+++ src/rebuild.c
@@ -35,14 +35,24 @@
35 @ --
36 @ CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);
37 @
38 @ -- Artifacts that should not be processed are identified in the
39 @ -- "shun" table. Artifacts that are control-file forgeries or
40 @ -- spam can be shunned in order to prevent them from contaminating
 
41 @ -- the repository.
 
 
 
 
42 @ --
43 @ CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);
 
 
 
 
 
44 @
45 @ -- An entry in this table describes a database query that generates a
46 @ -- table of tickets.
47 @ --
48 @ CREATE TABLE IF NOT EXISTS reportfmt(
@@ -50,20 +60,10 @@
50 @ owner text, -- Owner of this report format (not used)
51 @ title text, -- Title of this report
52 @ cols text, -- A color-key specification
53 @ sqlcode text -- An SQL SELECT statement for this report
54 @ );
55 @
56 @ -- A cache for mapping baseline artifact ID + filename into file
57 @ -- artifact ID. Used by the /doc method.
58 @ --
59 @ CREATE TABLE IF NOT EXISTS vcache(
60 @ vid integer, -- Baseline artifact ID
61 @ fname text, -- Filename
62 @ rid integer, -- File artifact ID
63 @ UNIQUE(vid,fname,rid)
64 @ );
65 ;
66
67 /*
68 ** Variables used for progress information
69 */
@@ -170,19 +170,24 @@
170 db_multi_exec(zSchemaUpdates);
171 for(;;){
172 zTable = db_text(0,
173 "SELECT name FROM sqlite_master"
174 " WHERE type='table'"
175 " AND name NOT IN ('blob','delta','rcvfrom','user','config','shun')");
 
 
176 if( zTable==0 ) break;
177 db_multi_exec("DROP TABLE %Q", zTable);
178 free(zTable);
179 }
180 db_multi_exec(zRepositorySchema2);
181 ticket_create_table(0);
182
183 db_multi_exec("INSERT INTO unclustered SELECT rid FROM blob");
 
 
 
184 db_multi_exec(
185 "DELETE FROM unclustered"
186 " WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
187 );
188 db_multi_exec(
189
--- src/rebuild.c
+++ src/rebuild.c
@@ -35,14 +35,24 @@
35 @ --
36 @ CREATE INDEX IF NOT EXISTS delta_i1 ON delta(srcid);
37 @
38 @ -- Artifacts that should not be processed are identified in the
39 @ -- "shun" table. Artifacts that are control-file forgeries or
40 @ -- spam or artifacts whose contents violate administrative policy
41 @ -- can be shunned in order to prevent them from contaminating
42 @ -- the repository.
43 @ --
44 @ -- Shunned artifacts do not exist in the blob table. Hence they
45 @ -- have not artifact ID (rid) and we thus must store their full
46 @ -- UUID.
47 @ --
48 @ CREATE TABLE IF NOT EXISTS shun(uuid UNIQUE);
49 @
50 @ -- Artifacts that should not be pushed are stored in the "private"
51 @ -- table.
52 @ --
53 @ CREATE TABLE IF NOT EXISTS private(rid INTEGER PRIMARY KEY);
54 @
55 @ -- An entry in this table describes a database query that generates a
56 @ -- table of tickets.
57 @ --
58 @ CREATE TABLE IF NOT EXISTS reportfmt(
@@ -50,20 +60,10 @@
60 @ owner text, -- Owner of this report format (not used)
61 @ title text, -- Title of this report
62 @ cols text, -- A color-key specification
63 @ sqlcode text -- An SQL SELECT statement for this report
64 @ );
 
 
 
 
 
 
 
 
 
 
65 ;
66
67 /*
68 ** Variables used for progress information
69 */
@@ -170,19 +170,24 @@
170 db_multi_exec(zSchemaUpdates);
171 for(;;){
172 zTable = db_text(0,
173 "SELECT name FROM sqlite_master"
174 " WHERE type='table'"
175 " AND name NOT IN ('blob','delta','rcvfrom','user',"
176 "'config','shun','private')"
177 );
178 if( zTable==0 ) break;
179 db_multi_exec("DROP TABLE %Q", zTable);
180 free(zTable);
181 }
182 db_multi_exec(zRepositorySchema2);
183 ticket_create_table(0);
184
185 db_multi_exec(
186 "INSERT INTO unclustered"
187 " SELECT rid FROM blob EXCEPT SELECT rid FROM private"
188 );
189 db_multi_exec(
190 "DELETE FROM unclustered"
191 " WHERE rid IN (SELECT rid FROM shun JOIN blob USING(uuid))"
192 );
193 db_multi_exec(
194
+12 -1
--- src/schema.c
+++ src/schema.c
@@ -118,14 +118,25 @@
118118
@ CHECK( typeof(name)='text' AND length(name)>=1 )
119119
@ );
120120
@
121121
@ -- Artifacts that should not be processed are identified in the
122122
@ -- "shun" table. Artifacts that are control-file forgeries or
123
-@ -- spam can be shunned in order to prevent them from contaminating
123
+@ -- spam or artifacts whose contents violate administrative policy
124
+@ -- can be shunned in order to prevent them from contaminating
124125
@ -- the repository.
126
+@ --
127
+@ -- Shunned artifacts do not exist in the blob table. Hence they
128
+@ -- have not artifact ID (rid) and we thus must store their full
129
+@ -- UUID.
125130
@ --
126131
@ CREATE TABLE shun(uuid UNIQUE);
132
+@
133
+@ -- Artifacts that should not be pushed are stored in the "private"
134
+@ -- table. Private artifacts are omitted from the "unclustered" and
135
+@ -- "unsent" tables.
136
+@ --
137
+@ CREATE TABLE private(rid INTEGER PRIMARY KEY);
127138
@
128139
@ -- An entry in this table describes a database query that generates a
129140
@ -- table of tickets.
130141
@ --
131142
@ CREATE TABLE reportfmt(
132143
--- src/schema.c
+++ src/schema.c
@@ -118,14 +118,25 @@
118 @ CHECK( typeof(name)='text' AND length(name)>=1 )
119 @ );
120 @
121 @ -- Artifacts that should not be processed are identified in the
122 @ -- "shun" table. Artifacts that are control-file forgeries or
123 @ -- spam can be shunned in order to prevent them from contaminating
 
124 @ -- the repository.
 
 
 
 
125 @ --
126 @ CREATE TABLE shun(uuid UNIQUE);
 
 
 
 
 
 
127 @
128 @ -- An entry in this table describes a database query that generates a
129 @ -- table of tickets.
130 @ --
131 @ CREATE TABLE reportfmt(
132
--- src/schema.c
+++ src/schema.c
@@ -118,14 +118,25 @@
118 @ CHECK( typeof(name)='text' AND length(name)>=1 )
119 @ );
120 @
121 @ -- Artifacts that should not be processed are identified in the
122 @ -- "shun" table. Artifacts that are control-file forgeries or
123 @ -- spam or artifacts whose contents violate administrative policy
124 @ -- can be shunned in order to prevent them from contaminating
125 @ -- the repository.
126 @ --
127 @ -- Shunned artifacts do not exist in the blob table. Hence they
128 @ -- have not artifact ID (rid) and we thus must store their full
129 @ -- UUID.
130 @ --
131 @ CREATE TABLE shun(uuid UNIQUE);
132 @
133 @ -- Artifacts that should not be pushed are stored in the "private"
134 @ -- table. Private artifacts are omitted from the "unclustered" and
135 @ -- "unsent" tables.
136 @ --
137 @ CREATE TABLE private(rid INTEGER PRIMARY KEY);
138 @
139 @ -- An entry in this table describes a database query that generates a
140 @ -- table of tickets.
141 @ --
142 @ CREATE TABLE reportfmt(
143

Keyboard Shortcuts

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