Fossil SCM
Additional comments on the changes to deal with git-fast-export tagging, to try to better explain what Git is doing and how we are working around it.
Commit
352066b267c392ff958628a99cc99896dd055b8c
Parent
4dcd9c9923cd400…
1 file changed
+24
-3
+24
-3
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -450,12 +450,31 @@ | ||
| 450 | 450 | if( memcmp(zLine, "commit ", 7)==0 ){ |
| 451 | 451 | gg.xFinish(); |
| 452 | 452 | gg.xFinish = finish_commit; |
| 453 | 453 | trim_newline(&zLine[7]); |
| 454 | 454 | z = &zLine[7]; |
| 455 | + | |
| 456 | + /* The argument to the "commit" line might match either of these | |
| 457 | + ** patterns: | |
| 458 | + ** | |
| 459 | + ** (A) refs/heads/BRANCHNAME | |
| 460 | + ** (B) refs/tags/TAGNAME | |
| 461 | + ** | |
| 462 | + ** If pattern A is used, then the branchname used is as shown. | |
| 463 | + ** Except, the "master" branch which is the default branch name in | |
| 464 | + ** Git is changed to "trunk" which is the default name in Fossil. | |
| 465 | + ** If the pattern is B, then the new commit should be on the same | |
| 466 | + ** branch as its parent. And, we might need to add the TAGNAME | |
| 467 | + ** tag to the new commit. However, if there are multiple instances | |
| 468 | + ** of pattern B with the same TAGNAME, then only put the tag on the | |
| 469 | + ** last commit that holds that tag. | |
| 470 | + ** | |
| 471 | + ** None of the above is explained in the git-fast-export | |
| 472 | + ** documentation. We had to figure it out via trial and error. | |
| 473 | + */ | |
| 455 | 474 | for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){} |
| 456 | - gg.tagCommit = memcmp(&z[i-4], "tags", 4)==0; | |
| 475 | + gg.tagCommit = memcmp(&z[i-4], "tags", 4)==0; /* True for pattern B */ | |
| 457 | 476 | if( z[i+1]!=0 ) z += i+1; |
| 458 | 477 | if( fossil_strcmp(z, "master")==0 ) z = "trunk"; |
| 459 | 478 | gg.zBranch = fossil_strdup(z); |
| 460 | 479 | gg.fromLoaded = 0; |
| 461 | 480 | }else |
| @@ -688,16 +707,18 @@ | ||
| 688 | 707 | ** Given any valid fast-import symbol, the corresponding fossil rid and |
| 689 | 708 | ** uuid can found by searching against the xmark.tname field. |
| 690 | 709 | ** |
| 691 | 710 | ** The XBRANCH table maps commit marks and symbols into the branch those |
| 692 | 711 | ** commits belong to. If xbranch.tname is a fast-import symbol for a |
| 693 | - ** check-in then xbranch.brnm is the branch that checkin is part of. | |
| 712 | + ** checkin then xbranch.brnm is the branch that checkin is part of. | |
| 694 | 713 | ** |
| 695 | 714 | ** The XTAG table records information about tags that need to be applied |
| 696 | 715 | ** to various branches after the import finishes. The xtag.tcontent field |
| 697 | 716 | ** contains the text of an artifact that will add a tag to a check-in. |
| 698 | - ** These artifacts should all be added at the end of the import. | |
| 717 | + ** The git-fast-export file format might specify the same tag multiple | |
| 718 | + ** times but only the last tag should be used. And we do not know which | |
| 719 | + ** occurrence of the tag is the last until the import finishes. | |
| 699 | 720 | */ |
| 700 | 721 | db_multi_exec( |
| 701 | 722 | "CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT);" |
| 702 | 723 | "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);" |
| 703 | 724 | "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);" |
| 704 | 725 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -450,12 +450,31 @@ | |
| 450 | if( memcmp(zLine, "commit ", 7)==0 ){ |
| 451 | gg.xFinish(); |
| 452 | gg.xFinish = finish_commit; |
| 453 | trim_newline(&zLine[7]); |
| 454 | z = &zLine[7]; |
| 455 | for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){} |
| 456 | gg.tagCommit = memcmp(&z[i-4], "tags", 4)==0; |
| 457 | if( z[i+1]!=0 ) z += i+1; |
| 458 | if( fossil_strcmp(z, "master")==0 ) z = "trunk"; |
| 459 | gg.zBranch = fossil_strdup(z); |
| 460 | gg.fromLoaded = 0; |
| 461 | }else |
| @@ -688,16 +707,18 @@ | |
| 688 | ** Given any valid fast-import symbol, the corresponding fossil rid and |
| 689 | ** uuid can found by searching against the xmark.tname field. |
| 690 | ** |
| 691 | ** The XBRANCH table maps commit marks and symbols into the branch those |
| 692 | ** commits belong to. If xbranch.tname is a fast-import symbol for a |
| 693 | ** check-in then xbranch.brnm is the branch that checkin is part of. |
| 694 | ** |
| 695 | ** The XTAG table records information about tags that need to be applied |
| 696 | ** to various branches after the import finishes. The xtag.tcontent field |
| 697 | ** contains the text of an artifact that will add a tag to a check-in. |
| 698 | ** These artifacts should all be added at the end of the import. |
| 699 | */ |
| 700 | db_multi_exec( |
| 701 | "CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT);" |
| 702 | "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);" |
| 703 | "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);" |
| 704 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -450,12 +450,31 @@ | |
| 450 | if( memcmp(zLine, "commit ", 7)==0 ){ |
| 451 | gg.xFinish(); |
| 452 | gg.xFinish = finish_commit; |
| 453 | trim_newline(&zLine[7]); |
| 454 | z = &zLine[7]; |
| 455 | |
| 456 | /* The argument to the "commit" line might match either of these |
| 457 | ** patterns: |
| 458 | ** |
| 459 | ** (A) refs/heads/BRANCHNAME |
| 460 | ** (B) refs/tags/TAGNAME |
| 461 | ** |
| 462 | ** If pattern A is used, then the branchname used is as shown. |
| 463 | ** Except, the "master" branch which is the default branch name in |
| 464 | ** Git is changed to "trunk" which is the default name in Fossil. |
| 465 | ** If the pattern is B, then the new commit should be on the same |
| 466 | ** branch as its parent. And, we might need to add the TAGNAME |
| 467 | ** tag to the new commit. However, if there are multiple instances |
| 468 | ** of pattern B with the same TAGNAME, then only put the tag on the |
| 469 | ** last commit that holds that tag. |
| 470 | ** |
| 471 | ** None of the above is explained in the git-fast-export |
| 472 | ** documentation. We had to figure it out via trial and error. |
| 473 | */ |
| 474 | for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){} |
| 475 | gg.tagCommit = memcmp(&z[i-4], "tags", 4)==0; /* True for pattern B */ |
| 476 | if( z[i+1]!=0 ) z += i+1; |
| 477 | if( fossil_strcmp(z, "master")==0 ) z = "trunk"; |
| 478 | gg.zBranch = fossil_strdup(z); |
| 479 | gg.fromLoaded = 0; |
| 480 | }else |
| @@ -688,16 +707,18 @@ | |
| 707 | ** Given any valid fast-import symbol, the corresponding fossil rid and |
| 708 | ** uuid can found by searching against the xmark.tname field. |
| 709 | ** |
| 710 | ** The XBRANCH table maps commit marks and symbols into the branch those |
| 711 | ** commits belong to. If xbranch.tname is a fast-import symbol for a |
| 712 | ** checkin then xbranch.brnm is the branch that checkin is part of. |
| 713 | ** |
| 714 | ** The XTAG table records information about tags that need to be applied |
| 715 | ** to various branches after the import finishes. The xtag.tcontent field |
| 716 | ** contains the text of an artifact that will add a tag to a check-in. |
| 717 | ** The git-fast-export file format might specify the same tag multiple |
| 718 | ** times but only the last tag should be used. And we do not know which |
| 719 | ** occurrence of the tag is the last until the import finishes. |
| 720 | */ |
| 721 | db_multi_exec( |
| 722 | "CREATE TEMP TABLE xmark(tname TEXT UNIQUE, trid INT, tuuid TEXT);" |
| 723 | "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);" |
| 724 | "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);" |
| 725 |