Fossil SCM

Implement the hash-policy setting and the "fossil hash-policy" command. The default hash policy is "auto" for existing repositories and "shun-sha1" for new repositories.

drh 2017-03-04 20:06 fossil-2.1
Commit a616c04b6a010baee0cc55a385505ea922b69737
--- src/configure.c
+++ src/configure.c
@@ -129,10 +129,11 @@
129129
{ "empty-dirs", CONFIGSET_PROJ },
130130
{ "allow-symlinks", CONFIGSET_PROJ },
131131
{ "dotfiles", CONFIGSET_PROJ },
132132
{ "parent-project-code", CONFIGSET_PROJ },
133133
{ "parent-project-name", CONFIGSET_PROJ },
134
+ { "hash-policy", CONFIGSET_PROJ },
134135
135136
#ifdef FOSSIL_ENABLE_LEGACY_MV_RM
136137
{ "mv-rm-files", CONFIGSET_PROJ },
137138
#endif
138139
139140
--- src/configure.c
+++ src/configure.c
@@ -129,10 +129,11 @@
129 { "empty-dirs", CONFIGSET_PROJ },
130 { "allow-symlinks", CONFIGSET_PROJ },
131 { "dotfiles", CONFIGSET_PROJ },
132 { "parent-project-code", CONFIGSET_PROJ },
133 { "parent-project-name", CONFIGSET_PROJ },
 
134
135 #ifdef FOSSIL_ENABLE_LEGACY_MV_RM
136 { "mv-rm-files", CONFIGSET_PROJ },
137 #endif
138
139
--- src/configure.c
+++ src/configure.c
@@ -129,10 +129,11 @@
129 { "empty-dirs", CONFIGSET_PROJ },
130 { "allow-symlinks", CONFIGSET_PROJ },
131 { "dotfiles", CONFIGSET_PROJ },
132 { "parent-project-code", CONFIGSET_PROJ },
133 { "parent-project-name", CONFIGSET_PROJ },
134 { "hash-policy", CONFIGSET_PROJ },
135
136 #ifdef FOSSIL_ENABLE_LEGACY_MV_RM
137 { "mv-rm-files", CONFIGSET_PROJ },
138 #endif
139
140
+10
--- src/db.c
+++ src/db.c
@@ -1485,10 +1485,15 @@
14851485
g.repositoryOpen = 1;
14861486
/* Cache "allow-symlinks" option, because we'll need it on every stat call */
14871487
g.allowSymlinks = db_get_boolean("allow-symlinks",
14881488
db_allow_symlinks_by_default());
14891489
g.zAuxSchema = db_get("aux-schema","");
1490
+ g.eHashPolicy = db_get_int("hash-policy",-1);
1491
+ if( g.eHashPolicy<0 ){
1492
+ g.eHashPolicy = hname_default_policy();
1493
+ db_set_int("hash-policy", g.eHashPolicy, 0);
1494
+ }
14901495
14911496
/* If the ALIAS table is not present, then some on-the-fly schema
14921497
** updates might be required.
14931498
*/
14941499
rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
@@ -1917,14 +1922,17 @@
19171922
void create_repository_cmd(void){
19181923
char *zPassword;
19191924
const char *zTemplate; /* Repository from which to copy settings */
19201925
const char *zDate; /* Date of the initial check-in */
19211926
const char *zDefaultUser; /* Optional name of the default user */
1927
+
19221928
19231929
zTemplate = find_option("template",0,1);
19241930
zDate = find_option("date-override",0,1);
19251931
zDefaultUser = find_option("admin-user","A",1);
1932
+ g.eHashPolicy = HPOLICY_SHUN_SHA1;
1933
+ if( find_option("sha1",0,0)!=0 ) g.eHashPolicy = HPOLICY_SHA1;
19261934
/* We should be done with options.. */
19271935
verify_all_options();
19281936
19291937
if( g.argc!=3 ){
19301938
usage("REPOSITORY-NAME");
@@ -1937,10 +1945,12 @@
19371945
db_create_repository(g.argv[2]);
19381946
db_open_repository(g.argv[2]);
19391947
db_open_config(0, 0);
19401948
if( zTemplate ) db_attach(zTemplate, "settingSrc");
19411949
db_begin_transaction();
1950
+ g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
1951
+ db_set_int("hash-policy", g.eHashPolicy, 0);
19421952
if( zDate==0 ) zDate = "now";
19431953
db_initial_setup(zTemplate, zDate, zDefaultUser);
19441954
db_end_transaction(0);
19451955
if( zTemplate ) db_detach("settingSrc");
19461956
fossil_print("project-id: %s\n", db_get("project-code", 0));
19471957
--- src/db.c
+++ src/db.c
@@ -1485,10 +1485,15 @@
1485 g.repositoryOpen = 1;
1486 /* Cache "allow-symlinks" option, because we'll need it on every stat call */
1487 g.allowSymlinks = db_get_boolean("allow-symlinks",
1488 db_allow_symlinks_by_default());
1489 g.zAuxSchema = db_get("aux-schema","");
 
 
 
 
 
1490
1491 /* If the ALIAS table is not present, then some on-the-fly schema
1492 ** updates might be required.
1493 */
1494 rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
@@ -1917,14 +1922,17 @@
1917 void create_repository_cmd(void){
1918 char *zPassword;
1919 const char *zTemplate; /* Repository from which to copy settings */
1920 const char *zDate; /* Date of the initial check-in */
1921 const char *zDefaultUser; /* Optional name of the default user */
 
1922
1923 zTemplate = find_option("template",0,1);
1924 zDate = find_option("date-override",0,1);
1925 zDefaultUser = find_option("admin-user","A",1);
 
 
1926 /* We should be done with options.. */
1927 verify_all_options();
1928
1929 if( g.argc!=3 ){
1930 usage("REPOSITORY-NAME");
@@ -1937,10 +1945,12 @@
1937 db_create_repository(g.argv[2]);
1938 db_open_repository(g.argv[2]);
1939 db_open_config(0, 0);
1940 if( zTemplate ) db_attach(zTemplate, "settingSrc");
1941 db_begin_transaction();
 
 
1942 if( zDate==0 ) zDate = "now";
1943 db_initial_setup(zTemplate, zDate, zDefaultUser);
1944 db_end_transaction(0);
1945 if( zTemplate ) db_detach("settingSrc");
1946 fossil_print("project-id: %s\n", db_get("project-code", 0));
1947
--- src/db.c
+++ src/db.c
@@ -1485,10 +1485,15 @@
1485 g.repositoryOpen = 1;
1486 /* Cache "allow-symlinks" option, because we'll need it on every stat call */
1487 g.allowSymlinks = db_get_boolean("allow-symlinks",
1488 db_allow_symlinks_by_default());
1489 g.zAuxSchema = db_get("aux-schema","");
1490 g.eHashPolicy = db_get_int("hash-policy",-1);
1491 if( g.eHashPolicy<0 ){
1492 g.eHashPolicy = hname_default_policy();
1493 db_set_int("hash-policy", g.eHashPolicy, 0);
1494 }
1495
1496 /* If the ALIAS table is not present, then some on-the-fly schema
1497 ** updates might be required.
1498 */
1499 rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
@@ -1917,14 +1922,17 @@
1922 void create_repository_cmd(void){
1923 char *zPassword;
1924 const char *zTemplate; /* Repository from which to copy settings */
1925 const char *zDate; /* Date of the initial check-in */
1926 const char *zDefaultUser; /* Optional name of the default user */
1927
1928
1929 zTemplate = find_option("template",0,1);
1930 zDate = find_option("date-override",0,1);
1931 zDefaultUser = find_option("admin-user","A",1);
1932 g.eHashPolicy = HPOLICY_SHUN_SHA1;
1933 if( find_option("sha1",0,0)!=0 ) g.eHashPolicy = HPOLICY_SHA1;
1934 /* We should be done with options.. */
1935 verify_all_options();
1936
1937 if( g.argc!=3 ){
1938 usage("REPOSITORY-NAME");
@@ -1937,10 +1945,12 @@
1945 db_create_repository(g.argv[2]);
1946 db_open_repository(g.argv[2]);
1947 db_open_config(0, 0);
1948 if( zTemplate ) db_attach(zTemplate, "settingSrc");
1949 db_begin_transaction();
1950 g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
1951 db_set_int("hash-policy", g.eHashPolicy, 0);
1952 if( zDate==0 ) zDate = "now";
1953 db_initial_setup(zTemplate, zDate, zDefaultUser);
1954 db_end_transaction(0);
1955 if( zTemplate ) db_detach("settingSrc");
1956 fossil_print("project-id: %s\n", db_get("project-code", 0));
1957
+117 -20
--- src/hname.c
+++ src/hname.c
@@ -16,11 +16,13 @@
1616
*******************************************************************************
1717
**
1818
** This file contains generic code for dealing with hashes used for
1919
** naming artifacts. Specific hash algorithms are implemented separately
2020
** (for example in sha1.c and sha3.c). This file contains the generic
21
-** interface code.
21
+** interface logic.
22
+**
23
+** "hname" is intended to be an abbreviation of "hash name".
2224
*/
2325
#include "config.h"
2426
#include "hname.h"
2527
2628
@@ -47,10 +49,19 @@
4749
/*
4850
** The number of distinct hash algorithms:
4951
*/
5052
#define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */
5153
54
+/*
55
+** Hash naming policies
56
+*/
57
+#define HPOLICY_SHA1 0 /* Use SHA1 hashes */
58
+#define HPOLICY_AUTO 1 /* SHA1 but auto-promote to SHA3 */
59
+#define HPOLICY_SHA3 2 /* Use SHA3 hashes */
60
+#define HPOLICY_SHA3_ONLY 3 /* Use SHA3 hashes exclusively */
61
+#define HPOLICY_SHUN_SHA1 4 /* Shun all SHA1 objects */
62
+
5263
#endif /* INTERFACE */
5364
5465
/*
5566
** Return a human-readable name for the hash algorithm given a hash with
5667
** a length of nHash hexadecimal digits.
@@ -142,26 +153,112 @@
142153
143154
/*
144155
** Compute a hash on blob pContent. Write the hash into blob pHashOut.
145156
** This routine assumes that pHashOut is uninitialized.
146157
**
147
-** The preferred hash is used for iHType==0, and various alternative hashes
148
-** are used for iHType>0 && iHType<NHAME_COUNT.
158
+** The preferred hash is used for iHType==0 and the alternative hash is
159
+** used if iHType==1. (The interface is designed to accommodate more than
160
+** just two hashes, but HNAME_COUNT is currently fixed at 2.)
161
+**
162
+** Depending on the hash policy, the alternative hash may be disallowed.
163
+** If the alterative hash is disallowed, the routine returns 0. This
164
+** routine returns 1 if iHType>0 and the alternative hash is allowed,
165
+** and it always returns 1 when iHType==0.
166
+**
167
+** Alternative hash is disallowed for all hash policies except sha1
168
+** and sha3.
169
+*/
170
+int hname_hash(const Blob *pContent, unsigned int iHType, Blob *pHashOut){
171
+ assert( iHType==0 || iHType==1 );
172
+ if( iHType==1 ){
173
+ switch( g.eHashPolicy ){
174
+ case HPOLICY_SHA1:
175
+ sha3sum_blob(pContent, 256, pHashOut);
176
+ return 1;
177
+ case HPOLICY_SHA3:
178
+ sha1sum_blob(pContent, pHashOut);
179
+ return 1;
180
+ }
181
+ }
182
+ if( iHType==0 ){
183
+ switch( g.eHashPolicy ){
184
+ case HPOLICY_SHA1:
185
+ case HPOLICY_AUTO:
186
+ sha1sum_blob(pContent, pHashOut);
187
+ return 1;
188
+ case HPOLICY_SHA3:
189
+ case HPOLICY_SHA3_ONLY:
190
+ case HPOLICY_SHUN_SHA1:
191
+ sha3sum_blob(pContent, 256, pHashOut);
192
+ return 1;
193
+ }
194
+ }
195
+ blob_init(pHashOut, 0, 0);
196
+ return 0;
197
+}
198
+
199
+/*
200
+** Return the default hash policy for repositories that do not currently
201
+** have an assigned hash policy.
202
+**
203
+** Make the default HPOLICY_AUTO if there are no SHA3 artifacts in the
204
+** repository, and make the default HPOLICY_SHA3 if there are one or more
205
+** SHA3 artifacts.
206
+*/
207
+int hname_default_policy(void){
208
+ if( db_exists("SELECT 1 FROM blob WHERE length(uuid)>40") ){
209
+ return HPOLICY_SHA3;
210
+ }else{
211
+ return HPOLICY_AUTO;
212
+ }
213
+}
214
+
215
+/*
216
+** COMMAND: hash-policy*
217
+**
218
+** Usage: fossil hash-policy ?NEW-POLICY?
219
+**
220
+** Query or set the hash policy for the current repository. Available hash
221
+** policies are as follows:
222
+**
223
+** sha1 New artifact names are created using SHA1
224
+**
225
+** auto New artifact names are created using SHA1, but
226
+** automatically change the policy to "sha3" when
227
+** any SHA3 artifact enters the repository.
228
+**
229
+** sha3 New artifact names are created using SHA3, but
230
+** older artifacts with SHA1 names may be reused.
231
+**
232
+** sha3-only Use only SHA3 artifact names. Do not reuse legacy
233
+** SHA1 names.
234
+**
235
+** shun-sha1 Shun any SHA1 artifacts received by sync operations
236
+** other than clones. Older legacy SHA1 artifacts are
237
+** are allowed during a clone.
238
+**
239
+** The default hash policy for existing repositories is "auto", which will
240
+** immediately promote to "sha3" if the repository contains one or more
241
+** artifacts with SHA3 names. The default hash policy for new repositories
242
+** is "shun-sha1".
149243
*/
150
-void hname_hash(const Blob *pContent, unsigned int iHType, Blob *pHashOut){
151
-#if RELEASE_VERSION_NUMBER>=20100
152
- /* For Fossil 2.1 and later, the preferred hash algorithm is SHA3-256 and
153
- ** SHA1 is the secondary hash algorithm. */
154
- switch( iHType ){
155
- case 0: sha3sum_blob(pContent, 256, pHashOut); break;
156
- case 1: sha1sum_blob(pContent, pHashOut); break;
157
- }
158
-#else
159
- /* Prior to Fossil 2.1, the preferred hash algorithm is SHA1 (for backwards
160
- ** compatibility with Fossil 1.x) and SHA3-256 is the only auxiliary
161
- ** algorithm */
162
- switch( iHType ){
163
- case 0: sha1sum_blob(pContent, pHashOut); break;
164
- case 1: sha3sum_blob(pContent, 256, pHashOut); break;
165
- }
166
-#endif
244
+void hash_policy_command(void){
245
+ static const char *azPolicy[] = {
246
+ "sha1", "auto", "sha3", "sha3-only", "shun-sha1"
247
+ };
248
+ int i;
249
+ db_find_and_open_repository(0, 0);
250
+ if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
251
+ if( g.argc==2 ){
252
+ fossil_print("%s\n", azPolicy[g.eHashPolicy]);
253
+ return;
254
+ }
255
+ for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
256
+ if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
257
+ g.eHashPolicy = i;
258
+ db_set_int("hash-policy", i, 0);
259
+ return;
260
+ }
261
+ }
262
+ fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
263
+ " sha3 sha3-only shun-sha1", g.argv[2]);
167264
}
168265
--- src/hname.c
+++ src/hname.c
@@ -16,11 +16,13 @@
16 *******************************************************************************
17 **
18 ** This file contains generic code for dealing with hashes used for
19 ** naming artifacts. Specific hash algorithms are implemented separately
20 ** (for example in sha1.c and sha3.c). This file contains the generic
21 ** interface code.
 
 
22 */
23 #include "config.h"
24 #include "hname.h"
25
26
@@ -47,10 +49,19 @@
47 /*
48 ** The number of distinct hash algorithms:
49 */
50 #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */
51
 
 
 
 
 
 
 
 
 
52 #endif /* INTERFACE */
53
54 /*
55 ** Return a human-readable name for the hash algorithm given a hash with
56 ** a length of nHash hexadecimal digits.
@@ -142,26 +153,112 @@
142
143 /*
144 ** Compute a hash on blob pContent. Write the hash into blob pHashOut.
145 ** This routine assumes that pHashOut is uninitialized.
146 **
147 ** The preferred hash is used for iHType==0, and various alternative hashes
148 ** are used for iHType>0 && iHType<NHAME_COUNT.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149 */
150 void hname_hash(const Blob *pContent, unsigned int iHType, Blob *pHashOut){
151 #if RELEASE_VERSION_NUMBER>=20100
152 /* For Fossil 2.1 and later, the preferred hash algorithm is SHA3-256 and
153 ** SHA1 is the secondary hash algorithm. */
154 switch( iHType ){
155 case 0: sha3sum_blob(pContent, 256, pHashOut); break;
156 case 1: sha1sum_blob(pContent, pHashOut); break;
157 }
158 #else
159 /* Prior to Fossil 2.1, the preferred hash algorithm is SHA1 (for backwards
160 ** compatibility with Fossil 1.x) and SHA3-256 is the only auxiliary
161 ** algorithm */
162 switch( iHType ){
163 case 0: sha1sum_blob(pContent, pHashOut); break;
164 case 1: sha3sum_blob(pContent, 256, pHashOut); break;
165 }
166 #endif
 
 
 
167 }
168
--- src/hname.c
+++ src/hname.c
@@ -16,11 +16,13 @@
16 *******************************************************************************
17 **
18 ** This file contains generic code for dealing with hashes used for
19 ** naming artifacts. Specific hash algorithms are implemented separately
20 ** (for example in sha1.c and sha3.c). This file contains the generic
21 ** interface logic.
22 **
23 ** "hname" is intended to be an abbreviation of "hash name".
24 */
25 #include "config.h"
26 #include "hname.h"
27
28
@@ -47,10 +49,19 @@
49 /*
50 ** The number of distinct hash algorithms:
51 */
52 #define HNAME_COUNT 2 /* Just SHA1 and SHA3-256. Let's keep it that way! */
53
54 /*
55 ** Hash naming policies
56 */
57 #define HPOLICY_SHA1 0 /* Use SHA1 hashes */
58 #define HPOLICY_AUTO 1 /* SHA1 but auto-promote to SHA3 */
59 #define HPOLICY_SHA3 2 /* Use SHA3 hashes */
60 #define HPOLICY_SHA3_ONLY 3 /* Use SHA3 hashes exclusively */
61 #define HPOLICY_SHUN_SHA1 4 /* Shun all SHA1 objects */
62
63 #endif /* INTERFACE */
64
65 /*
66 ** Return a human-readable name for the hash algorithm given a hash with
67 ** a length of nHash hexadecimal digits.
@@ -142,26 +153,112 @@
153
154 /*
155 ** Compute a hash on blob pContent. Write the hash into blob pHashOut.
156 ** This routine assumes that pHashOut is uninitialized.
157 **
158 ** The preferred hash is used for iHType==0 and the alternative hash is
159 ** used if iHType==1. (The interface is designed to accommodate more than
160 ** just two hashes, but HNAME_COUNT is currently fixed at 2.)
161 **
162 ** Depending on the hash policy, the alternative hash may be disallowed.
163 ** If the alterative hash is disallowed, the routine returns 0. This
164 ** routine returns 1 if iHType>0 and the alternative hash is allowed,
165 ** and it always returns 1 when iHType==0.
166 **
167 ** Alternative hash is disallowed for all hash policies except sha1
168 ** and sha3.
169 */
170 int hname_hash(const Blob *pContent, unsigned int iHType, Blob *pHashOut){
171 assert( iHType==0 || iHType==1 );
172 if( iHType==1 ){
173 switch( g.eHashPolicy ){
174 case HPOLICY_SHA1:
175 sha3sum_blob(pContent, 256, pHashOut);
176 return 1;
177 case HPOLICY_SHA3:
178 sha1sum_blob(pContent, pHashOut);
179 return 1;
180 }
181 }
182 if( iHType==0 ){
183 switch( g.eHashPolicy ){
184 case HPOLICY_SHA1:
185 case HPOLICY_AUTO:
186 sha1sum_blob(pContent, pHashOut);
187 return 1;
188 case HPOLICY_SHA3:
189 case HPOLICY_SHA3_ONLY:
190 case HPOLICY_SHUN_SHA1:
191 sha3sum_blob(pContent, 256, pHashOut);
192 return 1;
193 }
194 }
195 blob_init(pHashOut, 0, 0);
196 return 0;
197 }
198
199 /*
200 ** Return the default hash policy for repositories that do not currently
201 ** have an assigned hash policy.
202 **
203 ** Make the default HPOLICY_AUTO if there are no SHA3 artifacts in the
204 ** repository, and make the default HPOLICY_SHA3 if there are one or more
205 ** SHA3 artifacts.
206 */
207 int hname_default_policy(void){
208 if( db_exists("SELECT 1 FROM blob WHERE length(uuid)>40") ){
209 return HPOLICY_SHA3;
210 }else{
211 return HPOLICY_AUTO;
212 }
213 }
214
215 /*
216 ** COMMAND: hash-policy*
217 **
218 ** Usage: fossil hash-policy ?NEW-POLICY?
219 **
220 ** Query or set the hash policy for the current repository. Available hash
221 ** policies are as follows:
222 **
223 ** sha1 New artifact names are created using SHA1
224 **
225 ** auto New artifact names are created using SHA1, but
226 ** automatically change the policy to "sha3" when
227 ** any SHA3 artifact enters the repository.
228 **
229 ** sha3 New artifact names are created using SHA3, but
230 ** older artifacts with SHA1 names may be reused.
231 **
232 ** sha3-only Use only SHA3 artifact names. Do not reuse legacy
233 ** SHA1 names.
234 **
235 ** shun-sha1 Shun any SHA1 artifacts received by sync operations
236 ** other than clones. Older legacy SHA1 artifacts are
237 ** are allowed during a clone.
238 **
239 ** The default hash policy for existing repositories is "auto", which will
240 ** immediately promote to "sha3" if the repository contains one or more
241 ** artifacts with SHA3 names. The default hash policy for new repositories
242 ** is "shun-sha1".
243 */
244 void hash_policy_command(void){
245 static const char *azPolicy[] = {
246 "sha1", "auto", "sha3", "sha3-only", "shun-sha1"
247 };
248 int i;
249 db_find_and_open_repository(0, 0);
250 if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
251 if( g.argc==2 ){
252 fossil_print("%s\n", azPolicy[g.eHashPolicy]);
253 return;
254 }
255 for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
256 if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
257 g.eHashPolicy = i;
258 db_set_int("hash-policy", i, 0);
259 return;
260 }
261 }
262 fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
263 " sha3 sha3-only shun-sha1", g.argv[2]);
264 }
265
+1
--- src/main.c
+++ src/main.c
@@ -140,10 +140,11 @@
140140
char *zLocalDbName; /* Name of the local database file */
141141
char *zOpenRevision; /* Check-in version to use during database open */
142142
int localOpen; /* True if the local database is open */
143143
char *zLocalRoot; /* The directory holding the local database */
144144
int minPrefix; /* Number of digits needed for a distinct UUID */
145
+ int eHashPolicy; /* Current hash policy. On of HPOLICY_* */
145146
int fNoDirSymlinks; /* True if --no-dir-symlinks flag is present */
146147
int fSqlTrace; /* True if --sqltrace flag is present */
147148
int fSqlStats; /* True if --sqltrace or --sqlstats are present */
148149
int fSqlPrint; /* True if -sqlprint flag is present */
149150
int fQuiet; /* True if -quiet flag is present */
150151
--- src/main.c
+++ src/main.c
@@ -140,10 +140,11 @@
140 char *zLocalDbName; /* Name of the local database file */
141 char *zOpenRevision; /* Check-in version to use during database open */
142 int localOpen; /* True if the local database is open */
143 char *zLocalRoot; /* The directory holding the local database */
144 int minPrefix; /* Number of digits needed for a distinct UUID */
 
145 int fNoDirSymlinks; /* True if --no-dir-symlinks flag is present */
146 int fSqlTrace; /* True if --sqltrace flag is present */
147 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
148 int fSqlPrint; /* True if -sqlprint flag is present */
149 int fQuiet; /* True if -quiet flag is present */
150
--- src/main.c
+++ src/main.c
@@ -140,10 +140,11 @@
140 char *zLocalDbName; /* Name of the local database file */
141 char *zOpenRevision; /* Check-in version to use during database open */
142 int localOpen; /* True if the local database is open */
143 char *zLocalRoot; /* The directory holding the local database */
144 int minPrefix; /* Number of digits needed for a distinct UUID */
145 int eHashPolicy; /* Current hash policy. On of HPOLICY_* */
146 int fNoDirSymlinks; /* True if --no-dir-symlinks flag is present */
147 int fSqlTrace; /* True if --sqltrace flag is present */
148 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
149 int fSqlPrint; /* True if -sqlprint flag is present */
150 int fQuiet; /* True if -quiet flag is present */
151
+1
--- src/shun.c
+++ src/shun.c
@@ -26,10 +26,11 @@
2626
*/
2727
int uuid_is_shunned(const char *zUuid){
2828
static Stmt q;
2929
int rc;
3030
if( zUuid==0 || zUuid[0]==0 ) return 0;
31
+ if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1;
3132
db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid");
3233
db_bind_text(&q, ":uuid", zUuid);
3334
rc = db_step(&q);
3435
db_reset(&q);
3536
return rc==SQLITE_ROW;
3637
--- src/shun.c
+++ src/shun.c
@@ -26,10 +26,11 @@
26 */
27 int uuid_is_shunned(const char *zUuid){
28 static Stmt q;
29 int rc;
30 if( zUuid==0 || zUuid[0]==0 ) return 0;
 
31 db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid");
32 db_bind_text(&q, ":uuid", zUuid);
33 rc = db_step(&q);
34 db_reset(&q);
35 return rc==SQLITE_ROW;
36
--- src/shun.c
+++ src/shun.c
@@ -26,10 +26,11 @@
26 */
27 int uuid_is_shunned(const char *zUuid){
28 static Stmt q;
29 int rc;
30 if( zUuid==0 || zUuid[0]==0 ) return 0;
31 if( g.eHashPolicy==HPOLICY_SHUN_SHA1 && zUuid[HNAME_LEN_SHA1]==0 ) return 1;
32 db_static_prepare(&q, "SELECT 1 FROM shun WHERE uuid=:uuid");
33 db_bind_text(&q, ":uuid", zUuid);
34 rc = db_step(&q);
35 db_reset(&q);
36 return rc==SQLITE_ROW;
37

Keyboard Shortcuts

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