Fossil SCM

Add --rename-trunk option to export instead of forcing a naming convention.

roy.marples 2017-02-10 20:28 UTC roy-export
Commit bc443729a0ae46aaaf03b1a92a379237d8dca44e
1 file changed +13 -2
+13 -2
--- src/export.c
+++ src/export.c
@@ -19,10 +19,17 @@
1919
*/
2020
#include "config.h"
2121
#include "export.h"
2222
#include <assert.h>
2323
24
+/*
25
+** State information common to all export types.
26
+*/
27
+static struct {
28
+ const char *zTrunkName; /* Name of trunk branch */
29
+} gexport;
30
+
2431
#if INTERFACE
2532
/*
2633
** struct mark_t
2734
** holds information for translating between git commits
2835
** and fossil commits.
@@ -471,10 +478,11 @@
471478
** blobs written on exit for use with "--import-marks" on the next run.
472479
**
473480
** Options:
474481
** --export-marks FILE export rids of exported data to FILE
475482
** --import-marks FILE read rids of data to ignore from FILE
483
+** --rename-trunk NAME use NAME as name of exported trunk branch
476484
** --repository|-R REPOSITORY export the given REPOSITORY
477485
**
478486
** See also: import
479487
*/
480488
void export_cmd(void){
@@ -489,10 +497,14 @@
489497
bag_init(&vers);
490498
491499
find_option("git", 0, 0); /* Ignore the --git option for now */
492500
markfile_in = find_option("import-marks", 0, 1);
493501
markfile_out = find_option("export-marks", 0, 1);
502
+
503
+ if( !(gexport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
504
+ gexport.zTrunkName = "trunk";
505
+ }
494506
495507
db_find_and_open_repository(0, 2);
496508
verify_all_options();
497509
if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); }
498510
@@ -611,12 +623,11 @@
611623
612624
bag_insert(&vers, ckinId);
613625
db_bind_int(&q2, ":rid", ckinId);
614626
db_step(&q2);
615627
db_reset(&q2);
616
- /* fossil trunk is git master. */
617
- if( zBranch==0 || fossil_strcmp(zBranch, "trunk")==0 ) zBranch = "master";
628
+ if( zBranch==0 || fossil_strcmp(zBranch, "trunk")==0 ) zBranch = gexport.zTrunkName;
618629
zMark = mark_name_from_rid(ckinId, &unused_mark);
619630
printf("commit refs/heads/");
620631
print_ref(zBranch);
621632
printf("\nmark %s\n", zMark);
622633
free(zMark);
623634
--- src/export.c
+++ src/export.c
@@ -19,10 +19,17 @@
19 */
20 #include "config.h"
21 #include "export.h"
22 #include <assert.h>
23
 
 
 
 
 
 
 
24 #if INTERFACE
25 /*
26 ** struct mark_t
27 ** holds information for translating between git commits
28 ** and fossil commits.
@@ -471,10 +478,11 @@
471 ** blobs written on exit for use with "--import-marks" on the next run.
472 **
473 ** Options:
474 ** --export-marks FILE export rids of exported data to FILE
475 ** --import-marks FILE read rids of data to ignore from FILE
 
476 ** --repository|-R REPOSITORY export the given REPOSITORY
477 **
478 ** See also: import
479 */
480 void export_cmd(void){
@@ -489,10 +497,14 @@
489 bag_init(&vers);
490
491 find_option("git", 0, 0); /* Ignore the --git option for now */
492 markfile_in = find_option("import-marks", 0, 1);
493 markfile_out = find_option("export-marks", 0, 1);
 
 
 
 
494
495 db_find_and_open_repository(0, 2);
496 verify_all_options();
497 if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); }
498
@@ -611,12 +623,11 @@
611
612 bag_insert(&vers, ckinId);
613 db_bind_int(&q2, ":rid", ckinId);
614 db_step(&q2);
615 db_reset(&q2);
616 /* fossil trunk is git master. */
617 if( zBranch==0 || fossil_strcmp(zBranch, "trunk")==0 ) zBranch = "master";
618 zMark = mark_name_from_rid(ckinId, &unused_mark);
619 printf("commit refs/heads/");
620 print_ref(zBranch);
621 printf("\nmark %s\n", zMark);
622 free(zMark);
623
--- src/export.c
+++ src/export.c
@@ -19,10 +19,17 @@
19 */
20 #include "config.h"
21 #include "export.h"
22 #include <assert.h>
23
24 /*
25 ** State information common to all export types.
26 */
27 static struct {
28 const char *zTrunkName; /* Name of trunk branch */
29 } gexport;
30
31 #if INTERFACE
32 /*
33 ** struct mark_t
34 ** holds information for translating between git commits
35 ** and fossil commits.
@@ -471,10 +478,11 @@
478 ** blobs written on exit for use with "--import-marks" on the next run.
479 **
480 ** Options:
481 ** --export-marks FILE export rids of exported data to FILE
482 ** --import-marks FILE read rids of data to ignore from FILE
483 ** --rename-trunk NAME use NAME as name of exported trunk branch
484 ** --repository|-R REPOSITORY export the given REPOSITORY
485 **
486 ** See also: import
487 */
488 void export_cmd(void){
@@ -489,10 +497,14 @@
497 bag_init(&vers);
498
499 find_option("git", 0, 0); /* Ignore the --git option for now */
500 markfile_in = find_option("import-marks", 0, 1);
501 markfile_out = find_option("export-marks", 0, 1);
502
503 if( !(gexport.zTrunkName = find_option("rename-trunk", 0, 1)) ){
504 gexport.zTrunkName = "trunk";
505 }
506
507 db_find_and_open_repository(0, 2);
508 verify_all_options();
509 if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); }
510
@@ -611,12 +623,11 @@
623
624 bag_insert(&vers, ckinId);
625 db_bind_int(&q2, ":rid", ckinId);
626 db_step(&q2);
627 db_reset(&q2);
628 if( zBranch==0 || fossil_strcmp(zBranch, "trunk")==0 ) zBranch = gexport.zTrunkName;
 
629 zMark = mark_name_from_rid(ckinId, &unused_mark);
630 printf("commit refs/heads/");
631 print_ref(zBranch);
632 printf("\nmark %s\n", zMark);
633 free(zMark);
634

Keyboard Shortcuts

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