Fossil SCM

New repositories default to hash policy "shun-sha1" with a SHA3 initial check-in. But this can be overridden using the --template option with a template repository that is already set to a different hash policy.

drh 2017-03-04 20:38 fossil-2.1
Commit 95543ce45b6fbc981c831a7508495de8769f10a8
2 files changed +1 -4 +13 -4
+1 -4
--- src/db.c
+++ src/db.c
@@ -1833,10 +1833,11 @@
18331833
" AND name NOT GLOB 'project-*'"
18341834
" AND name NOT GLOB 'short-project-*';",
18351835
configure_inop_rhs(CONFIGSET_ALL),
18361836
db_setting_inop_rhs()
18371837
);
1838
+ g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
18381839
db_multi_exec(
18391840
"REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
18401841
);
18411842
18421843
/*
@@ -1927,12 +1928,10 @@
19271928
19281929
19291930
zTemplate = find_option("template",0,1);
19301931
zDate = find_option("date-override",0,1);
19311932
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;
19341933
/* We should be done with options.. */
19351934
verify_all_options();
19361935
19371936
if( g.argc!=3 ){
19381937
usage("REPOSITORY-NAME");
@@ -1945,12 +1944,10 @@
19451944
db_create_repository(g.argv[2]);
19461945
db_open_repository(g.argv[2]);
19471946
db_open_config(0, 0);
19481947
if( zTemplate ) db_attach(zTemplate, "settingSrc");
19491948
db_begin_transaction();
1950
- g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
1951
- db_set_int("hash-policy", g.eHashPolicy, 0);
19521949
if( zDate==0 ) zDate = "now";
19531950
db_initial_setup(zTemplate, zDate, zDefaultUser);
19541951
db_end_transaction(0);
19551952
if( zTemplate ) db_detach("settingSrc");
19561953
fossil_print("project-id: %s\n", db_get("project-code", 0));
19571954
--- src/db.c
+++ src/db.c
@@ -1833,10 +1833,11 @@
1833 " AND name NOT GLOB 'project-*'"
1834 " AND name NOT GLOB 'short-project-*';",
1835 configure_inop_rhs(CONFIGSET_ALL),
1836 db_setting_inop_rhs()
1837 );
 
1838 db_multi_exec(
1839 "REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
1840 );
1841
1842 /*
@@ -1927,12 +1928,10 @@
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");
@@ -1945,12 +1944,10 @@
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
--- src/db.c
+++ src/db.c
@@ -1833,10 +1833,11 @@
1833 " AND name NOT GLOB 'project-*'"
1834 " AND name NOT GLOB 'short-project-*';",
1835 configure_inop_rhs(CONFIGSET_ALL),
1836 db_setting_inop_rhs()
1837 );
1838 g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
1839 db_multi_exec(
1840 "REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
1841 );
1842
1843 /*
@@ -1927,12 +1928,10 @@
1928
1929
1930 zTemplate = find_option("template",0,1);
1931 zDate = find_option("date-override",0,1);
1932 zDefaultUser = find_option("admin-user","A",1);
 
 
1933 /* We should be done with options.. */
1934 verify_all_options();
1935
1936 if( g.argc!=3 ){
1937 usage("REPOSITORY-NAME");
@@ -1945,12 +1944,10 @@
1944 db_create_repository(g.argv[2]);
1945 db_open_repository(g.argv[2]);
1946 db_open_config(0, 0);
1947 if( zTemplate ) db_attach(zTemplate, "settingSrc");
1948 db_begin_transaction();
 
 
1949 if( zDate==0 ) zDate = "now";
1950 db_initial_setup(zTemplate, zDate, zDefaultUser);
1951 db_end_transaction(0);
1952 if( zTemplate ) db_detach("settingSrc");
1953 fossil_print("project-id: %s\n", db_get("project-code", 0));
1954
+13 -4
--- src/hname.c
+++ src/hname.c
@@ -198,19 +198,22 @@
198198
199199
/*
200200
** Return the default hash policy for repositories that do not currently
201201
** have an assigned hash policy.
202202
**
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.
203
+** Make the default HPOLICY_AUTO if there are SHA1 artficats but no SHA3
204
+** artifacts in the repository. Make the default HPOLICY_SHA3 if there
205
+** are one or more SHA3 artifacts. Make the default policy HPOLICY_SHUN_SHA1
206
+** if the repository contains no artifact at all.
206207
*/
207208
int hname_default_policy(void){
208209
if( db_exists("SELECT 1 FROM blob WHERE length(uuid)>40") ){
209210
return HPOLICY_SHA3;
210
- }else{
211
+ }else if( db_exists("SELECT 1 FROM blob WHERE length(uuid)==40") ){
211212
return HPOLICY_AUTO;
213
+ }else{
214
+ return HPOLICY_SHUN_SHA1;
212215
}
213216
}
214217
215218
/*
216219
** COMMAND: hash-policy*
@@ -252,13 +255,19 @@
252255
fossil_print("%s\n", azPolicy[g.eHashPolicy]);
253256
return;
254257
}
255258
for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
256259
if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
260
+ if( i==HPOLICY_AUTO
261
+ && db_exists("SELECT 1 FROM blob WHERE length(uuid)>40")
262
+ ){
263
+ i = HPOLICY_SHA3;
264
+ }
257265
g.eHashPolicy = i;
258266
db_set_int("hash-policy", i, 0);
267
+ fossil_print("%s\n", azPolicy[i]);
259268
return;
260269
}
261270
}
262271
fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
263272
" sha3 sha3-only shun-sha1", g.argv[2]);
264273
}
265274
--- src/hname.c
+++ src/hname.c
@@ -198,19 +198,22 @@
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*
@@ -252,13 +255,19 @@
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
--- src/hname.c
+++ src/hname.c
@@ -198,19 +198,22 @@
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 SHA1 artficats but no SHA3
204 ** artifacts in the repository. Make the default HPOLICY_SHA3 if there
205 ** are one or more SHA3 artifacts. Make the default policy HPOLICY_SHUN_SHA1
206 ** if the repository contains no artifact at all.
207 */
208 int hname_default_policy(void){
209 if( db_exists("SELECT 1 FROM blob WHERE length(uuid)>40") ){
210 return HPOLICY_SHA3;
211 }else if( db_exists("SELECT 1 FROM blob WHERE length(uuid)==40") ){
212 return HPOLICY_AUTO;
213 }else{
214 return HPOLICY_SHUN_SHA1;
215 }
216 }
217
218 /*
219 ** COMMAND: hash-policy*
@@ -252,13 +255,19 @@
255 fossil_print("%s\n", azPolicy[g.eHashPolicy]);
256 return;
257 }
258 for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
259 if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
260 if( i==HPOLICY_AUTO
261 && db_exists("SELECT 1 FROM blob WHERE length(uuid)>40")
262 ){
263 i = HPOLICY_SHA3;
264 }
265 g.eHashPolicy = i;
266 db_set_int("hash-policy", i, 0);
267 fossil_print("%s\n", azPolicy[i]);
268 return;
269 }
270 }
271 fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
272 " sha3 sha3-only shun-sha1", g.argv[2]);
273 }
274

Keyboard Shortcuts

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