Fossil SCM

Cache the name of the main branch.

danield 2025-10-28 15:05 trunk
Commit ca0d66b2e4e74eab6bee5d1229b4461077f44aa3e9c4749fcb21be28d59a0f5c
+15 -5
--- src/branch.c
+++ src/branch.c
@@ -18,10 +18,22 @@
1818
** This file contains code used to create new branches within a repository.
1919
*/
2020
#include "config.h"
2121
#include "branch.h"
2222
#include <assert.h>
23
+
24
+/*
25
+** Return the name of the main branch. Cache the result.
26
+**
27
+** This is the current value of the "main-branch" setting, or its default
28
+** value (historically, and as of 2025-10-28: "trunk") if not set.
29
+*/
30
+const char *db_main_branch(void){
31
+ static char *zMainBranch = 0;
32
+ if( zMainBranch==0 ) zMainBranch = db_get("main-branch", 0);
33
+ return zMainBranch;
34
+}
2335
2436
/*
2537
** Return true if zBr is the branch name associated with check-in with
2638
** blob.uuid value of zUuid
2739
*/
@@ -53,13 +65,11 @@
5365
if( db_step(&q)==SQLITE_ROW ){
5466
zBr = fossil_strdup(db_column_text(&q,0));
5567
}
5668
db_reset(&q);
5769
if( zBr==0 ){
58
- static char *zMain = 0;
59
- if( zMain==0 ) zMain = db_get("main-branch",0);
60
- zBr = fossil_strdup(zMain);
70
+ zBr = fossil_strdup(db_main_branch());
6171
}
6272
return zBr;
6373
}
6474
6575
/*
@@ -837,20 +847,20 @@
837847
*/
838848
static void new_brlist_page(void){
839849
Stmt q;
840850
double rNow;
841851
int show_colors = PB("colors");
842
- char *zMainBranch;
852
+ const char *zMainBranch;
843853
login_check_credentials();
844854
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
845855
style_set_current_feature("branch");
846856
style_header("Branches");
847857
style_adunit_config(ADUNIT_RIGHT_OK);
848858
style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
849859
850860
login_anonymous_available();
851
- zMainBranch = db_get("main-branch", 0);
861
+ zMainBranch = db_main_branch();
852862
853863
brlist_create_temp_table();
854864
db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
855865
rNow = db_double(0.0, "SELECT julianday('now')");
856866
@ <script id="brlist-data" type="application/json">\
857867
--- src/branch.c
+++ src/branch.c
@@ -18,10 +18,22 @@
18 ** This file contains code used to create new branches within a repository.
19 */
20 #include "config.h"
21 #include "branch.h"
22 #include <assert.h>
 
 
 
 
 
 
 
 
 
 
 
 
23
24 /*
25 ** Return true if zBr is the branch name associated with check-in with
26 ** blob.uuid value of zUuid
27 */
@@ -53,13 +65,11 @@
53 if( db_step(&q)==SQLITE_ROW ){
54 zBr = fossil_strdup(db_column_text(&q,0));
55 }
56 db_reset(&q);
57 if( zBr==0 ){
58 static char *zMain = 0;
59 if( zMain==0 ) zMain = db_get("main-branch",0);
60 zBr = fossil_strdup(zMain);
61 }
62 return zBr;
63 }
64
65 /*
@@ -837,20 +847,20 @@
837 */
838 static void new_brlist_page(void){
839 Stmt q;
840 double rNow;
841 int show_colors = PB("colors");
842 char *zMainBranch;
843 login_check_credentials();
844 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
845 style_set_current_feature("branch");
846 style_header("Branches");
847 style_adunit_config(ADUNIT_RIGHT_OK);
848 style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
849
850 login_anonymous_available();
851 zMainBranch = db_get("main-branch", 0);
852
853 brlist_create_temp_table();
854 db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
855 rNow = db_double(0.0, "SELECT julianday('now')");
856 @ <script id="brlist-data" type="application/json">\
857
--- src/branch.c
+++ src/branch.c
@@ -18,10 +18,22 @@
18 ** This file contains code used to create new branches within a repository.
19 */
20 #include "config.h"
21 #include "branch.h"
22 #include <assert.h>
23
24 /*
25 ** Return the name of the main branch. Cache the result.
26 **
27 ** This is the current value of the "main-branch" setting, or its default
28 ** value (historically, and as of 2025-10-28: "trunk") if not set.
29 */
30 const char *db_main_branch(void){
31 static char *zMainBranch = 0;
32 if( zMainBranch==0 ) zMainBranch = db_get("main-branch", 0);
33 return zMainBranch;
34 }
35
36 /*
37 ** Return true if zBr is the branch name associated with check-in with
38 ** blob.uuid value of zUuid
39 */
@@ -53,13 +65,11 @@
65 if( db_step(&q)==SQLITE_ROW ){
66 zBr = fossil_strdup(db_column_text(&q,0));
67 }
68 db_reset(&q);
69 if( zBr==0 ){
70 zBr = fossil_strdup(db_main_branch());
 
 
71 }
72 return zBr;
73 }
74
75 /*
@@ -837,20 +847,20 @@
847 */
848 static void new_brlist_page(void){
849 Stmt q;
850 double rNow;
851 int show_colors = PB("colors");
852 const char *zMainBranch;
853 login_check_credentials();
854 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
855 style_set_current_feature("branch");
856 style_header("Branches");
857 style_adunit_config(ADUNIT_RIGHT_OK);
858 style_submenu_checkbox("colors", "Use Branch Colors", 0, 0);
859
860 login_anonymous_available();
861 zMainBranch = db_main_branch();
862
863 brlist_create_temp_table();
864 db_prepare(&q, "SELECT * FROM tmp_brlist ORDER BY mtime DESC");
865 rNow = db_double(0.0, "SELECT julianday('now')");
866 @ <script id="brlist-data" type="application/json">\
867
+2 -2
--- src/browse.c
+++ src/browse.c
@@ -127,11 +127,11 @@
127127
**
128128
** * Links to files go to /doc (showing the file content directly,
129129
** depending on mimetype) rather than to /file (which always shows
130130
** the file embedded in a standard Fossil page frame).
131131
**
132
-** * The submenu and the page title is now show. The page is plain.
132
+** * The submenu and the page title is not shown. The page is plain.
133133
**
134134
** The /docdir page is a shorthand for /dir with the "dx" query parameter.
135135
**
136136
** Query parameters:
137137
**
@@ -192,11 +192,11 @@
192192
193193
/* If a specific check-in is requested, fetch and parse it. If the
194194
** specific check-in does not exist, clear zCI. zCI==0 will cause all
195195
** files from all check-ins to be displayed.
196196
*/
197
- if( bDocDir && zCI==0 ) zCI = db_get("main-branch", 0);
197
+ if( bDocDir && zCI==0 ) zCI = db_main_branch();
198198
if( zCI ){
199199
pM = manifest_get_by_name(zCI, &rid);
200200
if( pM ){
201201
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
202202
isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
203203
--- src/browse.c
+++ src/browse.c
@@ -127,11 +127,11 @@
127 **
128 ** * Links to files go to /doc (showing the file content directly,
129 ** depending on mimetype) rather than to /file (which always shows
130 ** the file embedded in a standard Fossil page frame).
131 **
132 ** * The submenu and the page title is now show. The page is plain.
133 **
134 ** The /docdir page is a shorthand for /dir with the "dx" query parameter.
135 **
136 ** Query parameters:
137 **
@@ -192,11 +192,11 @@
192
193 /* If a specific check-in is requested, fetch and parse it. If the
194 ** specific check-in does not exist, clear zCI. zCI==0 will cause all
195 ** files from all check-ins to be displayed.
196 */
197 if( bDocDir && zCI==0 ) zCI = db_get("main-branch", 0);
198 if( zCI ){
199 pM = manifest_get_by_name(zCI, &rid);
200 if( pM ){
201 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
202 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
203
--- src/browse.c
+++ src/browse.c
@@ -127,11 +127,11 @@
127 **
128 ** * Links to files go to /doc (showing the file content directly,
129 ** depending on mimetype) rather than to /file (which always shows
130 ** the file embedded in a standard Fossil page frame).
131 **
132 ** * The submenu and the page title is not shown. The page is plain.
133 **
134 ** The /docdir page is a shorthand for /dir with the "dx" query parameter.
135 **
136 ** Query parameters:
137 **
@@ -192,11 +192,11 @@
192
193 /* If a specific check-in is requested, fetch and parse it. If the
194 ** specific check-in does not exist, clear zCI. zCI==0 will cause all
195 ** files from all check-ins to be displayed.
196 */
197 if( bDocDir && zCI==0 ) zCI = db_main_branch();
198 if( zCI ){
199 pM = manifest_get_by_name(zCI, &rid);
200 if( pM ){
201 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
202 isSymbolicCI = (sqlite3_strnicmp(zUuid, zCI, strlen(zCI))!=0);
203
+2 -2
--- src/checkin.c
+++ src/checkin.c
@@ -1627,11 +1627,11 @@
16271627
int dryRunFlag /* True for a dry-run only */
16281628
){
16291629
Blob *pDesc;
16301630
char *zTags;
16311631
char *zFilename;
1632
- char *zMainBranch = db_get("main-branch", 0);
1632
+ const char *zMainBranch = db_main_branch();
16331633
Blob desc;
16341634
blob_init(&desc, 0, 0);
16351635
pDesc = &desc;
16361636
blob_appendf(pDesc, "checkout %s\n", g.zLocalRoot);
16371637
blob_appendf(pDesc, "repository %s\n", g.zRepositoryName);
@@ -2625,11 +2625,11 @@
26252625
/* Get the ID of the parent manifest artifact */
26262626
vid = db_lget_int("checkout", 0);
26272627
if( vid==0 ){
26282628
useCksum = 1;
26292629
if( privateFlag==0 && sCiInfo.zBranch==0 ) {
2630
- sCiInfo.zBranch=db_get("main-branch", 0);
2630
+ sCiInfo.zBranch = db_main_branch();
26312631
}
26322632
}else{
26332633
privateParent = content_is_private(vid);
26342634
}
26352635
26362636
--- src/checkin.c
+++ src/checkin.c
@@ -1627,11 +1627,11 @@
1627 int dryRunFlag /* True for a dry-run only */
1628 ){
1629 Blob *pDesc;
1630 char *zTags;
1631 char *zFilename;
1632 char *zMainBranch = db_get("main-branch", 0);
1633 Blob desc;
1634 blob_init(&desc, 0, 0);
1635 pDesc = &desc;
1636 blob_appendf(pDesc, "checkout %s\n", g.zLocalRoot);
1637 blob_appendf(pDesc, "repository %s\n", g.zRepositoryName);
@@ -2625,11 +2625,11 @@
2625 /* Get the ID of the parent manifest artifact */
2626 vid = db_lget_int("checkout", 0);
2627 if( vid==0 ){
2628 useCksum = 1;
2629 if( privateFlag==0 && sCiInfo.zBranch==0 ) {
2630 sCiInfo.zBranch=db_get("main-branch", 0);
2631 }
2632 }else{
2633 privateParent = content_is_private(vid);
2634 }
2635
2636
--- src/checkin.c
+++ src/checkin.c
@@ -1627,11 +1627,11 @@
1627 int dryRunFlag /* True for a dry-run only */
1628 ){
1629 Blob *pDesc;
1630 char *zTags;
1631 char *zFilename;
1632 const char *zMainBranch = db_main_branch();
1633 Blob desc;
1634 blob_init(&desc, 0, 0);
1635 pDesc = &desc;
1636 blob_appendf(pDesc, "checkout %s\n", g.zLocalRoot);
1637 blob_appendf(pDesc, "repository %s\n", g.zRepositoryName);
@@ -2625,11 +2625,11 @@
2625 /* Get the ID of the parent manifest artifact */
2626 vid = db_lget_int("checkout", 0);
2627 if( vid==0 ){
2628 useCksum = 1;
2629 if( privateFlag==0 && sCiInfo.zBranch==0 ) {
2630 sCiInfo.zBranch = db_main_branch();
2631 }
2632 }else{
2633 privateParent = content_is_private(vid);
2634 }
2635
2636
+1 -1
--- src/checkout.c
+++ src/checkout.c
@@ -496,11 +496,11 @@
496496
verify_all_options();
497497
if( g.argc<3 || g.argc>4 ){
498498
usage("URL ?VERSION? ?OPTIONS?");
499499
}
500500
zUrl = g.argv[2];
501
- zVers = g.argc==4 ? g.argv[3] : db_get("main-branch", 0);
501
+ zVers = g.argc==4 ? g.argv[3] : db_main_branch();
502502
503503
/* Parse the URL of the repository */
504504
url_parse(zUrl, 0);
505505
506506
/* Construct an appropriate name for the destination directory */
507507
--- src/checkout.c
+++ src/checkout.c
@@ -496,11 +496,11 @@
496 verify_all_options();
497 if( g.argc<3 || g.argc>4 ){
498 usage("URL ?VERSION? ?OPTIONS?");
499 }
500 zUrl = g.argv[2];
501 zVers = g.argc==4 ? g.argv[3] : db_get("main-branch", 0);
502
503 /* Parse the URL of the repository */
504 url_parse(zUrl, 0);
505
506 /* Construct an appropriate name for the destination directory */
507
--- src/checkout.c
+++ src/checkout.c
@@ -496,11 +496,11 @@
496 verify_all_options();
497 if( g.argc<3 || g.argc>4 ){
498 usage("URL ?VERSION? ?OPTIONS?");
499 }
500 zUrl = g.argv[2];
501 zVers = g.argc==4 ? g.argv[3] : db_main_branch();
502
503 /* Parse the URL of the repository */
504 url_parse(zUrl, 0);
505
506 /* Construct an appropriate name for the destination directory */
507
+1 -1
--- src/db.c
+++ src/db.c
@@ -4403,11 +4403,11 @@
44034403
/* Figure out which revision to open. */
44044404
if( !emptyFlag ){
44054405
if( g.argc==4 ){
44064406
g.zOpenRevision = g.argv[3];
44074407
}else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
4408
- g.zOpenRevision = db_get("main-branch", 0);
4408
+ g.zOpenRevision = fossil_strdup(db_main_branch());
44094409
}
44104410
if( autosync_loop(SYNC_PULL, !bForce, "open") && !bForce ){
44114411
fossil_fatal("unable to auto-sync the repository");
44124412
}
44134413
}
44144414
--- src/db.c
+++ src/db.c
@@ -4403,11 +4403,11 @@
4403 /* Figure out which revision to open. */
4404 if( !emptyFlag ){
4405 if( g.argc==4 ){
4406 g.zOpenRevision = g.argv[3];
4407 }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
4408 g.zOpenRevision = db_get("main-branch", 0);
4409 }
4410 if( autosync_loop(SYNC_PULL, !bForce, "open") && !bForce ){
4411 fossil_fatal("unable to auto-sync the repository");
4412 }
4413 }
4414
--- src/db.c
+++ src/db.c
@@ -4403,11 +4403,11 @@
4403 /* Figure out which revision to open. */
4404 if( !emptyFlag ){
4405 if( g.argc==4 ){
4406 g.zOpenRevision = g.argv[3];
4407 }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
4408 g.zOpenRevision = fossil_strdup(db_main_branch());
4409 }
4410 if( autosync_loop(SYNC_PULL, !bForce, "open") && !bForce ){
4411 fossil_fatal("unable to auto-sync the repository");
4412 }
4413 }
4414
--- src/descendants.c
+++ src/descendants.c
@@ -437,11 +437,11 @@
437437
int multipleFlag = find_option("multiple","m",0)!=0;
438438
const char *zWidth = find_option("width","W",1);
439439
char *zLastBr = 0;
440440
int n, width;
441441
char zLineNo[10];
442
- char *zMainBranch = db_get("main-branch", 0);
442
+ const char *zMainBranch = db_main_branch();
443443
444444
if( multipleFlag ) byBranch = 1;
445445
if( zWidth ){
446446
width = atoi(zWidth);
447447
if( (width!=0) && (width<=39) ){
@@ -535,11 +535,10 @@
535535
zBranchPoint ? zBranchPoint : "");
536536
comment_print(z, zCom, 7, width, get_comment_format());
537537
fossil_free(z);
538538
fossil_free(zBranchPoint);
539539
}
540
- fossil_free(zMainBranch);
541540
fossil_free(zLastBr);
542541
db_finalize(&q);
543542
}
544543
545544
/*
546545
--- src/descendants.c
+++ src/descendants.c
@@ -437,11 +437,11 @@
437 int multipleFlag = find_option("multiple","m",0)!=0;
438 const char *zWidth = find_option("width","W",1);
439 char *zLastBr = 0;
440 int n, width;
441 char zLineNo[10];
442 char *zMainBranch = db_get("main-branch", 0);
443
444 if( multipleFlag ) byBranch = 1;
445 if( zWidth ){
446 width = atoi(zWidth);
447 if( (width!=0) && (width<=39) ){
@@ -535,11 +535,10 @@
535 zBranchPoint ? zBranchPoint : "");
536 comment_print(z, zCom, 7, width, get_comment_format());
537 fossil_free(z);
538 fossil_free(zBranchPoint);
539 }
540 fossil_free(zMainBranch);
541 fossil_free(zLastBr);
542 db_finalize(&q);
543 }
544
545 /*
546
--- src/descendants.c
+++ src/descendants.c
@@ -437,11 +437,11 @@
437 int multipleFlag = find_option("multiple","m",0)!=0;
438 const char *zWidth = find_option("width","W",1);
439 char *zLastBr = 0;
440 int n, width;
441 char zLineNo[10];
442 const char *zMainBranch = db_main_branch();
443
444 if( multipleFlag ) byBranch = 1;
445 if( zWidth ){
446 width = atoi(zWidth);
447 if( (width!=0) && (width<=39) ){
@@ -535,11 +535,10 @@
535 zBranchPoint ? zBranchPoint : "");
536 comment_print(z, zCom, 7, width, get_comment_format());
537 fossil_free(z);
538 fossil_free(zBranchPoint);
539 }
 
540 fossil_free(zLastBr);
541 db_finalize(&q);
542 }
543
544 /*
545
+3 -3
--- src/export.c
+++ src/export.c
@@ -491,11 +491,11 @@
491491
Stmt q, q2, q3;
492492
Bag blobs, vers;
493493
unsigned int unused_mark = 1;
494494
const char *markfile_in;
495495
const char *markfile_out;
496
- char *zMainBranch = db_get("main-branch", 0);
496
+ const char *zMainBranch = db_main_branch();
497497
498498
bag_init(&blobs);
499499
bag_init(&vers);
500500
501501
find_option("git", 0, 0); /* Ignore the --git option for now */
@@ -1091,11 +1091,11 @@
10911091
int bPhantomOk; /* True if phantom files should be ignored */
10921092
char buf[24];
10931093
char *zEmail; /* Contact info for Git committer field */
10941094
int fManifest; /* Should the manifest files be included? */
10951095
int fPManifest = 0; /* OR of the manifest files for all parents */
1096
- char *zMainBranch;
1096
+ const char *zMainBranch;
10971097
10981098
pMan = manifest_get(rid, CFTYPE_MANIFEST, 0);
10991099
if( pMan==0 ){
11001100
/* Must be a phantom. Return without doing anything, and in particular
11011101
** without creating a mark for this check-in. */
@@ -1151,11 +1151,11 @@
11511151
/* Figure out which branch this check-in is a member of */
11521152
zBranch = db_text(0,
11531153
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d",
11541154
TAG_BRANCH, rid
11551155
);
1156
- zMainBranch = db_get("main-branch", 0);
1156
+ zMainBranch = db_main_branch();
11571157
if( fossil_strcmp(zBranch, zMainBranch)==0 ){
11581158
assert( gitmirror_mainbranch!=0 );
11591159
fossil_free(zBranch);
11601160
zBranch = fossil_strdup(gitmirror_mainbranch);
11611161
}else if( zBranch==0 ){
11621162
--- src/export.c
+++ src/export.c
@@ -491,11 +491,11 @@
491 Stmt q, q2, q3;
492 Bag blobs, vers;
493 unsigned int unused_mark = 1;
494 const char *markfile_in;
495 const char *markfile_out;
496 char *zMainBranch = db_get("main-branch", 0);
497
498 bag_init(&blobs);
499 bag_init(&vers);
500
501 find_option("git", 0, 0); /* Ignore the --git option for now */
@@ -1091,11 +1091,11 @@
1091 int bPhantomOk; /* True if phantom files should be ignored */
1092 char buf[24];
1093 char *zEmail; /* Contact info for Git committer field */
1094 int fManifest; /* Should the manifest files be included? */
1095 int fPManifest = 0; /* OR of the manifest files for all parents */
1096 char *zMainBranch;
1097
1098 pMan = manifest_get(rid, CFTYPE_MANIFEST, 0);
1099 if( pMan==0 ){
1100 /* Must be a phantom. Return without doing anything, and in particular
1101 ** without creating a mark for this check-in. */
@@ -1151,11 +1151,11 @@
1151 /* Figure out which branch this check-in is a member of */
1152 zBranch = db_text(0,
1153 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d",
1154 TAG_BRANCH, rid
1155 );
1156 zMainBranch = db_get("main-branch", 0);
1157 if( fossil_strcmp(zBranch, zMainBranch)==0 ){
1158 assert( gitmirror_mainbranch!=0 );
1159 fossil_free(zBranch);
1160 zBranch = fossil_strdup(gitmirror_mainbranch);
1161 }else if( zBranch==0 ){
1162
--- src/export.c
+++ src/export.c
@@ -491,11 +491,11 @@
491 Stmt q, q2, q3;
492 Bag blobs, vers;
493 unsigned int unused_mark = 1;
494 const char *markfile_in;
495 const char *markfile_out;
496 const char *zMainBranch = db_main_branch();
497
498 bag_init(&blobs);
499 bag_init(&vers);
500
501 find_option("git", 0, 0); /* Ignore the --git option for now */
@@ -1091,11 +1091,11 @@
1091 int bPhantomOk; /* True if phantom files should be ignored */
1092 char buf[24];
1093 char *zEmail; /* Contact info for Git committer field */
1094 int fManifest; /* Should the manifest files be included? */
1095 int fPManifest = 0; /* OR of the manifest files for all parents */
1096 const char *zMainBranch;
1097
1098 pMan = manifest_get(rid, CFTYPE_MANIFEST, 0);
1099 if( pMan==0 ){
1100 /* Must be a phantom. Return without doing anything, and in particular
1101 ** without creating a mark for this check-in. */
@@ -1151,11 +1151,11 @@
1151 /* Figure out which branch this check-in is a member of */
1152 zBranch = db_text(0,
1153 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d",
1154 TAG_BRANCH, rid
1155 );
1156 zMainBranch = db_main_branch();
1157 if( fossil_strcmp(zBranch, zMainBranch)==0 ){
1158 assert( gitmirror_mainbranch!=0 );
1159 fossil_free(zBranch);
1160 zBranch = fossil_strdup(gitmirror_mainbranch);
1161 }else if( zBranch==0 ){
1162
+1 -1
--- src/fileedit.c
+++ src/fileedit.c
@@ -833,11 +833,11 @@
833833
}
834834
if(zRevision==0 || zRevision[0]==0){
835835
if(g.localOpen/*check-out*/){
836836
zRevision = db_lget("checkout-hash", 0)/*leak*/;
837837
}else{
838
- zRevision = db_get("main-branch", 0);
838
+ zRevision = db_main_branch();
839839
}
840840
}
841841
name_to_uuid2(zRevision, "ci", &cimi.zParentUuid);
842842
if(cimi.zParentUuid==0){
843843
fossil_fatal("Cannot determine version to commit to.");
844844
--- src/fileedit.c
+++ src/fileedit.c
@@ -833,11 +833,11 @@
833 }
834 if(zRevision==0 || zRevision[0]==0){
835 if(g.localOpen/*check-out*/){
836 zRevision = db_lget("checkout-hash", 0)/*leak*/;
837 }else{
838 zRevision = db_get("main-branch", 0);
839 }
840 }
841 name_to_uuid2(zRevision, "ci", &cimi.zParentUuid);
842 if(cimi.zParentUuid==0){
843 fossil_fatal("Cannot determine version to commit to.");
844
--- src/fileedit.c
+++ src/fileedit.c
@@ -833,11 +833,11 @@
833 }
834 if(zRevision==0 || zRevision[0]==0){
835 if(g.localOpen/*check-out*/){
836 zRevision = db_lget("checkout-hash", 0)/*leak*/;
837 }else{
838 zRevision = db_main_branch();
839 }
840 }
841 name_to_uuid2(zRevision, "ci", &cimi.zParentUuid);
842 if(cimi.zParentUuid==0){
843 fossil_fatal("Cannot determine version to commit to.");
844
+4 -2
--- src/finfo.c
+++ src/finfo.c
@@ -176,11 +176,11 @@
176176
const char *zFilename;
177177
const char *zLimit;
178178
const char *zWidth;
179179
const char *zOffset;
180180
int iLimit, iOffset, iBrief, iWidth;
181
- char *zMainBranch = db_get("main-branch", 0);
181
+ const char *zMainBranch;
182182
183183
if( find_option("log","l",0) ){
184184
/* this is the default, no-op */
185185
}
186186
zLimit = find_option("limit","n",1);
@@ -232,10 +232,11 @@
232232
);
233233
blob_zero(&line);
234234
if( iBrief == 0 ){
235235
fossil_print("History for %s\n", blob_str(&fname));
236236
}
237
+ zMainBranch = db_main_branch();
237238
while( db_step(&q)==SQLITE_ROW ){
238239
const char *zFileUuid = db_column_text(&q, 0);
239240
const char *zCiUuid = db_column_text(&q,1);
240241
const char *zDate = db_column_text(&q, 2);
241242
const char *zCom = db_column_text(&q, 3);
@@ -377,11 +378,11 @@
377378
int tmFlags = 0; /* Viewing mode */
378379
const char *zStyle; /* Viewing mode name */
379380
const char *zMark; /* Mark this version of the file */
380381
int selRid = 0; /* RID of the marked file version */
381382
int mxfnid; /* Maximum filename.fnid value */
382
- char *zMainBranch = db_get("main-branch", 0);
383
+ const char *zMainBranch;
383384
384385
login_check_credentials();
385386
if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
386387
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
387388
ridCi = zCI ? name_to_rid_www("ci") : 0;
@@ -635,10 +636,11 @@
635636
while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){
636637
aParent[nParent] = db_column_int64(&qparent, 0);
637638
nParent++;
638639
}
639640
db_reset(&qparent);
641
+ zMainBranch = db_main_branch();
640642
if( zBr==0 ) zBr = fossil_strdup(zMainBranch);
641643
if( uBg ){
642644
zBgClr = user_color(zUser);
643645
}else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
644646
zBgClr = strcmp(zBr, zMainBranch)==0 ? "" : hash_color(zBr);
645647
--- src/finfo.c
+++ src/finfo.c
@@ -176,11 +176,11 @@
176 const char *zFilename;
177 const char *zLimit;
178 const char *zWidth;
179 const char *zOffset;
180 int iLimit, iOffset, iBrief, iWidth;
181 char *zMainBranch = db_get("main-branch", 0);
182
183 if( find_option("log","l",0) ){
184 /* this is the default, no-op */
185 }
186 zLimit = find_option("limit","n",1);
@@ -232,10 +232,11 @@
232 );
233 blob_zero(&line);
234 if( iBrief == 0 ){
235 fossil_print("History for %s\n", blob_str(&fname));
236 }
 
237 while( db_step(&q)==SQLITE_ROW ){
238 const char *zFileUuid = db_column_text(&q, 0);
239 const char *zCiUuid = db_column_text(&q,1);
240 const char *zDate = db_column_text(&q, 2);
241 const char *zCom = db_column_text(&q, 3);
@@ -377,11 +378,11 @@
377 int tmFlags = 0; /* Viewing mode */
378 const char *zStyle; /* Viewing mode name */
379 const char *zMark; /* Mark this version of the file */
380 int selRid = 0; /* RID of the marked file version */
381 int mxfnid; /* Maximum filename.fnid value */
382 char *zMainBranch = db_get("main-branch", 0);
383
384 login_check_credentials();
385 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
386 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
387 ridCi = zCI ? name_to_rid_www("ci") : 0;
@@ -635,10 +636,11 @@
635 while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){
636 aParent[nParent] = db_column_int64(&qparent, 0);
637 nParent++;
638 }
639 db_reset(&qparent);
 
640 if( zBr==0 ) zBr = fossil_strdup(zMainBranch);
641 if( uBg ){
642 zBgClr = user_color(zUser);
643 }else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
644 zBgClr = strcmp(zBr, zMainBranch)==0 ? "" : hash_color(zBr);
645
--- src/finfo.c
+++ src/finfo.c
@@ -176,11 +176,11 @@
176 const char *zFilename;
177 const char *zLimit;
178 const char *zWidth;
179 const char *zOffset;
180 int iLimit, iOffset, iBrief, iWidth;
181 const char *zMainBranch;
182
183 if( find_option("log","l",0) ){
184 /* this is the default, no-op */
185 }
186 zLimit = find_option("limit","n",1);
@@ -232,10 +232,11 @@
232 );
233 blob_zero(&line);
234 if( iBrief == 0 ){
235 fossil_print("History for %s\n", blob_str(&fname));
236 }
237 zMainBranch = db_main_branch();
238 while( db_step(&q)==SQLITE_ROW ){
239 const char *zFileUuid = db_column_text(&q, 0);
240 const char *zCiUuid = db_column_text(&q,1);
241 const char *zDate = db_column_text(&q, 2);
242 const char *zCom = db_column_text(&q, 3);
@@ -377,11 +378,11 @@
378 int tmFlags = 0; /* Viewing mode */
379 const char *zStyle; /* Viewing mode name */
380 const char *zMark; /* Mark this version of the file */
381 int selRid = 0; /* RID of the marked file version */
382 int mxfnid; /* Maximum filename.fnid value */
383 const char *zMainBranch;
384
385 login_check_credentials();
386 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
387 fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
388 ridCi = zCI ? name_to_rid_www("ci") : 0;
@@ -635,10 +636,11 @@
636 while( db_step(&qparent)==SQLITE_ROW && nParent<count(aParent) ){
637 aParent[nParent] = db_column_int64(&qparent, 0);
638 nParent++;
639 }
640 db_reset(&qparent);
641 zMainBranch = db_main_branch();
642 if( zBr==0 ) zBr = fossil_strdup(zMainBranch);
643 if( uBg ){
644 zBgClr = user_color(zUser);
645 }else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
646 zBgClr = strcmp(zBr, zMainBranch)==0 ? "" : hash_color(zBr);
647
+2 -2
--- src/graph.c
+++ src/graph.c
@@ -513,11 +513,11 @@
513513
GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
514514
int i, j;
515515
u64 mask;
516516
int hasDup = 0; /* True if one or more isDup entries */
517517
const char *zTrunk;
518
- char *zMainBranch;
518
+ const char *zMainBranch;
519519
u8 *aMap; /* Copy of p->aiRailMap */
520520
int omitDescenders = (tmFlags & TIMELINE_DISJOINT)!=0;
521521
int nTimewarp = 0;
522522
int riserMargin = (tmFlags & TIMELINE_DISJOINT) ? 0 : RISER_MARGIN;
523523
@@ -709,11 +709,11 @@
709709
/* Identify rows where the primary parent is off screen. Assign
710710
** each to a rail and draw descenders downward.
711711
**
712712
** Strive to put the main branch (usually "trunk") on far left.
713713
*/
714
- zMainBranch = db_get("main-branch", 0);
714
+ zMainBranch = db_main_branch();
715715
zTrunk = persistBranchName(p, zMainBranch);
716716
for(i=0; i<2; i++){
717717
for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
718718
if( i==0 && pRow->zBranch!=zTrunk ) continue;
719719
if( pRow->iRail>=0 ) continue;
720720
--- src/graph.c
+++ src/graph.c
@@ -513,11 +513,11 @@
513 GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
514 int i, j;
515 u64 mask;
516 int hasDup = 0; /* True if one or more isDup entries */
517 const char *zTrunk;
518 char *zMainBranch;
519 u8 *aMap; /* Copy of p->aiRailMap */
520 int omitDescenders = (tmFlags & TIMELINE_DISJOINT)!=0;
521 int nTimewarp = 0;
522 int riserMargin = (tmFlags & TIMELINE_DISJOINT) ? 0 : RISER_MARGIN;
523
@@ -709,11 +709,11 @@
709 /* Identify rows where the primary parent is off screen. Assign
710 ** each to a rail and draw descenders downward.
711 **
712 ** Strive to put the main branch (usually "trunk") on far left.
713 */
714 zMainBranch = db_get("main-branch", 0);
715 zTrunk = persistBranchName(p, zMainBranch);
716 for(i=0; i<2; i++){
717 for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
718 if( i==0 && pRow->zBranch!=zTrunk ) continue;
719 if( pRow->iRail>=0 ) continue;
720
--- src/graph.c
+++ src/graph.c
@@ -513,11 +513,11 @@
513 GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
514 int i, j;
515 u64 mask;
516 int hasDup = 0; /* True if one or more isDup entries */
517 const char *zTrunk;
518 const char *zMainBranch;
519 u8 *aMap; /* Copy of p->aiRailMap */
520 int omitDescenders = (tmFlags & TIMELINE_DISJOINT)!=0;
521 int nTimewarp = 0;
522 int riserMargin = (tmFlags & TIMELINE_DISJOINT) ? 0 : RISER_MARGIN;
523
@@ -709,11 +709,11 @@
709 /* Identify rows where the primary parent is off screen. Assign
710 ** each to a rail and draw descenders downward.
711 **
712 ** Strive to put the main branch (usually "trunk") on far left.
713 */
714 zMainBranch = db_main_branch();
715 zTrunk = persistBranchName(p, zMainBranch);
716 for(i=0; i<2; i++){
717 for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
718 if( i==0 && pRow->zBranch!=zTrunk ) continue;
719 if( pRow->iRail>=0 ) continue;
720
+3 -3
--- src/import.c
+++ src/import.c
@@ -1263,11 +1263,11 @@
12631263
** Return 0 if not a branch, tag, or trunk, or if ignored by --ignore-tree.
12641264
*/
12651265
static int svn_parse_path(char *zPath, char **zFile, int *type){
12661266
char *zBranch = 0;
12671267
int branchId = 0;
1268
- char *zMainBranch = db_get("main-branch", 0);
1268
+ const char *zMainBranch;
12691269
if( gsvn.azIgnTree ){
12701270
const char **pzIgnTree;
12711271
unsigned nPath = strlen(zPath);
12721272
for( pzIgnTree = gsvn.azIgnTree; *pzIgnTree; ++pzIgnTree ){
12731273
const char *zIgn = *pzIgnTree;
@@ -1278,10 +1278,11 @@
12781278
}
12791279
}
12801280
}
12811281
*type = SVN_UNKNOWN;
12821282
*zFile = 0;
1283
+ zMainBranch = db_main_branch();
12831284
if( gsvn.lenTrunk==0 ){
12841285
zBranch = fossil_strdup(zMainBranch);
12851286
*zFile = zPath;
12861287
*type = SVN_TRUNK;
12871288
}else
@@ -1728,11 +1729,10 @@
17281729
int svnFlag = find_option("svn", 0, 0)!=0;
17291730
int gitFlag = find_option("git", 0, 0)!=0;
17301731
int omitRebuild = find_option("no-rebuild",0,0)!=0;
17311732
int omitVacuum = find_option("no-vacuum",0,0)!=0;
17321733
const char *zDefaultUser = find_option("admin-user","A",1);
1733
- char *zMainBranch = db_get("main-branch", 0);
17341734
17351735
/* Options common to all input formats */
17361736
int incrFlag = find_option("incremental", "i", 0)!=0;
17371737
17381738
/* Options for --svn only */
@@ -1772,11 +1772,11 @@
17721772
*renOpt->varSuf = renOpt->zDefaultSuf;
17731773
}
17741774
}
17751775
}
17761776
if( !(gimport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
1777
- gimport.zTrunkName = fossil_strdup(zMainBranch);
1777
+ gimport.zTrunkName = fossil_strdup(db_main_branch());
17781778
}
17791779
17801780
if( svnFlag ){
17811781
/* Get --svn related options here, so verify_all_options() fails when
17821782
* svn-only options are specified with --git
17831783
--- src/import.c
+++ src/import.c
@@ -1263,11 +1263,11 @@
1263 ** Return 0 if not a branch, tag, or trunk, or if ignored by --ignore-tree.
1264 */
1265 static int svn_parse_path(char *zPath, char **zFile, int *type){
1266 char *zBranch = 0;
1267 int branchId = 0;
1268 char *zMainBranch = db_get("main-branch", 0);
1269 if( gsvn.azIgnTree ){
1270 const char **pzIgnTree;
1271 unsigned nPath = strlen(zPath);
1272 for( pzIgnTree = gsvn.azIgnTree; *pzIgnTree; ++pzIgnTree ){
1273 const char *zIgn = *pzIgnTree;
@@ -1278,10 +1278,11 @@
1278 }
1279 }
1280 }
1281 *type = SVN_UNKNOWN;
1282 *zFile = 0;
 
1283 if( gsvn.lenTrunk==0 ){
1284 zBranch = fossil_strdup(zMainBranch);
1285 *zFile = zPath;
1286 *type = SVN_TRUNK;
1287 }else
@@ -1728,11 +1729,10 @@
1728 int svnFlag = find_option("svn", 0, 0)!=0;
1729 int gitFlag = find_option("git", 0, 0)!=0;
1730 int omitRebuild = find_option("no-rebuild",0,0)!=0;
1731 int omitVacuum = find_option("no-vacuum",0,0)!=0;
1732 const char *zDefaultUser = find_option("admin-user","A",1);
1733 char *zMainBranch = db_get("main-branch", 0);
1734
1735 /* Options common to all input formats */
1736 int incrFlag = find_option("incremental", "i", 0)!=0;
1737
1738 /* Options for --svn only */
@@ -1772,11 +1772,11 @@
1772 *renOpt->varSuf = renOpt->zDefaultSuf;
1773 }
1774 }
1775 }
1776 if( !(gimport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
1777 gimport.zTrunkName = fossil_strdup(zMainBranch);
1778 }
1779
1780 if( svnFlag ){
1781 /* Get --svn related options here, so verify_all_options() fails when
1782 * svn-only options are specified with --git
1783
--- src/import.c
+++ src/import.c
@@ -1263,11 +1263,11 @@
1263 ** Return 0 if not a branch, tag, or trunk, or if ignored by --ignore-tree.
1264 */
1265 static int svn_parse_path(char *zPath, char **zFile, int *type){
1266 char *zBranch = 0;
1267 int branchId = 0;
1268 const char *zMainBranch;
1269 if( gsvn.azIgnTree ){
1270 const char **pzIgnTree;
1271 unsigned nPath = strlen(zPath);
1272 for( pzIgnTree = gsvn.azIgnTree; *pzIgnTree; ++pzIgnTree ){
1273 const char *zIgn = *pzIgnTree;
@@ -1278,10 +1278,11 @@
1278 }
1279 }
1280 }
1281 *type = SVN_UNKNOWN;
1282 *zFile = 0;
1283 zMainBranch = db_main_branch();
1284 if( gsvn.lenTrunk==0 ){
1285 zBranch = fossil_strdup(zMainBranch);
1286 *zFile = zPath;
1287 *type = SVN_TRUNK;
1288 }else
@@ -1728,11 +1729,10 @@
1729 int svnFlag = find_option("svn", 0, 0)!=0;
1730 int gitFlag = find_option("git", 0, 0)!=0;
1731 int omitRebuild = find_option("no-rebuild",0,0)!=0;
1732 int omitVacuum = find_option("no-vacuum",0,0)!=0;
1733 const char *zDefaultUser = find_option("admin-user","A",1);
 
1734
1735 /* Options common to all input formats */
1736 int incrFlag = find_option("incremental", "i", 0)!=0;
1737
1738 /* Options for --svn only */
@@ -1772,11 +1772,11 @@
1772 *renOpt->varSuf = renOpt->zDefaultSuf;
1773 }
1774 }
1775 }
1776 if( !(gimport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
1777 gimport.zTrunkName = fossil_strdup(db_main_branch());
1778 }
1779
1780 if( svnFlag ){
1781 /* Get --svn related options here, so verify_all_options() fails when
1782 * svn-only options are specified with --git
1783
+3 -3
--- src/info.c
+++ src/info.c
@@ -1141,11 +1141,11 @@
11411141
}
11421142
@ %s(zLinks)</td></tr>
11431143
}
11441144
11451145
if( g.perm.Hyperlink ){
1146
- char *zMainBranch = db_get("main-branch", 0);
1146
+ const char *zMainBranch = db_main_branch();
11471147
@ <tr><th>Other&nbsp;Links:</th>
11481148
@ <td>
11491149
if( fossil_strcmp(zBrName, zMainBranch)!=0 ){
11501150
@ %z(href("%R/vdiff?branch=%!S", zUuid))branch diff</a> |
11511151
}
@@ -3718,11 +3718,11 @@
37183718
style_header("Edit Check-in [%s]", zUuid);
37193719
if( P("preview") ){
37203720
Blob suffix;
37213721
int nTag = 0;
37223722
const char *zDplyBr; /* Branch name used to determine BG color */
3723
- char *zMainBranch = db_get("main-branch", 0);
3723
+ const char *zMainBranch = db_main_branch();
37243724
if( zNewBrFlag[0] && zNewBranch[0] ){
37253725
zDplyBr = zNewBranch;
37263726
}else{
37273727
zDplyBr = zBranchName;
37283728
}
@@ -3857,11 +3857,11 @@
38573857
}
38583858
db_finalize(&q);
38593859
@ </td></tr>
38603860
38613861
if( !zBranchName ){
3862
- zBranchName = db_get("main-branch", 0);
3862
+ zBranchName = fossil_strdup(db_main_branch());
38633863
}
38643864
if( !zNewBranch || !zNewBranch[0]){
38653865
zNewBranch = zBranchName;
38663866
}
38673867
@ <tr><th align="right" valign="top">Branching:</th>
38683868
--- src/info.c
+++ src/info.c
@@ -1141,11 +1141,11 @@
1141 }
1142 @ %s(zLinks)</td></tr>
1143 }
1144
1145 if( g.perm.Hyperlink ){
1146 char *zMainBranch = db_get("main-branch", 0);
1147 @ <tr><th>Other&nbsp;Links:</th>
1148 @ <td>
1149 if( fossil_strcmp(zBrName, zMainBranch)!=0 ){
1150 @ %z(href("%R/vdiff?branch=%!S", zUuid))branch diff</a> |
1151 }
@@ -3718,11 +3718,11 @@
3718 style_header("Edit Check-in [%s]", zUuid);
3719 if( P("preview") ){
3720 Blob suffix;
3721 int nTag = 0;
3722 const char *zDplyBr; /* Branch name used to determine BG color */
3723 char *zMainBranch = db_get("main-branch", 0);
3724 if( zNewBrFlag[0] && zNewBranch[0] ){
3725 zDplyBr = zNewBranch;
3726 }else{
3727 zDplyBr = zBranchName;
3728 }
@@ -3857,11 +3857,11 @@
3857 }
3858 db_finalize(&q);
3859 @ </td></tr>
3860
3861 if( !zBranchName ){
3862 zBranchName = db_get("main-branch", 0);
3863 }
3864 if( !zNewBranch || !zNewBranch[0]){
3865 zNewBranch = zBranchName;
3866 }
3867 @ <tr><th align="right" valign="top">Branching:</th>
3868
--- src/info.c
+++ src/info.c
@@ -1141,11 +1141,11 @@
1141 }
1142 @ %s(zLinks)</td></tr>
1143 }
1144
1145 if( g.perm.Hyperlink ){
1146 const char *zMainBranch = db_main_branch();
1147 @ <tr><th>Other&nbsp;Links:</th>
1148 @ <td>
1149 if( fossil_strcmp(zBrName, zMainBranch)!=0 ){
1150 @ %z(href("%R/vdiff?branch=%!S", zUuid))branch diff</a> |
1151 }
@@ -3718,11 +3718,11 @@
3718 style_header("Edit Check-in [%s]", zUuid);
3719 if( P("preview") ){
3720 Blob suffix;
3721 int nTag = 0;
3722 const char *zDplyBr; /* Branch name used to determine BG color */
3723 const char *zMainBranch = db_main_branch();
3724 if( zNewBrFlag[0] && zNewBranch[0] ){
3725 zDplyBr = zNewBranch;
3726 }else{
3727 zDplyBr = zBranchName;
3728 }
@@ -3857,11 +3857,11 @@
3857 }
3858 db_finalize(&q);
3859 @ </td></tr>
3860
3861 if( !zBranchName ){
3862 zBranchName = fossil_strdup(db_main_branch());
3863 }
3864 if( !zNewBranch || !zNewBranch[0]){
3865 zNewBranch = zBranchName;
3866 }
3867 @ <tr><th align="right" valign="top">Branching:</th>
3868
--- src/json_branch.c
+++ src/json_branch.c
@@ -313,11 +313,11 @@
313313
cson_value * payV = NULL;
314314
cson_object * pay = NULL;
315315
int rc = 0;
316316
BranchCreateOptions opt;
317317
char * zUuid = NULL;
318
- char *zMainBranch = db_get("main-branch", 0);
318
+ const char *zMainBranch = db_main_branch();
319319
int rid = 0;
320320
if( !g.perm.Write ){
321321
json_set_err(FSL_JSON_E_DENIED,
322322
"Requires 'i' permissions.");
323323
return NULL;
324324
--- src/json_branch.c
+++ src/json_branch.c
@@ -313,11 +313,11 @@
313 cson_value * payV = NULL;
314 cson_object * pay = NULL;
315 int rc = 0;
316 BranchCreateOptions opt;
317 char * zUuid = NULL;
318 char *zMainBranch = db_get("main-branch", 0);
319 int rid = 0;
320 if( !g.perm.Write ){
321 json_set_err(FSL_JSON_E_DENIED,
322 "Requires 'i' permissions.");
323 return NULL;
324
--- src/json_branch.c
+++ src/json_branch.c
@@ -313,11 +313,11 @@
313 cson_value * payV = NULL;
314 cson_object * pay = NULL;
315 int rc = 0;
316 BranchCreateOptions opt;
317 char * zUuid = NULL;
318 const char *zMainBranch = db_main_branch();
319 int rid = 0;
320 if( !g.perm.Write ){
321 json_set_err(FSL_JSON_E_DENIED,
322 "Requires 'i' permissions.");
323 return NULL;
324
+1 -1
--- src/leaf.c
+++ src/leaf.c
@@ -228,11 +228,11 @@
228228
Stmt q;
229229
int n = 0;
230230
Blob msg;
231231
const char *zMainBranch;
232232
if( leaf_ambiguity(rid)==0 ) return 0;
233
- zMainBranch = db_get("main-branch", 0);
233
+ zMainBranch = db_main_branch();
234234
zBr = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
235235
TAG_BRANCH, rid);
236236
if( zBr==0 ) zBr = fossil_strdup(zMainBranch);
237237
blob_init(&msg, 0, 0);
238238
blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
239239
--- src/leaf.c
+++ src/leaf.c
@@ -228,11 +228,11 @@
228 Stmt q;
229 int n = 0;
230 Blob msg;
231 const char *zMainBranch;
232 if( leaf_ambiguity(rid)==0 ) return 0;
233 zMainBranch = db_get("main-branch", 0);
234 zBr = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
235 TAG_BRANCH, rid);
236 if( zBr==0 ) zBr = fossil_strdup(zMainBranch);
237 blob_init(&msg, 0, 0);
238 blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
239
--- src/leaf.c
+++ src/leaf.c
@@ -228,11 +228,11 @@
228 Stmt q;
229 int n = 0;
230 Blob msg;
231 const char *zMainBranch;
232 if( leaf_ambiguity(rid)==0 ) return 0;
233 zMainBranch = db_main_branch();
234 zBr = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
235 TAG_BRANCH, rid);
236 if( zBr==0 ) zBr = fossil_strdup(zMainBranch);
237 blob_init(&msg, 0, 0);
238 blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
239
+1 -1
--- src/rebuild.c
+++ src/rebuild.c
@@ -351,11 +351,11 @@
351351
/*
352352
** Check to see if the "sym-trunk" tag exists. If not, create it
353353
** and attach it to the very first check-in.
354354
*/
355355
static void rebuild_tag_trunk(void){
356
- char *zMainBranch = db_get("main-branch", 0);
356
+ const char *zMainBranch = db_main_branch();
357357
int tagid = db_int(0, "SELECT 1 FROM tag WHERE tagname='sym-%q'",zMainBranch);
358358
int rid;
359359
char *zUuid;
360360
361361
if( tagid>0 ) return;
362362
--- src/rebuild.c
+++ src/rebuild.c
@@ -351,11 +351,11 @@
351 /*
352 ** Check to see if the "sym-trunk" tag exists. If not, create it
353 ** and attach it to the very first check-in.
354 */
355 static void rebuild_tag_trunk(void){
356 char *zMainBranch = db_get("main-branch", 0);
357 int tagid = db_int(0, "SELECT 1 FROM tag WHERE tagname='sym-%q'",zMainBranch);
358 int rid;
359 char *zUuid;
360
361 if( tagid>0 ) return;
362
--- src/rebuild.c
+++ src/rebuild.c
@@ -351,11 +351,11 @@
351 /*
352 ** Check to see if the "sym-trunk" tag exists. If not, create it
353 ** and attach it to the very first check-in.
354 */
355 static void rebuild_tag_trunk(void){
356 const char *zMainBranch = db_main_branch();
357 int tagid = db_int(0, "SELECT 1 FROM tag WHERE tagname='sym-%q'",zMainBranch);
358 int rid;
359 char *zUuid;
360
361 if( tagid>0 ) return;
362
+2 -2
--- src/search.c
+++ src/search.c
@@ -852,11 +852,11 @@
852852
){
853853
search_init(zPattern, "<mark>", "</mark>", " ... ",
854854
SRCHFLG_STATIC|SRCHFLG_HTML);
855855
if( (srchFlags & SRCH_DOC)!=0 ){
856856
char *zDocGlob = db_get("doc-glob","");
857
- char *zMainBranch = db_get("main-branch", 0);
857
+ const char *zMainBranch = db_main_branch();
858858
char *zDocBr = db_get("doc-branch", zMainBranch);
859859
if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
860860
Glob * pGlob = glob_create(zDocBr)
861861
/* We're misusing a Glob as a list of comma-/space-delimited
862862
** tokens. We're not actually doing glob matches here. */;
@@ -1987,11 +1987,11 @@
19871987
** and if the latest check-in on doc-br is in the unindexed set of
19881988
** check-ins, then update all 'd' entries in FTSDOCS that have
19891989
** changed.
19901990
*/
19911991
static void search_update_doc_index(void){
1992
- char *zMainBranch = db_get("main-branch", 0);
1992
+ const char *zMainBranch = db_main_branch();
19931993
const char *zDocBranches = db_get("doc-branch", zMainBranch);
19941994
int i;
19951995
Glob * pGlob = glob_create(zDocBranches)
19961996
/* We're misusing a Glob as a list of comma-/space-delimited
19971997
** tokens. We're not actually doing glob matches here. */;
19981998
--- src/search.c
+++ src/search.c
@@ -852,11 +852,11 @@
852 ){
853 search_init(zPattern, "<mark>", "</mark>", " ... ",
854 SRCHFLG_STATIC|SRCHFLG_HTML);
855 if( (srchFlags & SRCH_DOC)!=0 ){
856 char *zDocGlob = db_get("doc-glob","");
857 char *zMainBranch = db_get("main-branch", 0);
858 char *zDocBr = db_get("doc-branch", zMainBranch);
859 if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
860 Glob * pGlob = glob_create(zDocBr)
861 /* We're misusing a Glob as a list of comma-/space-delimited
862 ** tokens. We're not actually doing glob matches here. */;
@@ -1987,11 +1987,11 @@
1987 ** and if the latest check-in on doc-br is in the unindexed set of
1988 ** check-ins, then update all 'd' entries in FTSDOCS that have
1989 ** changed.
1990 */
1991 static void search_update_doc_index(void){
1992 char *zMainBranch = db_get("main-branch", 0);
1993 const char *zDocBranches = db_get("doc-branch", zMainBranch);
1994 int i;
1995 Glob * pGlob = glob_create(zDocBranches)
1996 /* We're misusing a Glob as a list of comma-/space-delimited
1997 ** tokens. We're not actually doing glob matches here. */;
1998
--- src/search.c
+++ src/search.c
@@ -852,11 +852,11 @@
852 ){
853 search_init(zPattern, "<mark>", "</mark>", " ... ",
854 SRCHFLG_STATIC|SRCHFLG_HTML);
855 if( (srchFlags & SRCH_DOC)!=0 ){
856 char *zDocGlob = db_get("doc-glob","");
857 const char *zMainBranch = db_main_branch();
858 char *zDocBr = db_get("doc-branch", zMainBranch);
859 if( zDocGlob && zDocGlob[0] && zDocBr && zDocBr[0] ){
860 Glob * pGlob = glob_create(zDocBr)
861 /* We're misusing a Glob as a list of comma-/space-delimited
862 ** tokens. We're not actually doing glob matches here. */;
@@ -1987,11 +1987,11 @@
1987 ** and if the latest check-in on doc-br is in the unindexed set of
1988 ** check-ins, then update all 'd' entries in FTSDOCS that have
1989 ** changed.
1990 */
1991 static void search_update_doc_index(void){
1992 const char *zMainBranch = db_main_branch();
1993 const char *zDocBranches = db_get("doc-branch", zMainBranch);
1994 int i;
1995 Glob * pGlob = glob_create(zDocBranches)
1996 /* We're misusing a Glob as a list of comma-/space-delimited
1997 ** tokens. We're not actually doing glob matches here. */;
1998
+2 -2
--- src/setup.c
+++ src/setup.c
@@ -2282,11 +2282,11 @@
22822282
** WEBPAGE: srchsetup
22832283
**
22842284
** Configure the search engine. Requires Admin privilege.
22852285
*/
22862286
void page_srchsetup(){
2287
- char *zMainBranch;
2287
+ const char *zMainBranch;
22882288
login_check_credentials();
22892289
if( !g.perm.Admin ){
22902290
login_needed(0);
22912291
return;
22922292
}
@@ -2313,11 +2313,11 @@
23132313
@ <tr><td>*<td><td>Search all checked-in files</tr>
23142314
@ <tr><td><i>(blank)</i><td>
23152315
@ <td>Search nothing. (Disables document search).</tr>
23162316
@ </table>
23172317
@ <hr>
2318
- zMainBranch = db_get("main-branch", 0);
2318
+ zMainBranch = db_main_branch();
23192319
entry_attribute("Document Branches", 20, "doc-branch", "db", zMainBranch, 0);
23202320
@ <p>When searching documents, use the versions of the files found at the
23212321
@ type of the "Document Branches" branch. Recommended value: the name of
23222322
@ the main branch (usually "trunk").
23232323
@ Document search is disabled if blank. It may be a list of branch names
23242324
--- src/setup.c
+++ src/setup.c
@@ -2282,11 +2282,11 @@
2282 ** WEBPAGE: srchsetup
2283 **
2284 ** Configure the search engine. Requires Admin privilege.
2285 */
2286 void page_srchsetup(){
2287 char *zMainBranch;
2288 login_check_credentials();
2289 if( !g.perm.Admin ){
2290 login_needed(0);
2291 return;
2292 }
@@ -2313,11 +2313,11 @@
2313 @ <tr><td>*<td><td>Search all checked-in files</tr>
2314 @ <tr><td><i>(blank)</i><td>
2315 @ <td>Search nothing. (Disables document search).</tr>
2316 @ </table>
2317 @ <hr>
2318 zMainBranch = db_get("main-branch", 0);
2319 entry_attribute("Document Branches", 20, "doc-branch", "db", zMainBranch, 0);
2320 @ <p>When searching documents, use the versions of the files found at the
2321 @ type of the "Document Branches" branch. Recommended value: the name of
2322 @ the main branch (usually "trunk").
2323 @ Document search is disabled if blank. It may be a list of branch names
2324
--- src/setup.c
+++ src/setup.c
@@ -2282,11 +2282,11 @@
2282 ** WEBPAGE: srchsetup
2283 **
2284 ** Configure the search engine. Requires Admin privilege.
2285 */
2286 void page_srchsetup(){
2287 const char *zMainBranch;
2288 login_check_credentials();
2289 if( !g.perm.Admin ){
2290 login_needed(0);
2291 return;
2292 }
@@ -2313,11 +2313,11 @@
2313 @ <tr><td>*<td><td>Search all checked-in files</tr>
2314 @ <tr><td><i>(blank)</i><td>
2315 @ <td>Search nothing. (Disables document search).</tr>
2316 @ </table>
2317 @ <hr>
2318 zMainBranch = db_main_branch();
2319 entry_attribute("Document Branches", 20, "doc-branch", "db", zMainBranch, 0);
2320 @ <p>When searching documents, use the versions of the files found at the
2321 @ type of the "Document Branches" branch. Recommended value: the name of
2322 @ the main branch (usually "trunk").
2323 @ Document search is disabled if blank. It may be a list of branch names
2324
+1 -2
--- src/tar.c
+++ src/tar.c
@@ -949,21 +949,20 @@
949949
Blob cacheKey; /* The key to cache */
950950
Glob *pInclude = 0; /* The compiled in= glob pattern */
951951
Glob *pExclude = 0; /* The compiled ex= glob pattern */
952952
Blob tarball; /* Tarball accumulated here */
953953
const char *z;
954
- char *zMainBranch = db_get("main-branch", 0);
955954
956955
login_check_credentials();
957956
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
958957
if( robot_restrict("zip") ) return;
959958
fossil_nice_default();
960959
zName = fossil_strdup(PD("name",""));
961960
z = P("r");
962961
if( z==0 ) z = P("uuid");
963962
if( z==0 ) z = tar_uuid_from_name(&zName);
964
- if( z==0 ) z = fossil_strdup(zMainBranch);
963
+ if( z==0 ) z = fossil_strdup(db_main_branch());
965964
g.zOpenRevision = zRid = fossil_strdup(z);
966965
nRid = strlen(zRid);
967966
zInclude = P("in");
968967
if( zInclude ) pInclude = glob_create(zInclude);
969968
zExclude = P("ex");
970969
--- src/tar.c
+++ src/tar.c
@@ -949,21 +949,20 @@
949 Blob cacheKey; /* The key to cache */
950 Glob *pInclude = 0; /* The compiled in= glob pattern */
951 Glob *pExclude = 0; /* The compiled ex= glob pattern */
952 Blob tarball; /* Tarball accumulated here */
953 const char *z;
954 char *zMainBranch = db_get("main-branch", 0);
955
956 login_check_credentials();
957 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
958 if( robot_restrict("zip") ) return;
959 fossil_nice_default();
960 zName = fossil_strdup(PD("name",""));
961 z = P("r");
962 if( z==0 ) z = P("uuid");
963 if( z==0 ) z = tar_uuid_from_name(&zName);
964 if( z==0 ) z = fossil_strdup(zMainBranch);
965 g.zOpenRevision = zRid = fossil_strdup(z);
966 nRid = strlen(zRid);
967 zInclude = P("in");
968 if( zInclude ) pInclude = glob_create(zInclude);
969 zExclude = P("ex");
970
--- src/tar.c
+++ src/tar.c
@@ -949,21 +949,20 @@
949 Blob cacheKey; /* The key to cache */
950 Glob *pInclude = 0; /* The compiled in= glob pattern */
951 Glob *pExclude = 0; /* The compiled ex= glob pattern */
952 Blob tarball; /* Tarball accumulated here */
953 const char *z;
 
954
955 login_check_credentials();
956 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
957 if( robot_restrict("zip") ) return;
958 fossil_nice_default();
959 zName = fossil_strdup(PD("name",""));
960 z = P("r");
961 if( z==0 ) z = P("uuid");
962 if( z==0 ) z = tar_uuid_from_name(&zName);
963 if( z==0 ) z = fossil_strdup(db_main_branch());
964 g.zOpenRevision = zRid = fossil_strdup(z);
965 nRid = strlen(zRid);
966 zInclude = P("in");
967 if( zInclude ) pInclude = glob_create(zInclude);
968 zExclude = P("ex");
969
+1 -1
--- src/timeline.c
+++ src/timeline.c
@@ -388,11 +388,11 @@
388388
const char *zStyle; /* Sub-name for classes for the style */
389389
const char *zDateFmt;
390390
int iTableId = timeline_tableid();
391391
int bTimestampLinksToInfo; /* True if timestamp hyperlinks go to the /info
392392
** page rather than the /timeline page */
393
- char *zMainBranch = db_get("main-branch","trunk");
393
+ const char *zMainBranch = db_main_branch();
394394
395395
396396
if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
397397
vid = db_lget_int("checkout", 0);
398398
}
399399
--- src/timeline.c
+++ src/timeline.c
@@ -388,11 +388,11 @@
388 const char *zStyle; /* Sub-name for classes for the style */
389 const char *zDateFmt;
390 int iTableId = timeline_tableid();
391 int bTimestampLinksToInfo; /* True if timestamp hyperlinks go to the /info
392 ** page rather than the /timeline page */
393 char *zMainBranch = db_get("main-branch","trunk");
394
395
396 if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
397 vid = db_lget_int("checkout", 0);
398 }
399
--- src/timeline.c
+++ src/timeline.c
@@ -388,11 +388,11 @@
388 const char *zStyle; /* Sub-name for classes for the style */
389 const char *zDateFmt;
390 int iTableId = timeline_tableid();
391 int bTimestampLinksToInfo; /* True if timestamp hyperlinks go to the /info
392 ** page rather than the /timeline page */
393 const char *zMainBranch = db_main_branch();
394
395
396 if( cgi_is_loopback(g.zIpAddr) && db_open_local(0) ){
397 vid = db_lget_int("checkout", 0);
398 }
399
+1 -2
--- src/update.c
+++ src/update.c
@@ -751,17 +751,16 @@
751751
Manifest *historical_manifest(
752752
const char *zRevision /* The check-in to query, or NULL for current */
753753
){
754754
int vid;
755755
Manifest *pManifest;
756
- char *zMainBranch = db_get("main-branch", 0);
757756
758757
/* Determine the check-in manifest artifact ID. Panic on failure. */
759758
if( zRevision ){
760759
vid = name_to_typed_rid(zRevision, "ci");
761760
}else if( !g.localOpen ){
762
- vid = name_to_typed_rid(zMainBranch, "ci");
761
+ vid = name_to_typed_rid(db_main_branch(), "ci");
763762
}else{
764763
vid = db_lget_int("checkout", 0);
765764
if( !is_a_version(vid) ){
766765
if( vid==0 ) return 0;
767766
zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
768767
--- src/update.c
+++ src/update.c
@@ -751,17 +751,16 @@
751 Manifest *historical_manifest(
752 const char *zRevision /* The check-in to query, or NULL for current */
753 ){
754 int vid;
755 Manifest *pManifest;
756 char *zMainBranch = db_get("main-branch", 0);
757
758 /* Determine the check-in manifest artifact ID. Panic on failure. */
759 if( zRevision ){
760 vid = name_to_typed_rid(zRevision, "ci");
761 }else if( !g.localOpen ){
762 vid = name_to_typed_rid(zMainBranch, "ci");
763 }else{
764 vid = db_lget_int("checkout", 0);
765 if( !is_a_version(vid) ){
766 if( vid==0 ) return 0;
767 zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
768
--- src/update.c
+++ src/update.c
@@ -751,17 +751,16 @@
751 Manifest *historical_manifest(
752 const char *zRevision /* The check-in to query, or NULL for current */
753 ){
754 int vid;
755 Manifest *pManifest;
 
756
757 /* Determine the check-in manifest artifact ID. Panic on failure. */
758 if( zRevision ){
759 vid = name_to_typed_rid(zRevision, "ci");
760 }else if( !g.localOpen ){
761 vid = name_to_typed_rid(db_main_branch(), "ci");
762 }else{
763 vid = db_lget_int("checkout", 0);
764 if( !is_a_version(vid) ){
765 if( vid==0 ) return 0;
766 zRevision = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", vid);
767
+1 -2
--- src/zip.c
+++ src/zip.c
@@ -1020,11 +1020,10 @@
10201020
Glob *pInclude = 0; /* The compiled in= glob pattern */
10211021
Glob *pExclude = 0; /* The compiled ex= glob pattern */
10221022
Blob zip; /* ZIP archive accumulated here */
10231023
int eType = ARCHIVE_ZIP; /* Type of archive to generate */
10241024
char *zType; /* Human-readable archive type */
1025
- char *zMainBranch = db_get("main-branch", 0);
10261025
10271026
login_check_credentials();
10281027
if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
10291028
if( robot_restrict("zip") ) return;
10301029
if( fossil_strcmp(g.zPath, "sqlar")==0 ){
@@ -1037,11 +1036,11 @@
10371036
fossil_nice_default();
10381037
zName = fossil_strdup(PD("name",""));
10391038
z = P("r");
10401039
if( z==0 ) z = P("uuid");
10411040
if( z==0 ) z = tar_uuid_from_name(&zName);
1042
- if( z==0 ) z = fossil_strdup(zMainBranch);
1041
+ if( z==0 ) z = fossil_strdup(db_main_branch());
10431042
nName = strlen(zName);
10441043
g.zOpenRevision = zRid = fossil_strdup(z);
10451044
nRid = strlen(zRid);
10461045
zInclude = P("in");
10471046
if( zInclude ) pInclude = glob_create(zInclude);
10481047
--- src/zip.c
+++ src/zip.c
@@ -1020,11 +1020,10 @@
1020 Glob *pInclude = 0; /* The compiled in= glob pattern */
1021 Glob *pExclude = 0; /* The compiled ex= glob pattern */
1022 Blob zip; /* ZIP archive accumulated here */
1023 int eType = ARCHIVE_ZIP; /* Type of archive to generate */
1024 char *zType; /* Human-readable archive type */
1025 char *zMainBranch = db_get("main-branch", 0);
1026
1027 login_check_credentials();
1028 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
1029 if( robot_restrict("zip") ) return;
1030 if( fossil_strcmp(g.zPath, "sqlar")==0 ){
@@ -1037,11 +1036,11 @@
1037 fossil_nice_default();
1038 zName = fossil_strdup(PD("name",""));
1039 z = P("r");
1040 if( z==0 ) z = P("uuid");
1041 if( z==0 ) z = tar_uuid_from_name(&zName);
1042 if( z==0 ) z = fossil_strdup(zMainBranch);
1043 nName = strlen(zName);
1044 g.zOpenRevision = zRid = fossil_strdup(z);
1045 nRid = strlen(zRid);
1046 zInclude = P("in");
1047 if( zInclude ) pInclude = glob_create(zInclude);
1048
--- src/zip.c
+++ src/zip.c
@@ -1020,11 +1020,10 @@
1020 Glob *pInclude = 0; /* The compiled in= glob pattern */
1021 Glob *pExclude = 0; /* The compiled ex= glob pattern */
1022 Blob zip; /* ZIP archive accumulated here */
1023 int eType = ARCHIVE_ZIP; /* Type of archive to generate */
1024 char *zType; /* Human-readable archive type */
 
1025
1026 login_check_credentials();
1027 if( !g.perm.Zip ){ login_needed(g.anon.Zip); return; }
1028 if( robot_restrict("zip") ) return;
1029 if( fossil_strcmp(g.zPath, "sqlar")==0 ){
@@ -1037,11 +1036,11 @@
1036 fossil_nice_default();
1037 zName = fossil_strdup(PD("name",""));
1038 z = P("r");
1039 if( z==0 ) z = P("uuid");
1040 if( z==0 ) z = tar_uuid_from_name(&zName);
1041 if( z==0 ) z = fossil_strdup(db_main_branch());
1042 nName = strlen(zName);
1043 g.zOpenRevision = zRid = fossil_strdup(z);
1044 nRid = strlen(zRid);
1045 zInclude = P("in");
1046 if( zInclude ) pInclude = glob_create(zInclude);
1047

Keyboard Shortcuts

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