Fossil SCM
Add --rename-trunk option to export instead of forcing a naming convention.
Commit
bc443729a0ae46aaaf03b1a92a379237d8dca44e
Parent
8e7079731eea4ba…
1 file changed
+13
-2
+13
-2
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -19,10 +19,17 @@ | ||
| 19 | 19 | */ |
| 20 | 20 | #include "config.h" |
| 21 | 21 | #include "export.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 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 | + | |
| 24 | 31 | #if INTERFACE |
| 25 | 32 | /* |
| 26 | 33 | ** struct mark_t |
| 27 | 34 | ** holds information for translating between git commits |
| 28 | 35 | ** and fossil commits. |
| @@ -471,10 +478,11 @@ | ||
| 471 | 478 | ** blobs written on exit for use with "--import-marks" on the next run. |
| 472 | 479 | ** |
| 473 | 480 | ** Options: |
| 474 | 481 | ** --export-marks FILE export rids of exported data to FILE |
| 475 | 482 | ** --import-marks FILE read rids of data to ignore from FILE |
| 483 | +** --rename-trunk NAME use NAME as name of exported trunk branch | |
| 476 | 484 | ** --repository|-R REPOSITORY export the given REPOSITORY |
| 477 | 485 | ** |
| 478 | 486 | ** See also: import |
| 479 | 487 | */ |
| 480 | 488 | void export_cmd(void){ |
| @@ -489,10 +497,14 @@ | ||
| 489 | 497 | bag_init(&vers); |
| 490 | 498 | |
| 491 | 499 | find_option("git", 0, 0); /* Ignore the --git option for now */ |
| 492 | 500 | markfile_in = find_option("import-marks", 0, 1); |
| 493 | 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 | + } | |
| 494 | 506 | |
| 495 | 507 | db_find_and_open_repository(0, 2); |
| 496 | 508 | verify_all_options(); |
| 497 | 509 | if( g.argc!=2 && g.argc!=3 ){ usage("--git ?REPOSITORY?"); } |
| 498 | 510 | |
| @@ -611,12 +623,11 @@ | ||
| 611 | 623 | |
| 612 | 624 | bag_insert(&vers, ckinId); |
| 613 | 625 | db_bind_int(&q2, ":rid", ckinId); |
| 614 | 626 | db_step(&q2); |
| 615 | 627 | 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; | |
| 618 | 629 | zMark = mark_name_from_rid(ckinId, &unused_mark); |
| 619 | 630 | printf("commit refs/heads/"); |
| 620 | 631 | print_ref(zBranch); |
| 621 | 632 | printf("\nmark %s\n", zMark); |
| 622 | 633 | free(zMark); |
| 623 | 634 |
| --- 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 |