Fossil SCM

Automatically run "git repack -adf" after an initial export to git using the "fossil git export" command. (Recommended by Linus Torvalds himself.)

drh 2019-03-17 00:14 trunk
Commit e4d87cd16bd4be9841ab608e0ef90d0662866e8dff642b3381043bac2116a84b
1 file changed +9
--- src/export.c
+++ src/export.c
@@ -1235,10 +1235,11 @@
12351235
const char *zAutoPush = 0; /* Value of the --autopush flag */
12361236
char *zPushUrl; /* URL to sync the mirror to */
12371237
double rEnd; /* time of most recent export */
12381238
int rc; /* Result code */
12391239
int bForce; /* Do the export and sync even if no changes*/
1240
+ int bNeedRepack = 0; /* True if we should run repack at the end */
12401241
int fManifest; /* Current "manifest" setting */
12411242
FILE *xCmd; /* Pipe to the "git fast-import" command */
12421243
FILE *pMarks; /* Git mark files */
12431244
Stmt q; /* Queries */
12441245
char zLine[200]; /* One line of a mark file */
@@ -1280,10 +1281,11 @@
12801281
rc = fossil_system(zCmd);
12811282
if( rc ){
12821283
fossil_fatal("cannot initialize the git repository using: \"%s\"", zCmd);
12831284
}
12841285
fossil_free(zCmd);
1286
+ bNeedRepack = 1;
12851287
}
12861288
fossil_free(z);
12871289
12881290
/* Make sure the .mirror_state subdirectory exists */
12891291
z = mprintf("%s/.mirror_state", zMirror);
@@ -1461,10 +1463,17 @@
14611463
db_bind_double(&q, ":x", rEnd);
14621464
db_step(&q);
14631465
db_finalize(&q);
14641466
}
14651467
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
+ }
14661475
14671476
/* Optionally do a "git push" */
14681477
zPushUrl = db_text(0, "SELECT value FROM mconfig WHERE key='autopush'");
14691478
if( zPushUrl ){
14701479
char *zPushCmd;
14711480
--- 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

Keyboard Shortcuts

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