Fossil SCM
Set the gitmirror_mainbranch value earlier to avoid creating a default branch with the wrong name in new exports.
Commit
dbcf66b57f971504b94512b9428535a29312665fd387a4be11b28d2b96bb58bd
Parent
f2aa77cc3fd3bd4…
1 file changed
+8
-5
+8
-5
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -865,11 +865,11 @@ | ||
| 865 | 865 | static int gitmirror_verbosity = VERB_NORMAL; |
| 866 | 866 | |
| 867 | 867 | /* The main branch in the Git repository. The "trunk" branch of |
| 868 | 868 | ** Fossil is renamed to be this branch name. |
| 869 | 869 | */ |
| 870 | -static const char *gitmirror_mainbranch = "master"; | |
| 870 | +static const char *gitmirror_mainbranch = 0; | |
| 871 | 871 | |
| 872 | 872 | /* |
| 873 | 873 | ** Output routine that depends on verbosity |
| 874 | 874 | */ |
| 875 | 875 | static void gitmirror_message(int iLevel, const char *zFormat, ...){ |
| @@ -1153,10 +1153,11 @@ | ||
| 1153 | 1153 | zBranch = db_text(0, |
| 1154 | 1154 | "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=%d", |
| 1155 | 1155 | TAG_BRANCH, rid |
| 1156 | 1156 | ); |
| 1157 | 1157 | if( fossil_strcmp(zBranch,"trunk")==0 ){ |
| 1158 | + assert( gitmirror_mainbranch!=0 ); | |
| 1158 | 1159 | fossil_free(zBranch); |
| 1159 | 1160 | zBranch = mprintf("%s",gitmirror_mainbranch); |
| 1160 | 1161 | }else if( zBranch==0 ){ |
| 1161 | 1162 | zBranch = mprintf("unknown"); |
| 1162 | 1163 | }else{ |
| @@ -1430,11 +1431,17 @@ | ||
| 1430 | 1431 | db_multi_exec( |
| 1431 | 1432 | "REPLACE INTO mirror.mconfig(key,value)" |
| 1432 | 1433 | "VALUES('mainbranch',%Q)", |
| 1433 | 1434 | zMainBr |
| 1434 | 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'"); | |
| 1435 | 1441 | } |
| 1442 | + | |
| 1436 | 1443 | |
| 1437 | 1444 | /* See if there is any work to be done. Exit early if not, before starting |
| 1438 | 1445 | ** the "git fast-import" command. */ |
| 1439 | 1446 | if( !bForce |
| 1440 | 1447 | && !db_exists("SELECT 1 FROM event WHERE type IN ('ci','t')" |
| @@ -1546,14 +1553,10 @@ | ||
| 1546 | 1553 | } |
| 1547 | 1554 | db_multi_exec( |
| 1548 | 1555 | "CREATE INDEX IF NOT EXISTS mirror.mmarkx1 ON mmark(githash);" |
| 1549 | 1556 | ); |
| 1550 | 1557 | |
| 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 | 1558 | /* Do any tags that have been created since the start time */ |
| 1556 | 1559 | db_prepare(&q, |
| 1557 | 1560 | "SELECT substr(tagname,5), githash" |
| 1558 | 1561 | " FROM (SELECT tagxref.tagid AS xtagid, tagname, rid, max(mtime) AS mtime" |
| 1559 | 1562 | " FROM tagxref JOIN tag ON tag.tagid=tagxref.tagid" |
| 1560 | 1563 |
| --- 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 |