Fossil SCM

Merge updates from trunk.

sdr 2014-09-25 05:13 winsymlink merge
Commit c42071515891e484704979b4485976a56f395cf8
+1
--- a/Dockerfile
+++ b/Dockerfile
@@ -0,0 +1 @@
1
+trunk
--- a/Dockerfile
+++ b/Dockerfile
@@ -0,0 +1 @@
 
--- a/Dockerfile
+++ b/Dockerfile
@@ -0,0 +1 @@
1 trunk
+1 -1
--- src/bisect.c
+++ src/bisect.c
@@ -396,11 +396,11 @@
396396
}
397397
}else if( g.argc==4 || g.argc==5 ){
398398
unsigned int i;
399399
n = strlen(g.argv[3]);
400400
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401
- if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
401
+ if( strncmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
402402
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
403403
if( g.argc==5 ){
404404
db_lset(z, g.argv[4]);
405405
}
406406
fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
407407
--- src/bisect.c
+++ src/bisect.c
@@ -396,11 +396,11 @@
396 }
397 }else if( g.argc==4 || g.argc==5 ){
398 unsigned int i;
399 n = strlen(g.argv[3]);
400 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401 if( memcmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
402 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
403 if( g.argc==5 ){
404 db_lset(z, g.argv[4]);
405 }
406 fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
407
--- src/bisect.c
+++ src/bisect.c
@@ -396,11 +396,11 @@
396 }
397 }else if( g.argc==4 || g.argc==5 ){
398 unsigned int i;
399 n = strlen(g.argv[3]);
400 for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
401 if( strncmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
402 char *z = mprintf("bisect-%s", aBisectOption[i].zName);
403 if( g.argc==5 ){
404 db_lset(z, g.argv[4]);
405 }
406 fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
407
+1 -1
--- src/captcha.c
+++ src/captcha.c
@@ -517,11 +517,11 @@
517517
char c = zEntered[i];
518518
if( c>='A' && c<='F' ) c += 'a' - 'A';
519519
if( c=='O' ) c = '0';
520520
z[i] = c;
521521
}
522
- if( memcmp(zDecode,z,8)!=0 ) return 0;
522
+ if( strncmp(zDecode,z,8)!=0 ) return 0;
523523
return 1;
524524
}
525525
526526
/*
527527
** Generate a captcha display together with the necessary hidden parameter
528528
--- src/captcha.c
+++ src/captcha.c
@@ -517,11 +517,11 @@
517 char c = zEntered[i];
518 if( c>='A' && c<='F' ) c += 'a' - 'A';
519 if( c=='O' ) c = '0';
520 z[i] = c;
521 }
522 if( memcmp(zDecode,z,8)!=0 ) return 0;
523 return 1;
524 }
525
526 /*
527 ** Generate a captcha display together with the necessary hidden parameter
528
--- src/captcha.c
+++ src/captcha.c
@@ -517,11 +517,11 @@
517 char c = zEntered[i];
518 if( c>='A' && c<='F' ) c += 'a' - 'A';
519 if( c=='O' ) c = '0';
520 z[i] = c;
521 }
522 if( strncmp(zDecode,z,8)!=0 ) return 0;
523 return 1;
524 }
525
526 /*
527 ** Generate a captcha display together with the necessary hidden parameter
528
+1 -1
--- src/cgi.c
+++ src/cgi.c
@@ -1715,11 +1715,11 @@
17151715
fflush(stdout);
17161716
if( zBrowser ){
17171717
zBrowser = mprintf(zBrowser, iPort);
17181718
#if defined(__CYGWIN__)
17191719
/* On Cygwin, we can do better than "echo" */
1720
- if( memcmp(zBrowser, "echo ", 5)==0 ){
1720
+ if( strncmp(zBrowser, "echo ", 5)==0 ){
17211721
wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
17221722
wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
17231723
if( (size_t)ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
17241724
fossil_warning("cannot start browser\n");
17251725
}
17261726
--- src/cgi.c
+++ src/cgi.c
@@ -1715,11 +1715,11 @@
1715 fflush(stdout);
1716 if( zBrowser ){
1717 zBrowser = mprintf(zBrowser, iPort);
1718 #if defined(__CYGWIN__)
1719 /* On Cygwin, we can do better than "echo" */
1720 if( memcmp(zBrowser, "echo ", 5)==0 ){
1721 wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
1722 wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
1723 if( (size_t)ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
1724 fossil_warning("cannot start browser\n");
1725 }
1726
--- src/cgi.c
+++ src/cgi.c
@@ -1715,11 +1715,11 @@
1715 fflush(stdout);
1716 if( zBrowser ){
1717 zBrowser = mprintf(zBrowser, iPort);
1718 #if defined(__CYGWIN__)
1719 /* On Cygwin, we can do better than "echo" */
1720 if( strncmp(zBrowser, "echo ", 5)==0 ){
1721 wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
1722 wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
1723 if( (size_t)ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
1724 fossil_warning("cannot start browser\n");
1725 }
1726
+3 -2
--- src/checkout.c
+++ src/checkout.c
@@ -137,14 +137,15 @@
137137
138138
if( db_get_boolean("manifest",0) ){
139139
blob_zero(&manifest);
140140
content_get(vid, &manifest);
141141
zManFile = mprintf("%smanifest", g.zLocalRoot);
142
- blob_write_to_file(&manifest, zManFile);
143
- free(zManFile);
144142
blob_zero(&hash);
145143
sha1sum_blob(&manifest, &hash);
144
+ sterilize_manifest(&manifest);
145
+ blob_write_to_file(&manifest, zManFile);
146
+ free(zManFile);
146147
zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
147148
blob_append(&hash, "\n", 1);
148149
blob_write_to_file(&hash, zManFile);
149150
free(zManFile);
150151
blob_reset(&hash);
151152
--- src/checkout.c
+++ src/checkout.c
@@ -137,14 +137,15 @@
137
138 if( db_get_boolean("manifest",0) ){
139 blob_zero(&manifest);
140 content_get(vid, &manifest);
141 zManFile = mprintf("%smanifest", g.zLocalRoot);
142 blob_write_to_file(&manifest, zManFile);
143 free(zManFile);
144 blob_zero(&hash);
145 sha1sum_blob(&manifest, &hash);
 
 
 
146 zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
147 blob_append(&hash, "\n", 1);
148 blob_write_to_file(&hash, zManFile);
149 free(zManFile);
150 blob_reset(&hash);
151
--- src/checkout.c
+++ src/checkout.c
@@ -137,14 +137,15 @@
137
138 if( db_get_boolean("manifest",0) ){
139 blob_zero(&manifest);
140 content_get(vid, &manifest);
141 zManFile = mprintf("%smanifest", g.zLocalRoot);
 
 
142 blob_zero(&hash);
143 sha1sum_blob(&manifest, &hash);
144 sterilize_manifest(&manifest);
145 blob_write_to_file(&manifest, zManFile);
146 free(zManFile);
147 zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
148 blob_append(&hash, "\n", 1);
149 blob_write_to_file(&hash, zManFile);
150 free(zManFile);
151 blob_reset(&hash);
152
+1 -1
--- src/configure.c
+++ src/configure.c
@@ -222,11 +222,11 @@
222222
if( n>2 && zName[0]=='\'' && zName[n-1]=='\'' ){
223223
zName++;
224224
n -= 2;
225225
}
226226
for(i=0; i<count(aConfig); i++){
227
- if( memcmp(zName, aConfig[i].zName, n)==0 && aConfig[i].zName[n]==0 ){
227
+ if( strncmp(zName, aConfig[i].zName, n)==0 && aConfig[i].zName[n]==0 ){
228228
int m = aConfig[i].groupMask;
229229
if( !g.perm.Admin ){
230230
m &= ~CONFIGSET_USER;
231231
}
232232
if( !g.perm.RdAddr ){
233233
--- src/configure.c
+++ src/configure.c
@@ -222,11 +222,11 @@
222 if( n>2 && zName[0]=='\'' && zName[n-1]=='\'' ){
223 zName++;
224 n -= 2;
225 }
226 for(i=0; i<count(aConfig); i++){
227 if( memcmp(zName, aConfig[i].zName, n)==0 && aConfig[i].zName[n]==0 ){
228 int m = aConfig[i].groupMask;
229 if( !g.perm.Admin ){
230 m &= ~CONFIGSET_USER;
231 }
232 if( !g.perm.RdAddr ){
233
--- src/configure.c
+++ src/configure.c
@@ -222,11 +222,11 @@
222 if( n>2 && zName[0]=='\'' && zName[n-1]=='\'' ){
223 zName++;
224 n -= 2;
225 }
226 for(i=0; i<count(aConfig); i++){
227 if( strncmp(zName, aConfig[i].zName, n)==0 && aConfig[i].zName[n]==0 ){
228 int m = aConfig[i].groupMask;
229 if( !g.perm.Admin ){
230 m &= ~CONFIGSET_USER;
231 }
232 if( !g.perm.RdAddr ){
233
+41 -10
--- src/db.c
+++ src/db.c
@@ -1311,10 +1311,42 @@
13111311
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
13121312
" VALUES('reader','','kptw','Reader');"
13131313
);
13141314
}
13151315
}
1316
+
1317
+/*
1318
+** This function sets the server and project codes if they do not already
1319
+** exist. Currently, it should be called only by the db_initial_setup()
1320
+** or cmd_webserver() functions, the latter being used to facilitate more
1321
+** robust integration with "canned image" environments (e.g. Docker).
1322
+*/
1323
+void db_setup_server_and_project_codes(
1324
+ int optional
1325
+){
1326
+ if( !optional ){
1327
+ db_multi_exec(
1328
+ "INSERT INTO config(name,value,mtime)"
1329
+ " VALUES('server-code', lower(hex(randomblob(20))),now());"
1330
+ "INSERT INTO config(name,value,mtime)"
1331
+ " VALUES('project-code', lower(hex(randomblob(20))),now());"
1332
+ );
1333
+ }else{
1334
+ if( db_get("server-code", 0)==0 ) {
1335
+ db_optional_sql("repository",
1336
+ "INSERT INTO config(name,value,mtime)"
1337
+ " VALUES('server-code', lower(hex(randomblob(20))),now());"
1338
+ );
1339
+ }
1340
+ if( db_get("project-code", 0)==0 ) {
1341
+ db_optional_sql("repository",
1342
+ "INSERT INTO config(name,value,mtime)"
1343
+ " VALUES('project-code', lower(hex(randomblob(20))),now());"
1344
+ );
1345
+ }
1346
+ }
1347
+}
13161348
13171349
/*
13181350
** Return a pointer to a string that contains the RHS of an IN operator
13191351
** that will select CONFIG table names that are in the list of control
13201352
** settings.
@@ -1364,16 +1396,11 @@
13641396
13651397
db_set("content-schema", CONTENT_SCHEMA, 0);
13661398
db_set("aux-schema", AUX_SCHEMA, 0);
13671399
db_set("rebuilt", get_version(), 0);
13681400
if( makeServerCodes ){
1369
- db_multi_exec(
1370
- "INSERT INTO config(name,value,mtime)"
1371
- " VALUES('server-code', lower(hex(randomblob(20))),now());"
1372
- "INSERT INTO config(name,value,mtime)"
1373
- " VALUES('project-code', lower(hex(randomblob(20))),now());"
1374
- );
1401
+ db_setup_server_and_project_codes(0);
13751402
}
13761403
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
13771404
if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
13781405
if( !db_is_global("timeline-plaintext") ){
13791406
db_set_int("timeline-plaintext", 1, 0);
@@ -1469,23 +1496,25 @@
14691496
** Options:
14701497
** --template FILE copy settings from repository file
14711498
** --admin-user|-A USERNAME select given USERNAME as admin user
14721499
** --date-override DATETIME use DATETIME as time of the initial checkin
14731500
** (default: do not create an initial checkin)
1501
+** --empty create repository without project-id/server-id
14741502
**
14751503
** See also: clone
14761504
*/
14771505
void create_repository_cmd(void){
14781506
char *zPassword;
14791507
const char *zTemplate; /* Repository from which to copy settings */
14801508
const char *zDate; /* Date of the initial check-in */
14811509
const char *zDefaultUser; /* Optional name of the default user */
1510
+ int makeServerCodes;
14821511
14831512
zTemplate = find_option("template",0,1);
14841513
zDate = find_option("date-override",0,1);
14851514
zDefaultUser = find_option("admin-user","A",1);
1486
- find_option("empty", 0, 0); /* deprecated */
1515
+ makeServerCodes = find_option("empty", 0, 0)==0;
14871516
14881517
/* We should be done with options.. */
14891518
verify_all_options();
14901519
14911520
if( g.argc!=3 ){
@@ -1494,15 +1523,17 @@
14941523
db_create_repository(g.argv[2]);
14951524
db_open_repository(g.argv[2]);
14961525
db_open_config(0);
14971526
if( zTemplate ) db_attach(zTemplate, "settingSrc");
14981527
db_begin_transaction();
1499
- db_initial_setup(zTemplate, zDate, zDefaultUser, 1);
1528
+ db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes);
15001529
db_end_transaction(0);
15011530
if( zTemplate ) db_detach("settingSrc");
1502
- fossil_print("project-id: %s\n", db_get("project-code", 0));
1503
- fossil_print("server-id: %s\n", db_get("server-code", 0));
1531
+ if( makeServerCodes ){
1532
+ fossil_print("project-id: %s\n", db_get("project-code", 0));
1533
+ fossil_print("server-id: %s\n", db_get("server-code", 0));
1534
+ }
15041535
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
15051536
fossil_print("admin-user: %s (initial password is \"%s\")\n",
15061537
g.zLogin, zPassword);
15071538
}
15081539
15091540
--- src/db.c
+++ src/db.c
@@ -1311,10 +1311,42 @@
1311 "INSERT OR IGNORE INTO user(login,pw,cap,info)"
1312 " VALUES('reader','','kptw','Reader');"
1313 );
1314 }
1315 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1316
1317 /*
1318 ** Return a pointer to a string that contains the RHS of an IN operator
1319 ** that will select CONFIG table names that are in the list of control
1320 ** settings.
@@ -1364,16 +1396,11 @@
1364
1365 db_set("content-schema", CONTENT_SCHEMA, 0);
1366 db_set("aux-schema", AUX_SCHEMA, 0);
1367 db_set("rebuilt", get_version(), 0);
1368 if( makeServerCodes ){
1369 db_multi_exec(
1370 "INSERT INTO config(name,value,mtime)"
1371 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1372 "INSERT INTO config(name,value,mtime)"
1373 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1374 );
1375 }
1376 if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
1377 if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
1378 if( !db_is_global("timeline-plaintext") ){
1379 db_set_int("timeline-plaintext", 1, 0);
@@ -1469,23 +1496,25 @@
1469 ** Options:
1470 ** --template FILE copy settings from repository file
1471 ** --admin-user|-A USERNAME select given USERNAME as admin user
1472 ** --date-override DATETIME use DATETIME as time of the initial checkin
1473 ** (default: do not create an initial checkin)
 
1474 **
1475 ** See also: clone
1476 */
1477 void create_repository_cmd(void){
1478 char *zPassword;
1479 const char *zTemplate; /* Repository from which to copy settings */
1480 const char *zDate; /* Date of the initial check-in */
1481 const char *zDefaultUser; /* Optional name of the default user */
 
1482
1483 zTemplate = find_option("template",0,1);
1484 zDate = find_option("date-override",0,1);
1485 zDefaultUser = find_option("admin-user","A",1);
1486 find_option("empty", 0, 0); /* deprecated */
1487
1488 /* We should be done with options.. */
1489 verify_all_options();
1490
1491 if( g.argc!=3 ){
@@ -1494,15 +1523,17 @@
1494 db_create_repository(g.argv[2]);
1495 db_open_repository(g.argv[2]);
1496 db_open_config(0);
1497 if( zTemplate ) db_attach(zTemplate, "settingSrc");
1498 db_begin_transaction();
1499 db_initial_setup(zTemplate, zDate, zDefaultUser, 1);
1500 db_end_transaction(0);
1501 if( zTemplate ) db_detach("settingSrc");
1502 fossil_print("project-id: %s\n", db_get("project-code", 0));
1503 fossil_print("server-id: %s\n", db_get("server-code", 0));
 
 
1504 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1505 fossil_print("admin-user: %s (initial password is \"%s\")\n",
1506 g.zLogin, zPassword);
1507 }
1508
1509
--- src/db.c
+++ src/db.c
@@ -1311,10 +1311,42 @@
1311 "INSERT OR IGNORE INTO user(login,pw,cap,info)"
1312 " VALUES('reader','','kptw','Reader');"
1313 );
1314 }
1315 }
1316
1317 /*
1318 ** This function sets the server and project codes if they do not already
1319 ** exist. Currently, it should be called only by the db_initial_setup()
1320 ** or cmd_webserver() functions, the latter being used to facilitate more
1321 ** robust integration with "canned image" environments (e.g. Docker).
1322 */
1323 void db_setup_server_and_project_codes(
1324 int optional
1325 ){
1326 if( !optional ){
1327 db_multi_exec(
1328 "INSERT INTO config(name,value,mtime)"
1329 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1330 "INSERT INTO config(name,value,mtime)"
1331 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1332 );
1333 }else{
1334 if( db_get("server-code", 0)==0 ) {
1335 db_optional_sql("repository",
1336 "INSERT INTO config(name,value,mtime)"
1337 " VALUES('server-code', lower(hex(randomblob(20))),now());"
1338 );
1339 }
1340 if( db_get("project-code", 0)==0 ) {
1341 db_optional_sql("repository",
1342 "INSERT INTO config(name,value,mtime)"
1343 " VALUES('project-code', lower(hex(randomblob(20))),now());"
1344 );
1345 }
1346 }
1347 }
1348
1349 /*
1350 ** Return a pointer to a string that contains the RHS of an IN operator
1351 ** that will select CONFIG table names that are in the list of control
1352 ** settings.
@@ -1364,16 +1396,11 @@
1396
1397 db_set("content-schema", CONTENT_SCHEMA, 0);
1398 db_set("aux-schema", AUX_SCHEMA, 0);
1399 db_set("rebuilt", get_version(), 0);
1400 if( makeServerCodes ){
1401 db_setup_server_and_project_codes(0);
 
 
 
 
 
1402 }
1403 if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
1404 if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
1405 if( !db_is_global("timeline-plaintext") ){
1406 db_set_int("timeline-plaintext", 1, 0);
@@ -1469,23 +1496,25 @@
1496 ** Options:
1497 ** --template FILE copy settings from repository file
1498 ** --admin-user|-A USERNAME select given USERNAME as admin user
1499 ** --date-override DATETIME use DATETIME as time of the initial checkin
1500 ** (default: do not create an initial checkin)
1501 ** --empty create repository without project-id/server-id
1502 **
1503 ** See also: clone
1504 */
1505 void create_repository_cmd(void){
1506 char *zPassword;
1507 const char *zTemplate; /* Repository from which to copy settings */
1508 const char *zDate; /* Date of the initial check-in */
1509 const char *zDefaultUser; /* Optional name of the default user */
1510 int makeServerCodes;
1511
1512 zTemplate = find_option("template",0,1);
1513 zDate = find_option("date-override",0,1);
1514 zDefaultUser = find_option("admin-user","A",1);
1515 makeServerCodes = find_option("empty", 0, 0)==0;
1516
1517 /* We should be done with options.. */
1518 verify_all_options();
1519
1520 if( g.argc!=3 ){
@@ -1494,15 +1523,17 @@
1523 db_create_repository(g.argv[2]);
1524 db_open_repository(g.argv[2]);
1525 db_open_config(0);
1526 if( zTemplate ) db_attach(zTemplate, "settingSrc");
1527 db_begin_transaction();
1528 db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes);
1529 db_end_transaction(0);
1530 if( zTemplate ) db_detach("settingSrc");
1531 if( makeServerCodes ){
1532 fossil_print("project-id: %s\n", db_get("project-code", 0));
1533 fossil_print("server-id: %s\n", db_get("server-code", 0));
1534 }
1535 zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
1536 fossil_print("admin-user: %s (initial password is \"%s\")\n",
1537 g.zLogin, zPassword);
1538 }
1539
1540
+1 -1
--- src/finfo.c
+++ src/finfo.c
@@ -430,11 +430,11 @@
430430
}else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
431431
zBgClr = strcmp(zBr,"trunk")==0 ? "" : hash_color(zBr);
432432
}
433433
gidx = graph_add_row(pGraph, frid, fpid>0 ? 1 : 0, &fpid, zBr, zBgClr,
434434
zUuid, 0);
435
- if( memcmp(zDate, zPrevDate, 10) ){
435
+ if( strncmp(zDate, zPrevDate, 10) ){
436436
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
437437
@ <tr><td>
438438
@ <div class="divider">%s(zPrevDate)</div>
439439
@ </td><td></td><td></td></tr>
440440
}
441441
--- src/finfo.c
+++ src/finfo.c
@@ -430,11 +430,11 @@
430 }else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
431 zBgClr = strcmp(zBr,"trunk")==0 ? "" : hash_color(zBr);
432 }
433 gidx = graph_add_row(pGraph, frid, fpid>0 ? 1 : 0, &fpid, zBr, zBgClr,
434 zUuid, 0);
435 if( memcmp(zDate, zPrevDate, 10) ){
436 sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
437 @ <tr><td>
438 @ <div class="divider">%s(zPrevDate)</div>
439 @ </td><td></td><td></td></tr>
440 }
441
--- src/finfo.c
+++ src/finfo.c
@@ -430,11 +430,11 @@
430 }else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
431 zBgClr = strcmp(zBr,"trunk")==0 ? "" : hash_color(zBr);
432 }
433 gidx = graph_add_row(pGraph, frid, fpid>0 ? 1 : 0, &fpid, zBr, zBgClr,
434 zUuid, 0);
435 if( strncmp(zDate, zPrevDate, 10) ){
436 sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
437 @ <tr><td>
438 @ <div class="divider">%s(zPrevDate)</div>
439 @ </td><td></td><td></td></tr>
440 }
441
+24 -24
--- src/import.c
+++ src/import.c
@@ -443,11 +443,11 @@
443443
static ImportFile *import_find_file(const char *zName, int *pI, int mx){
444444
int i = *pI;
445445
int nName = strlen(zName);
446446
while( i<mx ){
447447
const char *z = gg.aFile[i].zName;
448
- if( memcmp(zName, z, nName)==0 && (z[nName]==0 || z[nName]=='/') ){
448
+ if( strncmp(zName, z, nName)==0 && (z[nName]==0 || z[nName]=='/') ){
449449
*pI = i+1;
450450
return &gg.aFile[i];
451451
}
452452
i++;
453453
}
@@ -488,15 +488,15 @@
488488
char zLine[1000];
489489
490490
gg.xFinish = finish_noop;
491491
while( fgets(zLine, sizeof(zLine), pIn) ){
492492
if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
493
- if( memcmp(zLine, "blob", 4)==0 ){
493
+ if( strncmp(zLine, "blob", 4)==0 ){
494494
gg.xFinish();
495495
gg.xFinish = finish_blob;
496496
}else
497
- if( memcmp(zLine, "commit ", 7)==0 ){
497
+ if( strncmp(zLine, "commit ", 7)==0 ){
498498
gg.xFinish();
499499
gg.xFinish = finish_commit;
500500
trim_newline(&zLine[7]);
501501
z = &zLine[7];
502502
@@ -517,41 +517,41 @@
517517
**
518518
** None of the above is explained in the git-fast-export
519519
** documentation. We had to figure it out via trial and error.
520520
*/
521521
for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){}
522
- gg.tagCommit = memcmp(&z[i-4], "tags", 4)==0; /* True for pattern B */
522
+ gg.tagCommit = strncmp(&z[i-4], "tags", 4)==0; /* True for pattern B */
523523
if( z[i+1]!=0 ) z += i+1;
524524
if( fossil_strcmp(z, "master")==0 ) z = "trunk";
525525
gg.zBranch = fossil_strdup(z);
526526
gg.fromLoaded = 0;
527527
}else
528
- if( memcmp(zLine, "tag ", 4)==0 ){
528
+ if( strncmp(zLine, "tag ", 4)==0 ){
529529
gg.xFinish();
530530
gg.xFinish = finish_tag;
531531
trim_newline(&zLine[4]);
532532
gg.zTag = fossil_strdup(&zLine[4]);
533533
}else
534
- if( memcmp(zLine, "reset ", 4)==0 ){
534
+ if( strncmp(zLine, "reset ", 4)==0 ){
535
+ gg.xFinish();
536
+ }else
537
+ if( strncmp(zLine, "checkpoint", 10)==0 ){
535538
gg.xFinish();
536539
}else
537
- if( memcmp(zLine, "checkpoint", 10)==0 ){
540
+ if( strncmp(zLine, "feature", 7)==0 ){
538541
gg.xFinish();
539542
}else
540
- if( memcmp(zLine, "feature", 7)==0 ){
543
+ if( strncmp(zLine, "option", 6)==0 ){
541544
gg.xFinish();
542545
}else
543
- if( memcmp(zLine, "option", 6)==0 ){
544
- gg.xFinish();
545
- }else
546
- if( memcmp(zLine, "progress ", 9)==0 ){
546
+ if( strncmp(zLine, "progress ", 9)==0 ){
547547
gg.xFinish();
548548
trim_newline(&zLine[9]);
549549
fossil_print("%s\n", &zLine[9]);
550550
fflush(stdout);
551551
}else
552
- if( memcmp(zLine, "data ", 5)==0 ){
552
+ if( strncmp(zLine, "data ", 5)==0 ){
553553
fossil_free(gg.aData); gg.aData = 0;
554554
gg.nData = atoi(&zLine[5]);
555555
if( gg.nData ){
556556
int got;
557557
gg.aData = fossil_malloc( gg.nData+1 );
@@ -565,19 +565,19 @@
565565
gg.aData = 0;
566566
gg.nData = 0;
567567
}
568568
}
569569
}else
570
- if( memcmp(zLine, "author ", 7)==0 ){
570
+ if( strncmp(zLine, "author ", 7)==0 ){
571571
/* No-op */
572572
}else
573
- if( memcmp(zLine, "mark ", 5)==0 ){
573
+ if( strncmp(zLine, "mark ", 5)==0 ){
574574
trim_newline(&zLine[5]);
575575
fossil_free(gg.zMark);
576576
gg.zMark = fossil_strdup(&zLine[5]);
577577
}else
578
- if( memcmp(zLine, "tagger ", 7)==0 || memcmp(zLine, "committer ",10)==0 ){
578
+ if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
579579
sqlite3_int64 secSince1970;
580580
for(i=0; zLine[i] && zLine[i]!='<'; i++){}
581581
if( zLine[i]==0 ) goto malformed_line;
582582
z = &zLine[i+1];
583583
for(i=i+1; zLine[i] && zLine[i]!='>'; i++){}
@@ -591,27 +591,27 @@
591591
}
592592
fossil_free(gg.zDate);
593593
gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", secSince1970);
594594
gg.zDate[10] = 'T';
595595
}else
596
- if( memcmp(zLine, "from ", 5)==0 ){
596
+ if( strncmp(zLine, "from ", 5)==0 ){
597597
trim_newline(&zLine[5]);
598598
fossil_free(gg.zFromMark);
599599
gg.zFromMark = fossil_strdup(&zLine[5]);
600600
fossil_free(gg.zFrom);
601601
gg.zFrom = resolve_committish(&zLine[5]);
602602
}else
603
- if( memcmp(zLine, "merge ", 6)==0 ){
603
+ if( strncmp(zLine, "merge ", 6)==0 ){
604604
trim_newline(&zLine[6]);
605605
if( gg.nMerge>=gg.nMergeAlloc ){
606606
gg.nMergeAlloc = gg.nMergeAlloc*2 + 10;
607607
gg.azMerge = fossil_realloc(gg.azMerge, gg.nMergeAlloc*sizeof(char*));
608608
}
609609
gg.azMerge[gg.nMerge] = resolve_committish(&zLine[6]);
610610
if( gg.azMerge[gg.nMerge] ) gg.nMerge++;
611611
}else
612
- if( memcmp(zLine, "M ", 2)==0 ){
612
+ if( strncmp(zLine, "M ", 2)==0 ){
613613
import_prior_files();
614614
z = &zLine[2];
615615
zPerm = next_token(&z);
616616
zUuid = next_token(&z);
617617
zName = rest_of_line(&z);
@@ -626,11 +626,11 @@
626626
pFile->isLink = (fossil_strcmp(zPerm, "120000")==0);
627627
fossil_free(pFile->zUuid);
628628
pFile->zUuid = resolve_committish(zUuid);
629629
pFile->isFrom = 0;
630630
}else
631
- if( memcmp(zLine, "D ", 2)==0 ){
631
+ if( strncmp(zLine, "D ", 2)==0 ){
632632
import_prior_files();
633633
z = &zLine[2];
634634
zName = rest_of_line(&z);
635635
dequote_git_filename(zName);
636636
i = 0;
@@ -641,11 +641,11 @@
641641
fossil_free(pFile->zUuid);
642642
*pFile = gg.aFile[--gg.nFile];
643643
i--;
644644
}
645645
}else
646
- if( memcmp(zLine, "C ", 2)==0 ){
646
+ if( strncmp(zLine, "C ", 2)==0 ){
647647
int nFrom;
648648
import_prior_files();
649649
z = &zLine[2];
650650
zFrom = next_token(&z);
651651
zTo = rest_of_line(&z);
@@ -665,11 +665,11 @@
665665
pNew->isLink = pFile->isLink;
666666
pNew->zUuid = fossil_strdup(pFile->zUuid);
667667
pNew->isFrom = 0;
668668
}
669669
}else
670
- if( memcmp(zLine, "R ", 2)==0 ){
670
+ if( strncmp(zLine, "R ", 2)==0 ){
671671
int nFrom;
672672
import_prior_files();
673673
z = &zLine[2];
674674
zFrom = next_token(&z);
675675
zTo = rest_of_line(&z);
@@ -693,14 +693,14 @@
693693
*pFile = *pNew;
694694
memset(pNew, 0, sizeof(*pNew));
695695
}
696696
fossil_fatal("cannot handle R records, use --full-tree");
697697
}else
698
- if( memcmp(zLine, "deleteall", 9)==0 ){
698
+ if( strncmp(zLine, "deleteall", 9)==0 ){
699699
gg.fromLoaded = 1;
700700
}else
701
- if( memcmp(zLine, "N ", 2)==0 ){
701
+ if( strncmp(zLine, "N ", 2)==0 ){
702702
/* No-op */
703703
}else
704704
705705
{
706706
goto malformed_line;
707707
--- src/import.c
+++ src/import.c
@@ -443,11 +443,11 @@
443 static ImportFile *import_find_file(const char *zName, int *pI, int mx){
444 int i = *pI;
445 int nName = strlen(zName);
446 while( i<mx ){
447 const char *z = gg.aFile[i].zName;
448 if( memcmp(zName, z, nName)==0 && (z[nName]==0 || z[nName]=='/') ){
449 *pI = i+1;
450 return &gg.aFile[i];
451 }
452 i++;
453 }
@@ -488,15 +488,15 @@
488 char zLine[1000];
489
490 gg.xFinish = finish_noop;
491 while( fgets(zLine, sizeof(zLine), pIn) ){
492 if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
493 if( memcmp(zLine, "blob", 4)==0 ){
494 gg.xFinish();
495 gg.xFinish = finish_blob;
496 }else
497 if( memcmp(zLine, "commit ", 7)==0 ){
498 gg.xFinish();
499 gg.xFinish = finish_commit;
500 trim_newline(&zLine[7]);
501 z = &zLine[7];
502
@@ -517,41 +517,41 @@
517 **
518 ** None of the above is explained in the git-fast-export
519 ** documentation. We had to figure it out via trial and error.
520 */
521 for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){}
522 gg.tagCommit = memcmp(&z[i-4], "tags", 4)==0; /* True for pattern B */
523 if( z[i+1]!=0 ) z += i+1;
524 if( fossil_strcmp(z, "master")==0 ) z = "trunk";
525 gg.zBranch = fossil_strdup(z);
526 gg.fromLoaded = 0;
527 }else
528 if( memcmp(zLine, "tag ", 4)==0 ){
529 gg.xFinish();
530 gg.xFinish = finish_tag;
531 trim_newline(&zLine[4]);
532 gg.zTag = fossil_strdup(&zLine[4]);
533 }else
534 if( memcmp(zLine, "reset ", 4)==0 ){
 
 
 
535 gg.xFinish();
536 }else
537 if( memcmp(zLine, "checkpoint", 10)==0 ){
538 gg.xFinish();
539 }else
540 if( memcmp(zLine, "feature", 7)==0 ){
541 gg.xFinish();
542 }else
543 if( memcmp(zLine, "option", 6)==0 ){
544 gg.xFinish();
545 }else
546 if( memcmp(zLine, "progress ", 9)==0 ){
547 gg.xFinish();
548 trim_newline(&zLine[9]);
549 fossil_print("%s\n", &zLine[9]);
550 fflush(stdout);
551 }else
552 if( memcmp(zLine, "data ", 5)==0 ){
553 fossil_free(gg.aData); gg.aData = 0;
554 gg.nData = atoi(&zLine[5]);
555 if( gg.nData ){
556 int got;
557 gg.aData = fossil_malloc( gg.nData+1 );
@@ -565,19 +565,19 @@
565 gg.aData = 0;
566 gg.nData = 0;
567 }
568 }
569 }else
570 if( memcmp(zLine, "author ", 7)==0 ){
571 /* No-op */
572 }else
573 if( memcmp(zLine, "mark ", 5)==0 ){
574 trim_newline(&zLine[5]);
575 fossil_free(gg.zMark);
576 gg.zMark = fossil_strdup(&zLine[5]);
577 }else
578 if( memcmp(zLine, "tagger ", 7)==0 || memcmp(zLine, "committer ",10)==0 ){
579 sqlite3_int64 secSince1970;
580 for(i=0; zLine[i] && zLine[i]!='<'; i++){}
581 if( zLine[i]==0 ) goto malformed_line;
582 z = &zLine[i+1];
583 for(i=i+1; zLine[i] && zLine[i]!='>'; i++){}
@@ -591,27 +591,27 @@
591 }
592 fossil_free(gg.zDate);
593 gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", secSince1970);
594 gg.zDate[10] = 'T';
595 }else
596 if( memcmp(zLine, "from ", 5)==0 ){
597 trim_newline(&zLine[5]);
598 fossil_free(gg.zFromMark);
599 gg.zFromMark = fossil_strdup(&zLine[5]);
600 fossil_free(gg.zFrom);
601 gg.zFrom = resolve_committish(&zLine[5]);
602 }else
603 if( memcmp(zLine, "merge ", 6)==0 ){
604 trim_newline(&zLine[6]);
605 if( gg.nMerge>=gg.nMergeAlloc ){
606 gg.nMergeAlloc = gg.nMergeAlloc*2 + 10;
607 gg.azMerge = fossil_realloc(gg.azMerge, gg.nMergeAlloc*sizeof(char*));
608 }
609 gg.azMerge[gg.nMerge] = resolve_committish(&zLine[6]);
610 if( gg.azMerge[gg.nMerge] ) gg.nMerge++;
611 }else
612 if( memcmp(zLine, "M ", 2)==0 ){
613 import_prior_files();
614 z = &zLine[2];
615 zPerm = next_token(&z);
616 zUuid = next_token(&z);
617 zName = rest_of_line(&z);
@@ -626,11 +626,11 @@
626 pFile->isLink = (fossil_strcmp(zPerm, "120000")==0);
627 fossil_free(pFile->zUuid);
628 pFile->zUuid = resolve_committish(zUuid);
629 pFile->isFrom = 0;
630 }else
631 if( memcmp(zLine, "D ", 2)==0 ){
632 import_prior_files();
633 z = &zLine[2];
634 zName = rest_of_line(&z);
635 dequote_git_filename(zName);
636 i = 0;
@@ -641,11 +641,11 @@
641 fossil_free(pFile->zUuid);
642 *pFile = gg.aFile[--gg.nFile];
643 i--;
644 }
645 }else
646 if( memcmp(zLine, "C ", 2)==0 ){
647 int nFrom;
648 import_prior_files();
649 z = &zLine[2];
650 zFrom = next_token(&z);
651 zTo = rest_of_line(&z);
@@ -665,11 +665,11 @@
665 pNew->isLink = pFile->isLink;
666 pNew->zUuid = fossil_strdup(pFile->zUuid);
667 pNew->isFrom = 0;
668 }
669 }else
670 if( memcmp(zLine, "R ", 2)==0 ){
671 int nFrom;
672 import_prior_files();
673 z = &zLine[2];
674 zFrom = next_token(&z);
675 zTo = rest_of_line(&z);
@@ -693,14 +693,14 @@
693 *pFile = *pNew;
694 memset(pNew, 0, sizeof(*pNew));
695 }
696 fossil_fatal("cannot handle R records, use --full-tree");
697 }else
698 if( memcmp(zLine, "deleteall", 9)==0 ){
699 gg.fromLoaded = 1;
700 }else
701 if( memcmp(zLine, "N ", 2)==0 ){
702 /* No-op */
703 }else
704
705 {
706 goto malformed_line;
707
--- src/import.c
+++ src/import.c
@@ -443,11 +443,11 @@
443 static ImportFile *import_find_file(const char *zName, int *pI, int mx){
444 int i = *pI;
445 int nName = strlen(zName);
446 while( i<mx ){
447 const char *z = gg.aFile[i].zName;
448 if( strncmp(zName, z, nName)==0 && (z[nName]==0 || z[nName]=='/') ){
449 *pI = i+1;
450 return &gg.aFile[i];
451 }
452 i++;
453 }
@@ -488,15 +488,15 @@
488 char zLine[1000];
489
490 gg.xFinish = finish_noop;
491 while( fgets(zLine, sizeof(zLine), pIn) ){
492 if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
493 if( strncmp(zLine, "blob", 4)==0 ){
494 gg.xFinish();
495 gg.xFinish = finish_blob;
496 }else
497 if( strncmp(zLine, "commit ", 7)==0 ){
498 gg.xFinish();
499 gg.xFinish = finish_commit;
500 trim_newline(&zLine[7]);
501 z = &zLine[7];
502
@@ -517,41 +517,41 @@
517 **
518 ** None of the above is explained in the git-fast-export
519 ** documentation. We had to figure it out via trial and error.
520 */
521 for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){}
522 gg.tagCommit = strncmp(&z[i-4], "tags", 4)==0; /* True for pattern B */
523 if( z[i+1]!=0 ) z += i+1;
524 if( fossil_strcmp(z, "master")==0 ) z = "trunk";
525 gg.zBranch = fossil_strdup(z);
526 gg.fromLoaded = 0;
527 }else
528 if( strncmp(zLine, "tag ", 4)==0 ){
529 gg.xFinish();
530 gg.xFinish = finish_tag;
531 trim_newline(&zLine[4]);
532 gg.zTag = fossil_strdup(&zLine[4]);
533 }else
534 if( strncmp(zLine, "reset ", 4)==0 ){
535 gg.xFinish();
536 }else
537 if( strncmp(zLine, "checkpoint", 10)==0 ){
538 gg.xFinish();
539 }else
540 if( strncmp(zLine, "feature", 7)==0 ){
541 gg.xFinish();
542 }else
543 if( strncmp(zLine, "option", 6)==0 ){
544 gg.xFinish();
545 }else
546 if( strncmp(zLine, "progress ", 9)==0 ){
 
 
 
547 gg.xFinish();
548 trim_newline(&zLine[9]);
549 fossil_print("%s\n", &zLine[9]);
550 fflush(stdout);
551 }else
552 if( strncmp(zLine, "data ", 5)==0 ){
553 fossil_free(gg.aData); gg.aData = 0;
554 gg.nData = atoi(&zLine[5]);
555 if( gg.nData ){
556 int got;
557 gg.aData = fossil_malloc( gg.nData+1 );
@@ -565,19 +565,19 @@
565 gg.aData = 0;
566 gg.nData = 0;
567 }
568 }
569 }else
570 if( strncmp(zLine, "author ", 7)==0 ){
571 /* No-op */
572 }else
573 if( strncmp(zLine, "mark ", 5)==0 ){
574 trim_newline(&zLine[5]);
575 fossil_free(gg.zMark);
576 gg.zMark = fossil_strdup(&zLine[5]);
577 }else
578 if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
579 sqlite3_int64 secSince1970;
580 for(i=0; zLine[i] && zLine[i]!='<'; i++){}
581 if( zLine[i]==0 ) goto malformed_line;
582 z = &zLine[i+1];
583 for(i=i+1; zLine[i] && zLine[i]!='>'; i++){}
@@ -591,27 +591,27 @@
591 }
592 fossil_free(gg.zDate);
593 gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", secSince1970);
594 gg.zDate[10] = 'T';
595 }else
596 if( strncmp(zLine, "from ", 5)==0 ){
597 trim_newline(&zLine[5]);
598 fossil_free(gg.zFromMark);
599 gg.zFromMark = fossil_strdup(&zLine[5]);
600 fossil_free(gg.zFrom);
601 gg.zFrom = resolve_committish(&zLine[5]);
602 }else
603 if( strncmp(zLine, "merge ", 6)==0 ){
604 trim_newline(&zLine[6]);
605 if( gg.nMerge>=gg.nMergeAlloc ){
606 gg.nMergeAlloc = gg.nMergeAlloc*2 + 10;
607 gg.azMerge = fossil_realloc(gg.azMerge, gg.nMergeAlloc*sizeof(char*));
608 }
609 gg.azMerge[gg.nMerge] = resolve_committish(&zLine[6]);
610 if( gg.azMerge[gg.nMerge] ) gg.nMerge++;
611 }else
612 if( strncmp(zLine, "M ", 2)==0 ){
613 import_prior_files();
614 z = &zLine[2];
615 zPerm = next_token(&z);
616 zUuid = next_token(&z);
617 zName = rest_of_line(&z);
@@ -626,11 +626,11 @@
626 pFile->isLink = (fossil_strcmp(zPerm, "120000")==0);
627 fossil_free(pFile->zUuid);
628 pFile->zUuid = resolve_committish(zUuid);
629 pFile->isFrom = 0;
630 }else
631 if( strncmp(zLine, "D ", 2)==0 ){
632 import_prior_files();
633 z = &zLine[2];
634 zName = rest_of_line(&z);
635 dequote_git_filename(zName);
636 i = 0;
@@ -641,11 +641,11 @@
641 fossil_free(pFile->zUuid);
642 *pFile = gg.aFile[--gg.nFile];
643 i--;
644 }
645 }else
646 if( strncmp(zLine, "C ", 2)==0 ){
647 int nFrom;
648 import_prior_files();
649 z = &zLine[2];
650 zFrom = next_token(&z);
651 zTo = rest_of_line(&z);
@@ -665,11 +665,11 @@
665 pNew->isLink = pFile->isLink;
666 pNew->zUuid = fossil_strdup(pFile->zUuid);
667 pNew->isFrom = 0;
668 }
669 }else
670 if( strncmp(zLine, "R ", 2)==0 ){
671 int nFrom;
672 import_prior_files();
673 z = &zLine[2];
674 zFrom = next_token(&z);
675 zTo = rest_of_line(&z);
@@ -693,14 +693,14 @@
693 *pFile = *pNew;
694 memset(pNew, 0, sizeof(*pNew));
695 }
696 fossil_fatal("cannot handle R records, use --full-tree");
697 }else
698 if( strncmp(zLine, "deleteall", 9)==0 ){
699 gg.fromLoaded = 1;
700 }else
701 if( strncmp(zLine, "N ", 2)==0 ){
702 /* No-op */
703 }else
704
705 {
706 goto malformed_line;
707
+2
--- src/main.c
+++ src/main.c
@@ -2197,10 +2197,12 @@
21972197
}else{
21982198
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
21992199
}
22002200
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
22012201
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2202
+ }else{
2203
+ db_setup_server_and_project_codes(1);
22022204
}
22032205
db_close(1);
22042206
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
22052207
fossil_fatal("unable to listen on TCP socket %d", iPort);
22062208
}
22072209
--- src/main.c
+++ src/main.c
@@ -2197,10 +2197,12 @@
2197 }else{
2198 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2199 }
2200 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2201 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
 
 
2202 }
2203 db_close(1);
2204 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2205 fossil_fatal("unable to listen on TCP socket %d", iPort);
2206 }
2207
--- src/main.c
+++ src/main.c
@@ -2197,10 +2197,12 @@
2197 }else{
2198 zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
2199 }
2200 if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
2201 if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
2202 }else{
2203 db_setup_server_and_project_codes(1);
2204 }
2205 db_close(1);
2206 if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
2207 fossil_fatal("unable to listen on TCP socket %d", iPort);
2208 }
2209
+40 -2
--- src/manifest.c
+++ src/manifest.c
@@ -229,18 +229,18 @@
229229
*/
230230
static void remove_pgp_signature(char **pz, int *pn){
231231
char *z = *pz;
232232
int n = *pn;
233233
int i;
234
- if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
234
+ if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
235235
for(i=34; i<n && !after_blank_line(z+i); i++){}
236236
if( i>=n ) return;
237237
z += i;
238238
n -= i;
239239
*pz = z;
240240
for(i=n-1; i>=0; i--){
241
- if( z[i]=='\n' && memcmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
241
+ if( z[i]=='\n' && strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
242242
n = i+1;
243243
break;
244244
}
245245
}
246246
*pn = n;
@@ -1641,10 +1641,48 @@
16411641
blob_str(&comment), blob_str(&brief)
16421642
);
16431643
blob_reset(&comment);
16441644
blob_reset(&brief);
16451645
}
1646
+
1647
+/*
1648
+** Add an extra line of text to the end of a manifest to prevent it being
1649
+** recognized as a valid manifest.
1650
+**
1651
+** This routine is called prior to writing out the text of a manifest as
1652
+** the "manifest" file in the root of a repository when
1653
+** "fossil setting manifest on" is enabled. That way, if the files of
1654
+** the project are imported into a different Fossil project, the manifest
1655
+** file will not be interpreted as a control artifact in that other project.
1656
+**
1657
+** Normally it is sufficient to simply append the extra line of text.
1658
+** However, if the manifest is PGP signed then the extra line has to be
1659
+** inserted before the PGP signature (thus invalidating the signature).
1660
+*/
1661
+void sterilize_manifest(Blob *p){
1662
+ char *z, *zOrig;
1663
+ int n, nOrig;
1664
+ static const char zExtraLine[] =
1665
+ "# Remove this line to create a well-formed manifest.\n";
1666
+
1667
+ z = zOrig = blob_materialize(p);
1668
+ n = nOrig = blob_size(p);
1669
+ remove_pgp_signature(&z, &n);
1670
+ if( z==zOrig ){
1671
+ blob_append(p, zExtraLine, -1);
1672
+ }else{
1673
+ int iEnd;
1674
+ Blob copy;
1675
+ memcpy(&copy, p, sizeof(copy));
1676
+ blob_init(p, 0, 0);
1677
+ iEnd = (int)(&z[n] - zOrig);
1678
+ blob_append(p, zOrig, iEnd);
1679
+ blob_append(p, zExtraLine, -1);
1680
+ blob_append(p, &zOrig[iEnd], -1);
1681
+ blob_zero(&copy);
1682
+ }
1683
+}
16461684
16471685
/*
16481686
** This is the comparison function used to sort the tag array.
16491687
*/
16501688
static int tag_compare(const void *a, const void *b){
16511689
--- src/manifest.c
+++ src/manifest.c
@@ -229,18 +229,18 @@
229 */
230 static void remove_pgp_signature(char **pz, int *pn){
231 char *z = *pz;
232 int n = *pn;
233 int i;
234 if( memcmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
235 for(i=34; i<n && !after_blank_line(z+i); i++){}
236 if( i>=n ) return;
237 z += i;
238 n -= i;
239 *pz = z;
240 for(i=n-1; i>=0; i--){
241 if( z[i]=='\n' && memcmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
242 n = i+1;
243 break;
244 }
245 }
246 *pn = n;
@@ -1641,10 +1641,48 @@
1641 blob_str(&comment), blob_str(&brief)
1642 );
1643 blob_reset(&comment);
1644 blob_reset(&brief);
1645 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1646
1647 /*
1648 ** This is the comparison function used to sort the tag array.
1649 */
1650 static int tag_compare(const void *a, const void *b){
1651
--- src/manifest.c
+++ src/manifest.c
@@ -229,18 +229,18 @@
229 */
230 static void remove_pgp_signature(char **pz, int *pn){
231 char *z = *pz;
232 int n = *pn;
233 int i;
234 if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
235 for(i=34; i<n && !after_blank_line(z+i); i++){}
236 if( i>=n ) return;
237 z += i;
238 n -= i;
239 *pz = z;
240 for(i=n-1; i>=0; i--){
241 if( z[i]=='\n' && strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
242 n = i+1;
243 break;
244 }
245 }
246 *pn = n;
@@ -1641,10 +1641,48 @@
1641 blob_str(&comment), blob_str(&brief)
1642 );
1643 blob_reset(&comment);
1644 blob_reset(&brief);
1645 }
1646
1647 /*
1648 ** Add an extra line of text to the end of a manifest to prevent it being
1649 ** recognized as a valid manifest.
1650 **
1651 ** This routine is called prior to writing out the text of a manifest as
1652 ** the "manifest" file in the root of a repository when
1653 ** "fossil setting manifest on" is enabled. That way, if the files of
1654 ** the project are imported into a different Fossil project, the manifest
1655 ** file will not be interpreted as a control artifact in that other project.
1656 **
1657 ** Normally it is sufficient to simply append the extra line of text.
1658 ** However, if the manifest is PGP signed then the extra line has to be
1659 ** inserted before the PGP signature (thus invalidating the signature).
1660 */
1661 void sterilize_manifest(Blob *p){
1662 char *z, *zOrig;
1663 int n, nOrig;
1664 static const char zExtraLine[] =
1665 "# Remove this line to create a well-formed manifest.\n";
1666
1667 z = zOrig = blob_materialize(p);
1668 n = nOrig = blob_size(p);
1669 remove_pgp_signature(&z, &n);
1670 if( z==zOrig ){
1671 blob_append(p, zExtraLine, -1);
1672 }else{
1673 int iEnd;
1674 Blob copy;
1675 memcpy(&copy, p, sizeof(copy));
1676 blob_init(p, 0, 0);
1677 iEnd = (int)(&z[n] - zOrig);
1678 blob_append(p, zOrig, iEnd);
1679 blob_append(p, zExtraLine, -1);
1680 blob_append(p, &zOrig[iEnd], -1);
1681 blob_zero(&copy);
1682 }
1683 }
1684
1685 /*
1686 ** This is the comparison function used to sort the tag array.
1687 */
1688 static int tag_compare(const void *a, const void *b){
1689
+2 -1
--- src/tar.c
+++ src/tar.c
@@ -492,12 +492,13 @@
492492
mTime = (pManifest->rDate - 2440587.5)*86400.0;
493493
tar_begin(mTime);
494494
if( db_get_boolean("manifest", 0) ){
495495
blob_append(&filename, "manifest", -1);
496496
zName = blob_str(&filename);
497
- tar_add_file(zName, &mfile, 0, mTime);
498497
sha1sum_blob(&mfile, &hash);
498
+ sterilize_manifest(&mfile);
499
+ tar_add_file(zName, &mfile, 0, mTime);
499500
blob_reset(&mfile);
500501
blob_append(&hash, "\n", 1);
501502
blob_resize(&filename, nPrefix);
502503
blob_append(&filename, "manifest.uuid", -1);
503504
zName = blob_str(&filename);
504505
--- src/tar.c
+++ src/tar.c
@@ -492,12 +492,13 @@
492 mTime = (pManifest->rDate - 2440587.5)*86400.0;
493 tar_begin(mTime);
494 if( db_get_boolean("manifest", 0) ){
495 blob_append(&filename, "manifest", -1);
496 zName = blob_str(&filename);
497 tar_add_file(zName, &mfile, 0, mTime);
498 sha1sum_blob(&mfile, &hash);
 
 
499 blob_reset(&mfile);
500 blob_append(&hash, "\n", 1);
501 blob_resize(&filename, nPrefix);
502 blob_append(&filename, "manifest.uuid", -1);
503 zName = blob_str(&filename);
504
--- src/tar.c
+++ src/tar.c
@@ -492,12 +492,13 @@
492 mTime = (pManifest->rDate - 2440587.5)*86400.0;
493 tar_begin(mTime);
494 if( db_get_boolean("manifest", 0) ){
495 blob_append(&filename, "manifest", -1);
496 zName = blob_str(&filename);
 
497 sha1sum_blob(&mfile, &hash);
498 sterilize_manifest(&mfile);
499 tar_add_file(zName, &mfile, 0, mTime);
500 blob_reset(&mfile);
501 blob_append(&hash, "\n", 1);
502 blob_resize(&filename, nPrefix);
503 blob_append(&filename, "manifest.uuid", -1);
504 zName = blob_str(&filename);
505
+2 -1
--- src/zip.c
+++ src/zip.c
@@ -350,12 +350,13 @@
350350
zip_set_timedate(pManifest->rDate);
351351
if( db_get_boolean("manifest", 0) ){
352352
blob_append(&filename, "manifest", -1);
353353
zName = blob_str(&filename);
354354
zip_add_folders(zName);
355
- zip_add_file(zName, &mfile, 0);
356355
sha1sum_blob(&mfile, &hash);
356
+ sterilize_manifest(&mfile);
357
+ zip_add_file(zName, &mfile, 0);
357358
blob_reset(&mfile);
358359
blob_append(&hash, "\n", 1);
359360
blob_resize(&filename, nPrefix);
360361
blob_append(&filename, "manifest.uuid", -1);
361362
zName = blob_str(&filename);
362363
--- src/zip.c
+++ src/zip.c
@@ -350,12 +350,13 @@
350 zip_set_timedate(pManifest->rDate);
351 if( db_get_boolean("manifest", 0) ){
352 blob_append(&filename, "manifest", -1);
353 zName = blob_str(&filename);
354 zip_add_folders(zName);
355 zip_add_file(zName, &mfile, 0);
356 sha1sum_blob(&mfile, &hash);
 
 
357 blob_reset(&mfile);
358 blob_append(&hash, "\n", 1);
359 blob_resize(&filename, nPrefix);
360 blob_append(&filename, "manifest.uuid", -1);
361 zName = blob_str(&filename);
362
--- src/zip.c
+++ src/zip.c
@@ -350,12 +350,13 @@
350 zip_set_timedate(pManifest->rDate);
351 if( db_get_boolean("manifest", 0) ){
352 blob_append(&filename, "manifest", -1);
353 zName = blob_str(&filename);
354 zip_add_folders(zName);
 
355 sha1sum_blob(&mfile, &hash);
356 sterilize_manifest(&mfile);
357 zip_add_file(zName, &mfile, 0);
358 blob_reset(&mfile);
359 blob_append(&hash, "\n", 1);
360 blob_resize(&filename, nPrefix);
361 blob_append(&filename, "manifest.uuid", -1);
362 zName = blob_str(&filename);
363

Keyboard Shortcuts

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