Fossil SCM

Add the "fossil all git export" and "fossil all git status" commands.

drh 2020-11-30 21:46 trunk
Commit 9d53f2f6a22037e4d27049875f179829c320ac738cf2038a2b20ceacaaf27c27
2 files changed +17 -1 +4
+17 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -91,10 +91,13 @@
9191
** line options supported by the extra command itself, if any
9292
** are present, are passed along verbatim.
9393
**
9494
** fts-config Run the "fts-config" command on all repositories.
9595
**
96
+** git export Do the "git export" command on all repositories for which
97
+** a Git mirror has been previously established.
98
+**
9699
** info Run the "info" command on all repositories.
97100
**
98101
** pull Run a "pull" operation on all repositories. Only the
99102
** --verbose option is supported.
100103
**
@@ -236,10 +239,23 @@
236239
collect_argument_value(&extra, "ignore");
237240
collect_argument(&extra, "rel-paths",0);
238241
useCheckouts = 1;
239242
stopOnError = 0;
240243
quiet = 1;
244
+ }else if( strncmp(zCmd, "git", n)==0 ){
245
+ if( g.argc<4 ){
246
+ usage("git (export|status)");
247
+ }else{
248
+ int n3 = (int)strlen(g.argv[3]);
249
+ if( strncmp(g.argv[3], "export", n3)==0 ){
250
+ zCmd = "git export --if-mirrored -R";
251
+ }else if( strncmp(g.argv[3], "status", n3)==0 ){
252
+ zCmd = "git status -R";
253
+ }else{
254
+ usage("git (export|status)");
255
+ }
256
+ }
241257
}else if( strncmp(zCmd, "push", n)==0 ){
242258
zCmd = "push -autourl -R";
243259
collect_argument(&extra, "verbose","v");
244260
}else if( strncmp(zCmd, "pull", n)==0 ){
245261
zCmd = "pull -autourl -R";
@@ -358,11 +374,11 @@
358374
zCmd = "cache -R";
359375
showLabel = 1;
360376
collect_argv(&extra, 3);
361377
}else{
362378
fossil_fatal("\"all\" subcommand should be one of: "
363
- "add cache changes clean dbstat extras fts-config ignore "
379
+ "add cache changes clean dbstat extras fts-config git ignore "
364380
"info list ls pull push rebuild server setting sync ui unset");
365381
}
366382
verify_all_options();
367383
db_multi_exec("CREATE TEMP TABLE repolist(name,tag);");
368384
if( useCheckouts ){
369385
--- src/allrepo.c
+++ src/allrepo.c
@@ -91,10 +91,13 @@
91 ** line options supported by the extra command itself, if any
92 ** are present, are passed along verbatim.
93 **
94 ** fts-config Run the "fts-config" command on all repositories.
95 **
 
 
 
96 ** info Run the "info" command on all repositories.
97 **
98 ** pull Run a "pull" operation on all repositories. Only the
99 ** --verbose option is supported.
100 **
@@ -236,10 +239,23 @@
236 collect_argument_value(&extra, "ignore");
237 collect_argument(&extra, "rel-paths",0);
238 useCheckouts = 1;
239 stopOnError = 0;
240 quiet = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
241 }else if( strncmp(zCmd, "push", n)==0 ){
242 zCmd = "push -autourl -R";
243 collect_argument(&extra, "verbose","v");
244 }else if( strncmp(zCmd, "pull", n)==0 ){
245 zCmd = "pull -autourl -R";
@@ -358,11 +374,11 @@
358 zCmd = "cache -R";
359 showLabel = 1;
360 collect_argv(&extra, 3);
361 }else{
362 fossil_fatal("\"all\" subcommand should be one of: "
363 "add cache changes clean dbstat extras fts-config ignore "
364 "info list ls pull push rebuild server setting sync ui unset");
365 }
366 verify_all_options();
367 db_multi_exec("CREATE TEMP TABLE repolist(name,tag);");
368 if( useCheckouts ){
369
--- src/allrepo.c
+++ src/allrepo.c
@@ -91,10 +91,13 @@
91 ** line options supported by the extra command itself, if any
92 ** are present, are passed along verbatim.
93 **
94 ** fts-config Run the "fts-config" command on all repositories.
95 **
96 ** git export Do the "git export" command on all repositories for which
97 ** a Git mirror has been previously established.
98 **
99 ** info Run the "info" command on all repositories.
100 **
101 ** pull Run a "pull" operation on all repositories. Only the
102 ** --verbose option is supported.
103 **
@@ -236,10 +239,23 @@
239 collect_argument_value(&extra, "ignore");
240 collect_argument(&extra, "rel-paths",0);
241 useCheckouts = 1;
242 stopOnError = 0;
243 quiet = 1;
244 }else if( strncmp(zCmd, "git", n)==0 ){
245 if( g.argc<4 ){
246 usage("git (export|status)");
247 }else{
248 int n3 = (int)strlen(g.argv[3]);
249 if( strncmp(g.argv[3], "export", n3)==0 ){
250 zCmd = "git export --if-mirrored -R";
251 }else if( strncmp(g.argv[3], "status", n3)==0 ){
252 zCmd = "git status -R";
253 }else{
254 usage("git (export|status)");
255 }
256 }
257 }else if( strncmp(zCmd, "push", n)==0 ){
258 zCmd = "push -autourl -R";
259 collect_argument(&extra, "verbose","v");
260 }else if( strncmp(zCmd, "pull", n)==0 ){
261 zCmd = "pull -autourl -R";
@@ -358,11 +374,11 @@
374 zCmd = "cache -R";
375 showLabel = 1;
376 collect_argv(&extra, 3);
377 }else{
378 fossil_fatal("\"all\" subcommand should be one of: "
379 "add cache changes clean dbstat extras fts-config git ignore "
380 "info list ls pull push rebuild server setting sync ui unset");
381 }
382 verify_all_options();
383 db_multi_exec("CREATE TEMP TABLE repolist(name,tag);");
384 if( useCheckouts ){
385
--- src/export.c
+++ src/export.c
@@ -1300,10 +1300,11 @@
13001300
double rEnd; /* time of most recent export */
13011301
int rc; /* Result code */
13021302
int bForce; /* Do the export and sync even if no changes*/
13031303
int bNeedRepack = 0; /* True if we should run repack at the end */
13041304
int fManifest; /* Current "manifest" setting */
1305
+ int bIfExists; /* The --if-mirrored flag */
13051306
FILE *xCmd; /* Pipe to the "git fast-import" command */
13061307
FILE *pMarks; /* Git mark files */
13071308
Stmt q; /* Queries */
13081309
char zLine[200]; /* One line of a mark file */
13091310
@@ -1314,10 +1315,11 @@
13141315
nLimit = (unsigned int)atoi(zLimit);
13151316
if( nLimit<=0 ) fossil_fatal("--limit must be positive");
13161317
}
13171318
zAutoPush = find_option("autopush",0,1);
13181319
bForce = find_option("force","f",0)!=0;
1320
+ bIfExists = find_option("if-mirrored",0,0)!=0;
13191321
gitmirror_verbosity = VERB_NORMAL;
13201322
while( find_option("quiet","q",0)!=0 ){ gitmirror_verbosity--; }
13211323
while( find_option("verbose","v",0)!=0 ){ gitmirror_verbosity++; }
13221324
verify_all_options();
13231325
if( g.argc!=4 && g.argc!=3 ){ usage("export ?MIRROR?"); }
@@ -1327,10 +1329,11 @@
13271329
db_set("last-git-export-repo", blob_str(&mirror), 0);
13281330
blob_reset(&mirror);
13291331
}
13301332
zMirror = db_get("last-git-export-repo", 0);
13311333
if( zMirror==0 ){
1334
+ if( bIfExists ) return;
13321335
fossil_fatal("no Git repository specified");
13331336
}
13341337
13351338
/* Make sure the GIT repository directory exists */
13361339
rc = file_mkdir(zMirror, ExtFILE, 0);
@@ -1700,10 +1703,11 @@
17001703
** to the same repository. Or if URL is "off" the
17011704
** auto-push mechanism is disabled
17021705
** --debug FILE Write fast-export text to FILE rather than
17031706
** piping it into "git fast-import".
17041707
** --force|-f Do the export even if nothing has changed
1708
+** --if-mirrored No-op if the mirror does not already exist.
17051709
** --limit N Add no more than N new check-ins to MIRROR.
17061710
** Useful for debugging
17071711
** --quiet|-q Reduce output. Repeat for even less output.
17081712
** --verbose|-v More output.
17091713
**
17101714
--- src/export.c
+++ src/export.c
@@ -1300,10 +1300,11 @@
1300 double rEnd; /* time of most recent export */
1301 int rc; /* Result code */
1302 int bForce; /* Do the export and sync even if no changes*/
1303 int bNeedRepack = 0; /* True if we should run repack at the end */
1304 int fManifest; /* Current "manifest" setting */
 
1305 FILE *xCmd; /* Pipe to the "git fast-import" command */
1306 FILE *pMarks; /* Git mark files */
1307 Stmt q; /* Queries */
1308 char zLine[200]; /* One line of a mark file */
1309
@@ -1314,10 +1315,11 @@
1314 nLimit = (unsigned int)atoi(zLimit);
1315 if( nLimit<=0 ) fossil_fatal("--limit must be positive");
1316 }
1317 zAutoPush = find_option("autopush",0,1);
1318 bForce = find_option("force","f",0)!=0;
 
1319 gitmirror_verbosity = VERB_NORMAL;
1320 while( find_option("quiet","q",0)!=0 ){ gitmirror_verbosity--; }
1321 while( find_option("verbose","v",0)!=0 ){ gitmirror_verbosity++; }
1322 verify_all_options();
1323 if( g.argc!=4 && g.argc!=3 ){ usage("export ?MIRROR?"); }
@@ -1327,10 +1329,11 @@
1327 db_set("last-git-export-repo", blob_str(&mirror), 0);
1328 blob_reset(&mirror);
1329 }
1330 zMirror = db_get("last-git-export-repo", 0);
1331 if( zMirror==0 ){
 
1332 fossil_fatal("no Git repository specified");
1333 }
1334
1335 /* Make sure the GIT repository directory exists */
1336 rc = file_mkdir(zMirror, ExtFILE, 0);
@@ -1700,10 +1703,11 @@
1700 ** to the same repository. Or if URL is "off" the
1701 ** auto-push mechanism is disabled
1702 ** --debug FILE Write fast-export text to FILE rather than
1703 ** piping it into "git fast-import".
1704 ** --force|-f Do the export even if nothing has changed
 
1705 ** --limit N Add no more than N new check-ins to MIRROR.
1706 ** Useful for debugging
1707 ** --quiet|-q Reduce output. Repeat for even less output.
1708 ** --verbose|-v More output.
1709 **
1710
--- src/export.c
+++ src/export.c
@@ -1300,10 +1300,11 @@
1300 double rEnd; /* time of most recent export */
1301 int rc; /* Result code */
1302 int bForce; /* Do the export and sync even if no changes*/
1303 int bNeedRepack = 0; /* True if we should run repack at the end */
1304 int fManifest; /* Current "manifest" setting */
1305 int bIfExists; /* The --if-mirrored flag */
1306 FILE *xCmd; /* Pipe to the "git fast-import" command */
1307 FILE *pMarks; /* Git mark files */
1308 Stmt q; /* Queries */
1309 char zLine[200]; /* One line of a mark file */
1310
@@ -1314,10 +1315,11 @@
1315 nLimit = (unsigned int)atoi(zLimit);
1316 if( nLimit<=0 ) fossil_fatal("--limit must be positive");
1317 }
1318 zAutoPush = find_option("autopush",0,1);
1319 bForce = find_option("force","f",0)!=0;
1320 bIfExists = find_option("if-mirrored",0,0)!=0;
1321 gitmirror_verbosity = VERB_NORMAL;
1322 while( find_option("quiet","q",0)!=0 ){ gitmirror_verbosity--; }
1323 while( find_option("verbose","v",0)!=0 ){ gitmirror_verbosity++; }
1324 verify_all_options();
1325 if( g.argc!=4 && g.argc!=3 ){ usage("export ?MIRROR?"); }
@@ -1327,10 +1329,11 @@
1329 db_set("last-git-export-repo", blob_str(&mirror), 0);
1330 blob_reset(&mirror);
1331 }
1332 zMirror = db_get("last-git-export-repo", 0);
1333 if( zMirror==0 ){
1334 if( bIfExists ) return;
1335 fossil_fatal("no Git repository specified");
1336 }
1337
1338 /* Make sure the GIT repository directory exists */
1339 rc = file_mkdir(zMirror, ExtFILE, 0);
@@ -1700,10 +1703,11 @@
1703 ** to the same repository. Or if URL is "off" the
1704 ** auto-push mechanism is disabled
1705 ** --debug FILE Write fast-export text to FILE rather than
1706 ** piping it into "git fast-import".
1707 ** --force|-f Do the export even if nothing has changed
1708 ** --if-mirrored No-op if the mirror does not already exist.
1709 ** --limit N Add no more than N new check-ins to MIRROR.
1710 ** Useful for debugging
1711 ** --quiet|-q Reduce output. Repeat for even less output.
1712 ** --verbose|-v More output.
1713 **
1714

Keyboard Shortcuts

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