Fossil SCM
On a "fossil git export", run appropriate "git update-ref" commands to make sure that all refs/heads point to the latest check-ins for the branch, even in cases there the branch has been renamed on the Fossil side by a tag.
Commit
ab68afe984d7e43ed32de195ed6e6b1d4097b1dbff0b56d74078c2b70cd71acf
Parent
a0a5be0e976c77c…
1 file changed
+35
+35
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -1484,10 +1484,45 @@ | ||
| 1484 | 1484 | gitmirror_message(VERB_NORMAL, "%s\n", zTagCmd); |
| 1485 | 1485 | fossil_system(zTagCmd); |
| 1486 | 1486 | fossil_free(zTagCmd); |
| 1487 | 1487 | } |
| 1488 | 1488 | db_finalize(&q); |
| 1489 | + | |
| 1490 | + /* Update all references that might have changed since the start time */ | |
| 1491 | + db_prepare(&q, | |
| 1492 | + "SELECT" | |
| 1493 | + " tagxref.value AS name," | |
| 1494 | + " max(event.mtime) AS mtime," | |
| 1495 | + " mmark.githash AS gitckin" | |
| 1496 | + " FROM tagxref, tag, event, blob, mmark" | |
| 1497 | + " WHERE tagxref.tagid=tag.tagid" | |
| 1498 | + " AND tagxref.tagtype>0" | |
| 1499 | + " AND tag.tagname='branch'" | |
| 1500 | + " AND event.objid=tagxref.rid" | |
| 1501 | + " AND event.mtime > coalesce((SELECT value FROM mconfig" | |
| 1502 | + " WHERE key='start'),0.0)" | |
| 1503 | + " AND blob.rid=tagxref.rid" | |
| 1504 | + " AND mmark.uuid=blob.uuid" | |
| 1505 | + " GROUP BY 1" | |
| 1506 | + ); | |
| 1507 | + while( db_step(&q)==SQLITE_ROW ){ | |
| 1508 | + char *zBrname = fossil_strdup(db_column_text(&q,0)); | |
| 1509 | + const char *zObj = db_column_text(&q,2); | |
| 1510 | + char *zRefCmd; | |
| 1511 | + if( fossil_strcmp(zBrname,"trunk")==0 ){ | |
| 1512 | + fossil_free(zBrname); | |
| 1513 | + zBrname = fossil_strdup("master"); | |
| 1514 | + }else{ | |
| 1515 | + gitmirror_sanitize_name(zBrname); | |
| 1516 | + } | |
| 1517 | + zRefCmd = mprintf("git update-ref \"refs/heads/%s\" %s", zBrname, zObj); | |
| 1518 | + fossil_free(zBrname); | |
| 1519 | + gitmirror_message(VERB_NORMAL, "%s\n", zRefCmd); | |
| 1520 | + fossil_system(zRefCmd); | |
| 1521 | + fossil_free(zRefCmd); | |
| 1522 | + } | |
| 1523 | + db_finalize(&q); | |
| 1489 | 1524 | |
| 1490 | 1525 | /* Update the start time */ |
| 1491 | 1526 | if( rEnd>0.0 ){ |
| 1492 | 1527 | db_prepare(&q, "REPLACE INTO mirror.mconfig(key,value) VALUES('start',:x)"); |
| 1493 | 1528 | db_bind_double(&q, ":x", rEnd); |
| 1494 | 1529 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1484,10 +1484,45 @@ | |
| 1484 | gitmirror_message(VERB_NORMAL, "%s\n", zTagCmd); |
| 1485 | fossil_system(zTagCmd); |
| 1486 | fossil_free(zTagCmd); |
| 1487 | } |
| 1488 | db_finalize(&q); |
| 1489 | |
| 1490 | /* Update the start time */ |
| 1491 | if( rEnd>0.0 ){ |
| 1492 | db_prepare(&q, "REPLACE INTO mirror.mconfig(key,value) VALUES('start',:x)"); |
| 1493 | db_bind_double(&q, ":x", rEnd); |
| 1494 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1484,10 +1484,45 @@ | |
| 1484 | gitmirror_message(VERB_NORMAL, "%s\n", zTagCmd); |
| 1485 | fossil_system(zTagCmd); |
| 1486 | fossil_free(zTagCmd); |
| 1487 | } |
| 1488 | db_finalize(&q); |
| 1489 | |
| 1490 | /* Update all references that might have changed since the start time */ |
| 1491 | db_prepare(&q, |
| 1492 | "SELECT" |
| 1493 | " tagxref.value AS name," |
| 1494 | " max(event.mtime) AS mtime," |
| 1495 | " mmark.githash AS gitckin" |
| 1496 | " FROM tagxref, tag, event, blob, mmark" |
| 1497 | " WHERE tagxref.tagid=tag.tagid" |
| 1498 | " AND tagxref.tagtype>0" |
| 1499 | " AND tag.tagname='branch'" |
| 1500 | " AND event.objid=tagxref.rid" |
| 1501 | " AND event.mtime > coalesce((SELECT value FROM mconfig" |
| 1502 | " WHERE key='start'),0.0)" |
| 1503 | " AND blob.rid=tagxref.rid" |
| 1504 | " AND mmark.uuid=blob.uuid" |
| 1505 | " GROUP BY 1" |
| 1506 | ); |
| 1507 | while( db_step(&q)==SQLITE_ROW ){ |
| 1508 | char *zBrname = fossil_strdup(db_column_text(&q,0)); |
| 1509 | const char *zObj = db_column_text(&q,2); |
| 1510 | char *zRefCmd; |
| 1511 | if( fossil_strcmp(zBrname,"trunk")==0 ){ |
| 1512 | fossil_free(zBrname); |
| 1513 | zBrname = fossil_strdup("master"); |
| 1514 | }else{ |
| 1515 | gitmirror_sanitize_name(zBrname); |
| 1516 | } |
| 1517 | zRefCmd = mprintf("git update-ref \"refs/heads/%s\" %s", zBrname, zObj); |
| 1518 | fossil_free(zBrname); |
| 1519 | gitmirror_message(VERB_NORMAL, "%s\n", zRefCmd); |
| 1520 | fossil_system(zRefCmd); |
| 1521 | fossil_free(zRefCmd); |
| 1522 | } |
| 1523 | db_finalize(&q); |
| 1524 | |
| 1525 | /* Update the start time */ |
| 1526 | if( rEnd>0.0 ){ |
| 1527 | db_prepare(&q, "REPLACE INTO mirror.mconfig(key,value) VALUES('start',:x)"); |
| 1528 | db_bind_double(&q, ":x", rEnd); |
| 1529 |