Fossil SCM

Add the --use-author flag to "fossil import --git". Patch from Dingyuan Wang.

drh 2018-02-12 13:01 trunk
Commit fe87e4cb9dc0df125be7d5ef66d9ff8e56092a970b1a88803a1c0b3e91121f7d
1 file changed +9 -2
+9 -2
--- src/import.c
+++ src/import.c
@@ -517,10 +517,11 @@
517517
}
518518
519519
520520
static struct{
521521
const char *zMasterName; /* Name of master branch */
522
+ int authorFlag; /* Use author as checkin committer */
522523
} ggit;
523524
524525
/*
525526
** Read the git-fast-import format from pIn and insert the corresponding
526527
** content into the database.
@@ -619,19 +620,23 @@
619620
gg.aData = 0;
620621
gg.nData = 0;
621622
}
622623
}
623624
}else
624
- if( strncmp(zLine, "author ", 7)==0 ){
625
+ if( (!ggit.authorFlag && strncmp(zLine, "author ", 7)==0)
626
+ || (ggit.authorFlag && strncmp(zLine, "committer ",10)==0
627
+ && gg.zUser!=NULL) ){
625628
/* No-op */
626629
}else
627630
if( strncmp(zLine, "mark ", 5)==0 ){
628631
trim_newline(&zLine[5]);
629632
fossil_free(gg.zMark);
630633
gg.zMark = fossil_strdup(&zLine[5]);
631634
}else
632
- if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
635
+ if( strncmp(zLine, "tagger ", 7)==0
636
+ || (ggit.authorFlag && strncmp(zLine, "author ", 7)==0)
637
+ || strncmp(zLine, "committer ",10)==0 ){
633638
sqlite3_int64 secSince1970;
634639
z = strchr(zLine, ' ');
635640
while( fossil_isspace(*z) ) z++;
636641
if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
637642
*(++zTo) = '\0';
@@ -1603,10 +1608,11 @@
16031608
** --git Import from the git-fast-export file format (default)
16041609
** Options:
16051610
** --import-marks FILE Restore marks table from FILE
16061611
** --export-marks FILE Save marks table to FILE
16071612
** --rename-master NAME Renames the master branch to NAME
1613
+** --use-author Uses author as the committer
16081614
**
16091615
** --svn Import from the svnadmin-dump file format. The default
16101616
** behaviour (unless overridden by --flat) is to treat 3
16111617
** folders in the SVN root as special, following the
16121618
** common layout of SVN repositories. These are (by
@@ -1727,10 +1733,11 @@
17271733
markfile_in = find_option("import-marks", 0, 1);
17281734
markfile_out = find_option("export-marks", 0, 1);
17291735
if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
17301736
ggit.zMasterName = "master";
17311737
}
1738
+ ggit.authorFlag = find_option("use-author", 0, 0)!=0;
17321739
}
17331740
verify_all_options();
17341741
17351742
if( g.argc!=3 && g.argc!=4 ){
17361743
usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
17371744
--- src/import.c
+++ src/import.c
@@ -517,10 +517,11 @@
517 }
518
519
520 static struct{
521 const char *zMasterName; /* Name of master branch */
 
522 } ggit;
523
524 /*
525 ** Read the git-fast-import format from pIn and insert the corresponding
526 ** content into the database.
@@ -619,19 +620,23 @@
619 gg.aData = 0;
620 gg.nData = 0;
621 }
622 }
623 }else
624 if( strncmp(zLine, "author ", 7)==0 ){
 
 
625 /* No-op */
626 }else
627 if( strncmp(zLine, "mark ", 5)==0 ){
628 trim_newline(&zLine[5]);
629 fossil_free(gg.zMark);
630 gg.zMark = fossil_strdup(&zLine[5]);
631 }else
632 if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
 
 
633 sqlite3_int64 secSince1970;
634 z = strchr(zLine, ' ');
635 while( fossil_isspace(*z) ) z++;
636 if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
637 *(++zTo) = '\0';
@@ -1603,10 +1608,11 @@
1603 ** --git Import from the git-fast-export file format (default)
1604 ** Options:
1605 ** --import-marks FILE Restore marks table from FILE
1606 ** --export-marks FILE Save marks table to FILE
1607 ** --rename-master NAME Renames the master branch to NAME
 
1608 **
1609 ** --svn Import from the svnadmin-dump file format. The default
1610 ** behaviour (unless overridden by --flat) is to treat 3
1611 ** folders in the SVN root as special, following the
1612 ** common layout of SVN repositories. These are (by
@@ -1727,10 +1733,11 @@
1727 markfile_in = find_option("import-marks", 0, 1);
1728 markfile_out = find_option("export-marks", 0, 1);
1729 if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
1730 ggit.zMasterName = "master";
1731 }
 
1732 }
1733 verify_all_options();
1734
1735 if( g.argc!=3 && g.argc!=4 ){
1736 usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
1737
--- src/import.c
+++ src/import.c
@@ -517,10 +517,11 @@
517 }
518
519
520 static struct{
521 const char *zMasterName; /* Name of master branch */
522 int authorFlag; /* Use author as checkin committer */
523 } ggit;
524
525 /*
526 ** Read the git-fast-import format from pIn and insert the corresponding
527 ** content into the database.
@@ -619,19 +620,23 @@
620 gg.aData = 0;
621 gg.nData = 0;
622 }
623 }
624 }else
625 if( (!ggit.authorFlag && strncmp(zLine, "author ", 7)==0)
626 || (ggit.authorFlag && strncmp(zLine, "committer ",10)==0
627 && gg.zUser!=NULL) ){
628 /* No-op */
629 }else
630 if( strncmp(zLine, "mark ", 5)==0 ){
631 trim_newline(&zLine[5]);
632 fossil_free(gg.zMark);
633 gg.zMark = fossil_strdup(&zLine[5]);
634 }else
635 if( strncmp(zLine, "tagger ", 7)==0
636 || (ggit.authorFlag && strncmp(zLine, "author ", 7)==0)
637 || strncmp(zLine, "committer ",10)==0 ){
638 sqlite3_int64 secSince1970;
639 z = strchr(zLine, ' ');
640 while( fossil_isspace(*z) ) z++;
641 if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line;
642 *(++zTo) = '\0';
@@ -1603,10 +1608,11 @@
1608 ** --git Import from the git-fast-export file format (default)
1609 ** Options:
1610 ** --import-marks FILE Restore marks table from FILE
1611 ** --export-marks FILE Save marks table to FILE
1612 ** --rename-master NAME Renames the master branch to NAME
1613 ** --use-author Uses author as the committer
1614 **
1615 ** --svn Import from the svnadmin-dump file format. The default
1616 ** behaviour (unless overridden by --flat) is to treat 3
1617 ** folders in the SVN root as special, following the
1618 ** common layout of SVN repositories. These are (by
@@ -1727,10 +1733,11 @@
1733 markfile_in = find_option("import-marks", 0, 1);
1734 markfile_out = find_option("export-marks", 0, 1);
1735 if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){
1736 ggit.zMasterName = "master";
1737 }
1738 ggit.authorFlag = find_option("use-author", 0, 0)!=0;
1739 }
1740 verify_all_options();
1741
1742 if( g.argc!=3 && g.argc!=4 ){
1743 usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?");
1744

Keyboard Shortcuts

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