Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | 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. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | fossil-2.1 |
| Files: | files | file ages | folders |
| SHA1: |
95543ce45b6fbc981c831a7508495de8 |
| User & Date: | drh 2017-03-04 20:38:30.501 |
Context
|
2017-03-04
| ||
| 21:03 | Preserve the hash policy on a clone. check-in: d9b3a863ef user: drh tags: fossil-2.1 | |
| 20:38 | 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. check-in: 95543ce45b user: drh tags: fossil-2.1 | |
| 20:06 | 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. check-in: a616c04b6a user: drh tags: fossil-2.1 | |
Changes
Changes to src/db.c.
| ︙ | ︙ | |||
1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 |
" SELECT name,value,mtime FROM settingSrc.config"
" WHERE (name IN %s OR name IN %s)"
" AND name NOT GLOB 'project-*'"
" AND name NOT GLOB 'short-project-*';",
configure_inop_rhs(CONFIGSET_ALL),
db_setting_inop_rhs()
);
db_multi_exec(
"REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
);
/*
** Copy the user permissions, contact information, last modified
** time, and photo for all the "system" users from the supplied
| > | 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 |
" SELECT name,value,mtime FROM settingSrc.config"
" WHERE (name IN %s OR name IN %s)"
" AND name NOT GLOB 'project-*'"
" AND name NOT GLOB 'short-project-*';",
configure_inop_rhs(CONFIGSET_ALL),
db_setting_inop_rhs()
);
g.eHashPolicy = db_get_int("hash-policy", g.eHashPolicy);
db_multi_exec(
"REPLACE INTO reportfmt SELECT * FROM settingSrc.reportfmt;"
);
/*
** Copy the user permissions, contact information, last modified
** time, and photo for all the "system" users from the supplied
|
| ︙ | ︙ | |||
1925 1926 1927 1928 1929 1930 1931 |
const char *zDate; /* Date of the initial check-in */
const char *zDefaultUser; /* Optional name of the default user */
zTemplate = find_option("template",0,1);
zDate = find_option("date-override",0,1);
zDefaultUser = find_option("admin-user","A",1);
| < < < < | 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 |
const char *zDate; /* Date of the initial check-in */
const char *zDefaultUser; /* Optional name of the default user */
zTemplate = find_option("template",0,1);
zDate = find_option("date-override",0,1);
zDefaultUser = find_option("admin-user","A",1);
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 ){
usage("REPOSITORY-NAME");
}
if( -1 != file_size(g.argv[2]) ){
fossil_fatal("file already exists: %s", g.argv[2]);
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config(0, 0);
if( zTemplate ) db_attach(zTemplate, "settingSrc");
db_begin_transaction();
if( zDate==0 ) zDate = "now";
db_initial_setup(zTemplate, zDate, zDefaultUser);
db_end_transaction(0);
if( zTemplate ) db_detach("settingSrc");
fossil_print("project-id: %s\n", db_get("project-code", 0));
fossil_print("server-id: %s\n", db_get("server-code", 0));
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
|
| ︙ | ︙ |
Changes to src/hname.c.
| ︙ | ︙ | |||
196 197 198 199 200 201 202 | return 0; } /* ** Return the default hash policy for repositories that do not currently ** have an assigned hash policy. ** | | | | > > > | | 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
return 0;
}
/*
** Return the default hash policy for repositories that do not currently
** have an assigned hash policy.
**
** Make the default HPOLICY_AUTO if there are SHA1 artficats but no SHA3
** artifacts in the repository. Make the default HPOLICY_SHA3 if there
** are one or more SHA3 artifacts. Make the default policy HPOLICY_SHUN_SHA1
** if the repository contains no artifact at all.
*/
int hname_default_policy(void){
if( db_exists("SELECT 1 FROM blob WHERE length(uuid)>40") ){
return HPOLICY_SHA3;
}else if( db_exists("SELECT 1 FROM blob WHERE length(uuid)==40") ){
return HPOLICY_AUTO;
}else{
return HPOLICY_SHUN_SHA1;
}
}
/*
** COMMAND: hash-policy*
**
** Usage: fossil hash-policy ?NEW-POLICY?
|
| ︙ | ︙ | |||
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
if( g.argc==2 ){
fossil_print("%s\n", azPolicy[g.eHashPolicy]);
return;
}
for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
g.eHashPolicy = i;
db_set_int("hash-policy", i, 0);
return;
}
}
fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
" sha3 sha3-only shun-sha1", g.argv[2]);
}
| > > > > > > | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
if( g.argc!=2 && g.argc!=3 ) usage("?NEW-POLICY?");
if( g.argc==2 ){
fossil_print("%s\n", azPolicy[g.eHashPolicy]);
return;
}
for(i=HPOLICY_SHA1; i<=HPOLICY_SHUN_SHA1; i++){
if( fossil_strcmp(g.argv[2],azPolicy[i])==0 ){
if( i==HPOLICY_AUTO
&& db_exists("SELECT 1 FROM blob WHERE length(uuid)>40")
){
i = HPOLICY_SHA3;
}
g.eHashPolicy = i;
db_set_int("hash-policy", i, 0);
fossil_print("%s\n", azPolicy[i]);
return;
}
}
fossil_fatal("unknown hash policy \"%s\" - should be one of: sha1 auto"
" sha3 sha3-only shun-sha1", g.argv[2]);
}
|