importing from git: a couple of bugs
(1) By James Cook (falsifian) on 2023-07-12 11:54:35 [source]
None of this is blocking me, but I'm posting these notes in case they're useful to someone who wants to improve the import command. Everything can be worked around.
First bug: Mysterious empty branch name
Import this simple repo with two commits on master:
fossil import test0.fossil <<EOF
blob
mark :1
data 8
content
reset refs/heads/master
commit refs/heads/master
mark :2
author James Cook <falsifian@falsifian.org> 1689159522 +0000
committer James Cook <falsifian@falsifian.org> 1689159522 +0000
data 16
Initial commit.
M 100644 :1 file
blob
mark :3
data 12
new content
commit refs/heads/master
mark :4
author James Cook <falsifian@falsifian.org> 1689159533 +0000
committer James Cook <falsifian@falsifian.org> 1689159533 +0000
data 8
Change.
from :2
M 100644 :3 file
EOF
The timeline shows "Initial commit" on the branch "trunk", but "Change" branching off to another branch with "tags: , trunk". Looking at tags for that "Change" check-in using the fossil UI, I see:
- branch= propagates to descendants
- sym- propagates to descendants
- sym-trunk inherited from [0f7e0a7059]
(Workaround: fossil amend -R test.fossil 83aca6b --branch trunk
. However that leads to redundant sym-trunk and branch=trunk tags appearing on that commit; not sure if there's a downside to that.)
Second bug: Without a master branch, commits get both sym-trunk and sym-(whatever branch) at the same time
Here's the same import as before, but the branch is named "notmaster":
fossil import test1.fossil <<EOF
blob
mark :1
data 8
content
reset refs/heads/notmaster
commit refs/heads/notmaster
mark :2
author James Cook <falsifian@falsifian.org> 1689159522 +0000
committer James Cook <falsifian@falsifian.org> 1689159522 +0000
data 16
Initial commit.
M 100644 :1 file
blob
mark :3
data 12
new content
commit refs/heads/notmaster
mark :4
author James Cook <falsifian@falsifian.org> 1689159533 +0000
committer James Cook <falsifian@falsifian.org> 1689159533 +0000
data 8
Change.
from :2
M 100644 :3 file
EOF
The initial commit gets the following tags (I'm copying from check-in web UI):
- branch=notmaster propagates to descendants
- sym-notmaster propagates to descendants
- sym-trunk propagates to descendants
This has been previously mentioned here.
I tried --rename-trunk=mytrunk
to see what it does, but it seems to just result in the initial commit being tagged with all three of trunk
, notmaster
and mytrunk
. Not sure what the intended use of that option is.
I started to poke around the code, and I guess it has something to do with the following:
if( gg.zFrom==0 ){
aTCard[nTCard++] = mprintf("T *sym-%F *\n", gimport.zTrunkName);
}
although it beats me why even with --rename-trunk=mytrunk
the trunk
tag is still there.
I'm going to split this into two sub-notes, because I think what should happen depends on the use case:
Mapping a different branch to trunk
It should be possible to tell fossil that a git branch other than "master" is the trunk branch, e.g. with an option --trunk-branch-name=foo
. If the trunk branch is not detected, perhaps fossil should abort rather than do an import that doesn't make sense. (Note that git is generally switching over to main
as the standard trunk branch name, and there's nothing stopping projects from using something else.)
(Workaround if notmaster
should be the trunk branch: fossil amend -R test.fossil (hash of first imported check-in) --branch trunk
)
Not mapping any branch to trunk
When using fossil import -i
, there should be a way to deliberately import without a trunk branch. This is my use case: I'm importing a git repo into my existing fossil repository, and I plan to manually merge the histories together. I don't want any of the imported commits to be on trunk
. Continuing from 2a, perhaps the user could request this behaviour with an empty branch name: --trunk-branch-name=
, or a new option like --no-trunk
.
(Workaround if you don't want trunk on any of the imported check-ins: fossil amend -R test.fossil (hash of first imported check-in) --cancel trunk
)
(2) By mark on 2023-08-08 11:32:24 in reply to 1 [link] [source]
Sorry to reply so late! I am not ignoring these reports, but have not had the time to give them the proper attention they deserve. And I'm glad you have figured out a workaround in the interim. I do have them on my list, however, and will get to them as time permits so thank you for the report :)