Fossil SCM
Automatically run "git repack -adf" after an initial export to git using the "fossil git export" command. (Recommended by Linus Torvalds himself.)
Commit
e4d87cd16bd4be9841ab608e0ef90d0662866e8dff642b3381043bac2116a84b
Parent
8e6f3ced08278af…
1 file changed
+9
+9
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -1235,10 +1235,11 @@ | ||
| 1235 | 1235 | const char *zAutoPush = 0; /* Value of the --autopush flag */ |
| 1236 | 1236 | char *zPushUrl; /* URL to sync the mirror to */ |
| 1237 | 1237 | double rEnd; /* time of most recent export */ |
| 1238 | 1238 | int rc; /* Result code */ |
| 1239 | 1239 | int bForce; /* Do the export and sync even if no changes*/ |
| 1240 | + int bNeedRepack = 0; /* True if we should run repack at the end */ | |
| 1240 | 1241 | int fManifest; /* Current "manifest" setting */ |
| 1241 | 1242 | FILE *xCmd; /* Pipe to the "git fast-import" command */ |
| 1242 | 1243 | FILE *pMarks; /* Git mark files */ |
| 1243 | 1244 | Stmt q; /* Queries */ |
| 1244 | 1245 | char zLine[200]; /* One line of a mark file */ |
| @@ -1280,10 +1281,11 @@ | ||
| 1280 | 1281 | rc = fossil_system(zCmd); |
| 1281 | 1282 | if( rc ){ |
| 1282 | 1283 | fossil_fatal("cannot initialize the git repository using: \"%s\"", zCmd); |
| 1283 | 1284 | } |
| 1284 | 1285 | fossil_free(zCmd); |
| 1286 | + bNeedRepack = 1; | |
| 1285 | 1287 | } |
| 1286 | 1288 | fossil_free(z); |
| 1287 | 1289 | |
| 1288 | 1290 | /* Make sure the .mirror_state subdirectory exists */ |
| 1289 | 1291 | z = mprintf("%s/.mirror_state", zMirror); |
| @@ -1461,10 +1463,17 @@ | ||
| 1461 | 1463 | db_bind_double(&q, ":x", rEnd); |
| 1462 | 1464 | db_step(&q); |
| 1463 | 1465 | db_finalize(&q); |
| 1464 | 1466 | } |
| 1465 | 1467 | db_commit_transaction(); |
| 1468 | + | |
| 1469 | + /* Maybe run a git repack */ | |
| 1470 | + if( bNeedRepack ){ | |
| 1471 | + const char *zRepack = "git repack -adf"; | |
| 1472 | + gitmirror_message(VERB_NORMAL, "%s\n", zRepack); | |
| 1473 | + fossil_system(zRepack); | |
| 1474 | + } | |
| 1466 | 1475 | |
| 1467 | 1476 | /* Optionally do a "git push" */ |
| 1468 | 1477 | zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'"); |
| 1469 | 1478 | if( zPushUrl ){ |
| 1470 | 1479 | char *zPushCmd; |
| 1471 | 1480 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1235,10 +1235,11 @@ | |
| 1235 | const char *zAutoPush = 0; /* Value of the --autopush flag */ |
| 1236 | char *zPushUrl; /* URL to sync the mirror to */ |
| 1237 | double rEnd; /* time of most recent export */ |
| 1238 | int rc; /* Result code */ |
| 1239 | int bForce; /* Do the export and sync even if no changes*/ |
| 1240 | int fManifest; /* Current "manifest" setting */ |
| 1241 | FILE *xCmd; /* Pipe to the "git fast-import" command */ |
| 1242 | FILE *pMarks; /* Git mark files */ |
| 1243 | Stmt q; /* Queries */ |
| 1244 | char zLine[200]; /* One line of a mark file */ |
| @@ -1280,10 +1281,11 @@ | |
| 1280 | rc = fossil_system(zCmd); |
| 1281 | if( rc ){ |
| 1282 | fossil_fatal("cannot initialize the git repository using: \"%s\"", zCmd); |
| 1283 | } |
| 1284 | fossil_free(zCmd); |
| 1285 | } |
| 1286 | fossil_free(z); |
| 1287 | |
| 1288 | /* Make sure the .mirror_state subdirectory exists */ |
| 1289 | z = mprintf("%s/.mirror_state", zMirror); |
| @@ -1461,10 +1463,17 @@ | |
| 1461 | db_bind_double(&q, ":x", rEnd); |
| 1462 | db_step(&q); |
| 1463 | db_finalize(&q); |
| 1464 | } |
| 1465 | db_commit_transaction(); |
| 1466 | |
| 1467 | /* Optionally do a "git push" */ |
| 1468 | zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'"); |
| 1469 | if( zPushUrl ){ |
| 1470 | char *zPushCmd; |
| 1471 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -1235,10 +1235,11 @@ | |
| 1235 | const char *zAutoPush = 0; /* Value of the --autopush flag */ |
| 1236 | char *zPushUrl; /* URL to sync the mirror to */ |
| 1237 | double rEnd; /* time of most recent export */ |
| 1238 | int rc; /* Result code */ |
| 1239 | int bForce; /* Do the export and sync even if no changes*/ |
| 1240 | int bNeedRepack = 0; /* True if we should run repack at the end */ |
| 1241 | int fManifest; /* Current "manifest" setting */ |
| 1242 | FILE *xCmd; /* Pipe to the "git fast-import" command */ |
| 1243 | FILE *pMarks; /* Git mark files */ |
| 1244 | Stmt q; /* Queries */ |
| 1245 | char zLine[200]; /* One line of a mark file */ |
| @@ -1280,10 +1281,11 @@ | |
| 1281 | rc = fossil_system(zCmd); |
| 1282 | if( rc ){ |
| 1283 | fossil_fatal("cannot initialize the git repository using: \"%s\"", zCmd); |
| 1284 | } |
| 1285 | fossil_free(zCmd); |
| 1286 | bNeedRepack = 1; |
| 1287 | } |
| 1288 | fossil_free(z); |
| 1289 | |
| 1290 | /* Make sure the .mirror_state subdirectory exists */ |
| 1291 | z = mprintf("%s/.mirror_state", zMirror); |
| @@ -1461,10 +1463,17 @@ | |
| 1463 | db_bind_double(&q, ":x", rEnd); |
| 1464 | db_step(&q); |
| 1465 | db_finalize(&q); |
| 1466 | } |
| 1467 | db_commit_transaction(); |
| 1468 | |
| 1469 | /* Maybe run a git repack */ |
| 1470 | if( bNeedRepack ){ |
| 1471 | const char *zRepack = "git repack -adf"; |
| 1472 | gitmirror_message(VERB_NORMAL, "%s\n", zRepack); |
| 1473 | fossil_system(zRepack); |
| 1474 | } |
| 1475 | |
| 1476 | /* Optionally do a "git push" */ |
| 1477 | zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'"); |
| 1478 | if( zPushUrl ){ |
| 1479 | char *zPushCmd; |
| 1480 |