Fossil SCM

Set the gitmirror_mainbranch value earlier to avoid creating a default branch with the wrong name in new exports.

drh 2021-01-06 16:28 trunk
Commit dbcf66b57f971504b94512b9428535a29312665fd387a4be11b28d2b96bb58bd
1 file changed +8 -5
+8 -5
--- src/export.c
+++ src/export.c
@@ -865,11 +865,11 @@
865865
static int gitmirror_verbosity = VERB_NORMAL;
866866
867867
/* The main branch in the Git repository. The "trunk" branch of
868868
** Fossil is renamed to be this branch name.
869869
*/
870
-static const char *gitmirror_mainbranch = "master";
870
+static const char *gitmirror_mainbranch = 0;
871871
872872
/*
873873
** Output routine that depends on verbosity
874874
*/
875875
static void gitmirror_message(int iLevel, const char *zFormat, ...){
@@ -1153,10 +1153,11 @@
11531153
zBranch = db_text(0,
11541154
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d",
11551155
TAG_BRANCH, rid
11561156
);
11571157
if( fossil_strcmp(zBranch,"trunk")==0 ){
1158
+ assert( gitmirror_mainbranch!=0 );
11581159
fossil_free(zBranch);
11591160
zBranch = mprintf("%s",gitmirror_mainbranch);
11601161
}else if( zBranch==0 ){
11611162
zBranch = mprintf("unknown");
11621163
}else{
@@ -1430,11 +1431,17 @@
14301431
db_multi_exec(
14311432
"REPLACE INTO mirror.mconfig(key,value)"
14321433
"VALUES('mainbranch',%Q)",
14331434
zMainBr
14341435
);
1436
+ gitmirror_mainbranch = fossil_strdup(zMainBr);
1437
+ }else{
1438
+ /* Recover the saved name of the main branch */
1439
+ gitmirror_mainbranch = db_text("master",
1440
+ "SELECT value FROM mconfig WHERE key='mainbranch'");
14351441
}
1442
+
14361443
14371444
/* See if there is any work to be done. Exit early if not, before starting
14381445
** the "git fast-import" command. */
14391446
if( !bForce
14401447
&& !db_exists("SELECT 1 FROM event WHERE type IN ('ci','t')"
@@ -1546,14 +1553,10 @@
15461553
}
15471554
db_multi_exec(
15481555
"CREATE INDEX IF NOT EXISTS mirror.mmarkx1 ON mmark(githash);"
15491556
);
15501557
1551
- /* Recover the saved name of the main branch */
1552
- gitmirror_mainbranch = db_text("master",
1553
- "SELECT value FROM mconfig WHERE key='mainbranch'");
1554
-
15551558
/* Do any tags that have been created since the start time */
15561559
db_prepare(&q,
15571560
"SELECT substr(tagname,5), githash"
15581561
" FROM (SELECT tagxref.tagid AS xtagid, tagname, rid, max(mtime) AS mtime"
15591562
" FROM tagxref JOIN tag ON tag.tagid=tagxref.tagid"
15601563
--- src/export.c
+++ src/export.c
@@ -865,11 +865,11 @@
865 static int gitmirror_verbosity = VERB_NORMAL;
866
867 /* The main branch in the Git repository. The "trunk" branch of
868 ** Fossil is renamed to be this branch name.
869 */
870 static const char *gitmirror_mainbranch = "master";
871
872 /*
873 ** Output routine that depends on verbosity
874 */
875 static void gitmirror_message(int iLevel, const char *zFormat, ...){
@@ -1153,10 +1153,11 @@
1153 zBranch = db_text(0,
1154 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d",
1155 TAG_BRANCH, rid
1156 );
1157 if( fossil_strcmp(zBranch,"trunk")==0 ){
 
1158 fossil_free(zBranch);
1159 zBranch = mprintf("%s",gitmirror_mainbranch);
1160 }else if( zBranch==0 ){
1161 zBranch = mprintf("unknown");
1162 }else{
@@ -1430,11 +1431,17 @@
1430 db_multi_exec(
1431 "REPLACE INTO mirror.mconfig(key,value)"
1432 "VALUES('mainbranch',%Q)",
1433 zMainBr
1434 );
 
 
 
 
 
1435 }
 
1436
1437 /* See if there is any work to be done. Exit early if not, before starting
1438 ** the "git fast-import" command. */
1439 if( !bForce
1440 && !db_exists("SELECT 1 FROM event WHERE type IN ('ci','t')"
@@ -1546,14 +1553,10 @@
1546 }
1547 db_multi_exec(
1548 "CREATE INDEX IF NOT EXISTS mirror.mmarkx1 ON mmark(githash);"
1549 );
1550
1551 /* Recover the saved name of the main branch */
1552 gitmirror_mainbranch = db_text("master",
1553 "SELECT value FROM mconfig WHERE key='mainbranch'");
1554
1555 /* Do any tags that have been created since the start time */
1556 db_prepare(&q,
1557 "SELECT substr(tagname,5), githash"
1558 " FROM (SELECT tagxref.tagid AS xtagid, tagname, rid, max(mtime) AS mtime"
1559 " FROM tagxref JOIN tag ON tag.tagid=tagxref.tagid"
1560
--- src/export.c
+++ src/export.c
@@ -865,11 +865,11 @@
865 static int gitmirror_verbosity = VERB_NORMAL;
866
867 /* The main branch in the Git repository. The "trunk" branch of
868 ** Fossil is renamed to be this branch name.
869 */
870 static const char *gitmirror_mainbranch = 0;
871
872 /*
873 ** Output routine that depends on verbosity
874 */
875 static void gitmirror_message(int iLevel, const char *zFormat, ...){
@@ -1153,10 +1153,11 @@
1153 zBranch = db_text(0,
1154 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d",
1155 TAG_BRANCH, rid
1156 );
1157 if( fossil_strcmp(zBranch,"trunk")==0 ){
1158 assert( gitmirror_mainbranch!=0 );
1159 fossil_free(zBranch);
1160 zBranch = mprintf("%s",gitmirror_mainbranch);
1161 }else if( zBranch==0 ){
1162 zBranch = mprintf("unknown");
1163 }else{
@@ -1430,11 +1431,17 @@
1431 db_multi_exec(
1432 "REPLACE INTO mirror.mconfig(key,value)"
1433 "VALUES('mainbranch',%Q)",
1434 zMainBr
1435 );
1436 gitmirror_mainbranch = fossil_strdup(zMainBr);
1437 }else{
1438 /* Recover the saved name of the main branch */
1439 gitmirror_mainbranch = db_text("master",
1440 "SELECT value FROM mconfig WHERE key='mainbranch'");
1441 }
1442
1443
1444 /* See if there is any work to be done. Exit early if not, before starting
1445 ** the "git fast-import" command. */
1446 if( !bForce
1447 && !db_exists("SELECT 1 FROM event WHERE type IN ('ci','t')"
@@ -1546,14 +1553,10 @@
1553 }
1554 db_multi_exec(
1555 "CREATE INDEX IF NOT EXISTS mirror.mmarkx1 ON mmark(githash);"
1556 );
1557
 
 
 
 
1558 /* Do any tags that have been created since the start time */
1559 db_prepare(&q,
1560 "SELECT substr(tagname,5), githash"
1561 " FROM (SELECT tagxref.tagid AS xtagid, tagname, rid, max(mtime) AS mtime"
1562 " FROM tagxref JOIN tag ON tag.tagid=tagxref.tagid"
1563

Keyboard Shortcuts

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