Fossil SCM

Add --rename-master option to import --git instead of forcing a naming convention.

roy.marples 2017-02-10 22:04 UTC roy-export
Commit 50705503d94438068c5691162e38dbf0585362b5
1 file changed +17 -8
+17 -8
--- src/import.c
+++ src/import.c
@@ -513,10 +513,14 @@
513513
}
514514
zName[i] = 0;
515515
}
516516
517517
518
+static struct{
519
+ const char *zMasterName; /* Name of master branch */
520
+} ggit;
521
+
518522
/*
519523
** Read the git-fast-import format from pIn and insert the corresponding
520524
** content into the database.
521525
*/
522526
static void git_fast_import(FILE *pIn){
@@ -536,14 +540,15 @@
536540
if( strncmp(zLine, "blob", 4)==0 ){
537541
gg.xFinish();
538542
gg.xFinish = finish_blob;
539543
}else
540544
if( strncmp(zLine, "commit ", 7)==0 ){
545
+ const char *zRefName;
541546
gg.xFinish();
542547
gg.xFinish = finish_commit;
543548
trim_newline(&zLine[7]);
544
- z = &zLine[7];
549
+ zRefName = &zLine[7];
545550
546551
/* The argument to the "commit" line might match either of these
547552
** patterns:
548553
**
549554
** (A) refs/heads/BRANCHNAME
@@ -559,15 +564,15 @@
559564
** last commit that holds that tag.
560565
**
561566
** None of the above is explained in the git-fast-export
562567
** documentation. We had to figure it out via trial and error.
563568
*/
564
- for(i=5; i<strlen(z) && z[i]!='/'; i++){}
565
- gg.tagCommit = strncmp(&z[5], "tags", 4)==0; /* True for pattern B */
566
- if( z[i+1]!=0 ) z += i+1;
567
- if( fossil_strcmp(z, "master")==0 ) z = "trunk";
568
- gg.zBranch = fossil_strdup(z);
569
+ for(i=5; i<strlen(zRefName) && zRefName[i]!='/'; i++){}
570
+ gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* True for pattern B */
571
+ if( zRefName[i+1]!=0 ) zRefName += i+1;
572
+ if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
573
+ gg.zBranch = fossil_strdup(zRefName);
569574
gg.fromLoaded = 0;
570575
}else
571576
if( strncmp(zLine, "tag ", 4)==0 ){
572577
gg.xFinish();
573578
gg.xFinish = finish_tag;
@@ -1545,12 +1550,13 @@
15451550
**
15461551
** The following formats are currently understood by this command
15471552
**
15481553
** --git Import from the git-fast-export file format (default)
15491554
** Options:
1550
-** --import-marks FILE Restore marks table from FILE
1551
-** --export-marks FILE Save marks table to FILE
1555
+** --import-marks FILE Restore marks table from FILE
1556
+** --export-marks FILE Save marks table to FILE
1557
+** --rename-master NAME Renames the master branch to NAME
15521558
**
15531559
** --svn Import from the svnadmin-dump file format. The default
15541560
** behaviour (unless overridden by --flat) is to treat 3
15551561
** folders in the SVN root as special, following the
15561562
** common layout of SVN repositories. These are (by
@@ -1668,10 +1674,13 @@
16681674
gsvn.revFlag = find_option("rev-tags", 0, 0)
16691675
|| (incrFlag && !find_option("no-rev-tags", 0, 0));
16701676
}else if( gitFlag ){
16711677
markfile_in = find_option("import-marks", 0, 1);
16721678
markfile_out = find_option("export-marks", 0, 1);
1679
+ if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
1680
+ ggit.zMasterName = "master";
1681
+ }
16731682
}
16741683
verify_all_options();
16751684
16761685
if( g.argc!=3 && g.argc!=4 ){
16771686
usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
16781687
--- src/import.c
+++ src/import.c
@@ -513,10 +513,14 @@
513 }
514 zName[i] = 0;
515 }
516
517
 
 
 
 
518 /*
519 ** Read the git-fast-import format from pIn and insert the corresponding
520 ** content into the database.
521 */
522 static void git_fast_import(FILE *pIn){
@@ -536,14 +540,15 @@
536 if( strncmp(zLine, "blob", 4)==0 ){
537 gg.xFinish();
538 gg.xFinish = finish_blob;
539 }else
540 if( strncmp(zLine, "commit ", 7)==0 ){
 
541 gg.xFinish();
542 gg.xFinish = finish_commit;
543 trim_newline(&zLine[7]);
544 z = &zLine[7];
545
546 /* The argument to the "commit" line might match either of these
547 ** patterns:
548 **
549 ** (A) refs/heads/BRANCHNAME
@@ -559,15 +564,15 @@
559 ** last commit that holds that tag.
560 **
561 ** None of the above is explained in the git-fast-export
562 ** documentation. We had to figure it out via trial and error.
563 */
564 for(i=5; i<strlen(z) && z[i]!='/'; i++){}
565 gg.tagCommit = strncmp(&z[5], "tags", 4)==0; /* True for pattern B */
566 if( z[i+1]!=0 ) z += i+1;
567 if( fossil_strcmp(z, "master")==0 ) z = "trunk";
568 gg.zBranch = fossil_strdup(z);
569 gg.fromLoaded = 0;
570 }else
571 if( strncmp(zLine, "tag ", 4)==0 ){
572 gg.xFinish();
573 gg.xFinish = finish_tag;
@@ -1545,12 +1550,13 @@
1545 **
1546 ** The following formats are currently understood by this command
1547 **
1548 ** --git Import from the git-fast-export file format (default)
1549 ** Options:
1550 ** --import-marks FILE Restore marks table from FILE
1551 ** --export-marks FILE Save marks table to FILE
 
1552 **
1553 ** --svn Import from the svnadmin-dump file format. The default
1554 ** behaviour (unless overridden by --flat) is to treat 3
1555 ** folders in the SVN root as special, following the
1556 ** common layout of SVN repositories. These are (by
@@ -1668,10 +1674,13 @@
1668 gsvn.revFlag = find_option("rev-tags", 0, 0)
1669 || (incrFlag && !find_option("no-rev-tags", 0, 0));
1670 }else if( gitFlag ){
1671 markfile_in = find_option("import-marks", 0, 1);
1672 markfile_out = find_option("export-marks", 0, 1);
 
 
 
1673 }
1674 verify_all_options();
1675
1676 if( g.argc!=3 && g.argc!=4 ){
1677 usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
1678
--- src/import.c
+++ src/import.c
@@ -513,10 +513,14 @@
513 }
514 zName[i] = 0;
515 }
516
517
518 static struct{
519 const char *zMasterName; /* Name of master branch */
520 } ggit;
521
522 /*
523 ** Read the git-fast-import format from pIn and insert the corresponding
524 ** content into the database.
525 */
526 static void git_fast_import(FILE *pIn){
@@ -536,14 +540,15 @@
540 if( strncmp(zLine, "blob", 4)==0 ){
541 gg.xFinish();
542 gg.xFinish = finish_blob;
543 }else
544 if( strncmp(zLine, "commit ", 7)==0 ){
545 const char *zRefName;
546 gg.xFinish();
547 gg.xFinish = finish_commit;
548 trim_newline(&zLine[7]);
549 zRefName = &zLine[7];
550
551 /* The argument to the "commit" line might match either of these
552 ** patterns:
553 **
554 ** (A) refs/heads/BRANCHNAME
@@ -559,15 +564,15 @@
564 ** last commit that holds that tag.
565 **
566 ** None of the above is explained in the git-fast-export
567 ** documentation. We had to figure it out via trial and error.
568 */
569 for(i=5; i<strlen(zRefName) && zRefName[i]!='/'; i++){}
570 gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* True for pattern B */
571 if( zRefName[i+1]!=0 ) zRefName += i+1;
572 if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
573 gg.zBranch = fossil_strdup(zRefName);
574 gg.fromLoaded = 0;
575 }else
576 if( strncmp(zLine, "tag ", 4)==0 ){
577 gg.xFinish();
578 gg.xFinish = finish_tag;
@@ -1545,12 +1550,13 @@
1550 **
1551 ** The following formats are currently understood by this command
1552 **
1553 ** --git Import from the git-fast-export file format (default)
1554 ** Options:
1555 ** --import-marks FILE Restore marks table from FILE
1556 ** --export-marks FILE Save marks table to FILE
1557 ** --rename-master NAME Renames the master branch to NAME
1558 **
1559 ** --svn Import from the svnadmin-dump file format. The default
1560 ** behaviour (unless overridden by --flat) is to treat 3
1561 ** folders in the SVN root as special, following the
1562 ** common layout of SVN repositories. These are (by
@@ -1668,10 +1674,13 @@
1674 gsvn.revFlag = find_option("rev-tags", 0, 0)
1675 || (incrFlag && !find_option("no-rev-tags", 0, 0));
1676 }else if( gitFlag ){
1677 markfile_in = find_option("import-marks", 0, 1);
1678 markfile_out = find_option("export-marks", 0, 1);
1679 if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
1680 ggit.zMasterName = "master";
1681 }
1682 }
1683 verify_all_options();
1684
1685 if( g.argc!=3 && g.argc!=4 ){
1686 usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
1687

Keyboard Shortcuts

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