Fossil SCM
Add the --use-author flag to "fossil import --git". Patch from Dingyuan Wang.
Commit
fe87e4cb9dc0df125be7d5ef66d9ff8e56092a970b1a88803a1c0b3e91121f7d
Parent
ceba488122551b4…
1 file changed
+9
-2
+9
-2
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -517,10 +517,11 @@ | ||
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | |
| 520 | 520 | static struct{ |
| 521 | 521 | const char *zMasterName; /* Name of master branch */ |
| 522 | + int authorFlag; /* Use author as checkin committer */ | |
| 522 | 523 | } ggit; |
| 523 | 524 | |
| 524 | 525 | /* |
| 525 | 526 | ** Read the git-fast-import format from pIn and insert the corresponding |
| 526 | 527 | ** content into the database. |
| @@ -619,19 +620,23 @@ | ||
| 619 | 620 | gg.aData = 0; |
| 620 | 621 | gg.nData = 0; |
| 621 | 622 | } |
| 622 | 623 | } |
| 623 | 624 | }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) ){ | |
| 625 | 628 | /* No-op */ |
| 626 | 629 | }else |
| 627 | 630 | if( strncmp(zLine, "mark ", 5)==0 ){ |
| 628 | 631 | trim_newline(&zLine[5]); |
| 629 | 632 | fossil_free(gg.zMark); |
| 630 | 633 | gg.zMark = fossil_strdup(&zLine[5]); |
| 631 | 634 | }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 ){ | |
| 633 | 638 | sqlite3_int64 secSince1970; |
| 634 | 639 | z = strchr(zLine, ' '); |
| 635 | 640 | while( fossil_isspace(*z) ) z++; |
| 636 | 641 | if( (zTo=strchr(z, '>'))==NULL ) goto malformed_line; |
| 637 | 642 | *(++zTo) = '\0'; |
| @@ -1603,10 +1608,11 @@ | ||
| 1603 | 1608 | ** --git Import from the git-fast-export file format (default) |
| 1604 | 1609 | ** Options: |
| 1605 | 1610 | ** --import-marks FILE Restore marks table from FILE |
| 1606 | 1611 | ** --export-marks FILE Save marks table to FILE |
| 1607 | 1612 | ** --rename-master NAME Renames the master branch to NAME |
| 1613 | +** --use-author Uses author as the committer | |
| 1608 | 1614 | ** |
| 1609 | 1615 | ** --svn Import from the svnadmin-dump file format. The default |
| 1610 | 1616 | ** behaviour (unless overridden by --flat) is to treat 3 |
| 1611 | 1617 | ** folders in the SVN root as special, following the |
| 1612 | 1618 | ** common layout of SVN repositories. These are (by |
| @@ -1727,10 +1733,11 @@ | ||
| 1727 | 1733 | markfile_in = find_option("import-marks", 0, 1); |
| 1728 | 1734 | markfile_out = find_option("export-marks", 0, 1); |
| 1729 | 1735 | if( !(ggit.zMasterName = find_option("rename-master", 0, 1)) ){ |
| 1730 | 1736 | ggit.zMasterName = "master"; |
| 1731 | 1737 | } |
| 1738 | + ggit.authorFlag = find_option("use-author", 0, 0)!=0; | |
| 1732 | 1739 | } |
| 1733 | 1740 | verify_all_options(); |
| 1734 | 1741 | |
| 1735 | 1742 | if( g.argc!=3 && g.argc!=4 ){ |
| 1736 | 1743 | usage("--git|--svn ?OPTIONS? NEW-REPOSITORY ?INPUT-FILE?"); |
| 1737 | 1744 |
| --- 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 |