Fossil Forum

Changning mainbranch name
Login

Changning mainbranch name

Changning mainbranch name

(1) By Michael Durian (durian) on 2023-02-13 21:12:14 [link] [source]

When I initially created my fossil repository, I migrated from git using the 'fossil git' command. I must have used the --mainbranch option because I don't have a 'trunk' branch. I have a 'develop' branch instead. For consistency with new fossil repositories, I'd like to rename the 'develop' branch to 'trunk'. I'm not sure how I should go about doing this. Is it enough to create a new branch named trunk that is a duplicate of develop and then close my develop branch or is there more to it?

Thanks, mike

(2) By Warren Young (wyoung) on 2023-02-13 22:05:58 in reply to 1 [link] [source]

Try:

  fossil amend --branch trunk develop:root

If not that, then the literal commit ID at the root of your develop branch.

This won't rewrite the artifacts, because that would change all the hashes, but it should cause the UI to display "trunk" instead of "develop" everywhere.

(3) By Daniel Dumitriu (danield) on 2023-02-13 22:49:19 in reply to 2 [link] [source]

That special name should probably be start:develop.

(4) By Michael Durian (durian) on 2023-02-14 16:34:50 in reply to 3 [link] [source]

I think I made things worse.

I did

fossil amend --branch trunk start:develop

This created a new trunk branch. The develop branch was also still present after the command. However, the start branch was different from the develop branch (fossil diff --from develop --to trunk). Trunk seemed to be missing some changes.

I tried the command again and now my develop branch is gone and trunk still doesn't contain the most recent changes.

Here's the most recent entries in the timeline:

=== 2023-02-13 ===
23:39:37 [07eede2e3e] Edit [135a8e985209de52|135a8e9852]: Move to branch
         [/timeline?r=trunk&nd&dp=135a8e985209de52&unhide | trunk]. (user:
         durian)
23:37:26 [7d6d01b9c0] Edit [77ec273818446a9b|77ec273818]: Move to branch
         [/timeline?r=trunk&nd&dp=77ec273818446a9b&unhide | trunk]. (user:
         durian)
18:41:25 [58eaeb8d0a] Update README with notes saying to include serialization
         in the silk and that the silk should be white. (user: durian tags:
         ra6m3)

I'm not sure what to do. How can I either restore things to before my first amend command (I do have one remote repository I haven't synced to since before the amend) or adjust the current situation such that trunk is up-to-date with the most recent 58eaeb8d0a change.

mike

(5) By Warren Young (wyoung) on 2023-02-14 17:29:34 in reply to 4 [link] [source]

While it is possible to remove the amendment, returning your tree to its prior state, at this point I'd just restore from backup and then apply the amendment to the tip of "develop" instead, so that going forward it will be called "trunk".

(6) By Michael Durian (durian) on 2023-02-14 18:19:59 in reply to 5 [link] [source]

I've got two remotes, one that I haven't synced to and the other which is the default. I haven't explicitly synced since the amend, but I assume it was automatically pushed to the default remote. To restore from the non-default remote, do I need to delete my existing repository and then clone from it, or is there a command I can run that will ignore what I have and match the remote's state without accidentally pushing the amend changes?

As for the amend command itself, is this what you recommend?

fossil amend --branch trunk tip:develop

mike

(7) By Warren Young (wyoung) on 2023-02-14 20:17:30 in reply to 6 [link] [source]

I assume it was automatically pushed to the default remote

Why guess? Look at its timeline and find out.

do I need to delete my existing repository and then clone from it,

Better would be to restore from a local backup, which you do have, right? Right?

Fossil itself is not a perfect backup. If that's all you have, then I suggest you do back this confused repo up, then try an alternate plan first: cancel the amendment tag. You may be able to do this more easily in the UI by clicking on the initial commit to the repo and telling it to remove the branch rename.

If you can't work out how to do that, then yes, re-cloning is your next-best plan. It has one bad side-effect: you'll need to close and re-open your repos afterward since re-cloning changes the RID values referred to by the checkout DB.

is there a command I can run that will ignore what I have and match the remote's state without accidentally pushing the amend changes?

There isn't anything like "git reset --hard" in Fossil to globally throw away local history in favor of the remote, on purpose. The closest we have are surgical removals: tag cancel, amend hide/close, purge, shun…

fossil amend --branch trunk tip:develop

You don't need to give the tip: prefix. That's implied.

(8) By Michael Durian (durian) on 2023-02-14 21:41:05 in reply to 7 [link] [source]

Sigh, backups would be nice. I do have backups in a normal situation, but recently the zpool backing store detected corruption issues and my most recent backup for the fossil database is too old to be useful.

I couldn't figure out how to cancel the tag either. My attempts didn't seem to do anything.

Recloning was a success, so I'm back to where I need to be. Yay! And thanks.

I redid the amend command and it worked better, but I'm still a bit confused about its behavior. When I do

fossil diff --from develop --to trunk
I see output. Specially, the trunk branch has three files that are no longer present in the develop branch. Did amend create the trunk branch from the most recent check-in to develop and then left develop without that check-in? I was expecting it to be more like a rename, where develop would become trunk in toto. I suspect you tried to explain this when you said:

This won't rewrite the artifacts, because that would change all the hashes, but it should cause the UI to display "trunk" instead of "develop" everywhere.

But the bit about rewriting artifacts went right over my head.

For those following along at home, I did check my default remote and the amend stuff did not automatically propagate.

(9) By Daniel Dumitriu (danield) on 2023-02-14 22:06:10 in reply to 8 [link] [source]

Try out another path: fire up the UI, click on the first (oldest) checkin on the "develop" branch, click "edit", check "Make this check-in the start of a new branch named:" and say "trunk", then "Preview" and "Apply changes".

(10) By Daniel Dumitriu (danield) on 2023-02-14 23:15:45 in reply to 9 [link] [source]

The CLI equivalent would be:

fossil tag add --raw branch=trunk --propagate start:develop
fossil tag add --raw sym-trunk --propagate start:develop
fossil tag cancel --raw sym-develop start:trunk

(11) By Michael Durian (durian) on 2023-02-14 23:26:54 in reply to 10 [link] [source]

I will give this a try tomorrow. Can you explain what these commands do?

(13) By Daniel Dumitriu (danield) on 2023-02-15 07:27:57 in reply to 11 [link] [source]

In Fossil, branch "affiliation" is implemented by means of (propagating) tags, so basically those commands remove the "develop" and add the "trunk" tag to all check-ins on that branch. I recommend reading Warren's detailed documentation.

For this case, using the GUI is certainly the more comfortable option - bearing scrolling to the first check-in on the said branch, but that shouldn't be too difficult, either.

(14) By Warren Young (wyoung) on 2023-02-15 09:02:19 in reply to 13 [link] [source]

Warren's detailed documentation.

While I did add a lot to the branching doc, that particular section is mostly drh's work.

(15) By Daniel Dumitriu (danield) on 2023-02-15 09:05:33 in reply to 14 [link] [source]

Sorry - the power of habit 😉

(17) By Michael Durian (durian) on 2023-02-15 17:55:38 in reply to 10 [link] [source]

I gave these commands a try (command line stuff is a little more intuitive to me than the UI interface). They created a trunk tag, but when I check to see what branches exist, trunk does not appear and develop is still listed.

> f branch list
 * develop
   ivv
   libcmsis
   mod0
   ra6m3
   release
   vendor/elm-chan/libfatfs
   ...

> f tag list
...
develop
ivv
ivv/1
ivv/2
libcmsis
mod0
ra6m3
release
...
trunk
vendor/elm-chan/libfatfs
...

(18) By Michael Durian (durian) on 2023-02-16 18:01:44 in reply to 17 [link] [source]

I wonder if the problems I'm having changing the branch name are related to two earlier problems I had with this repository.

Back when I first created the repository, I imported the project history from git. This was not completely successful. There is a place where the git import code that doesn't check for a NULL value and goes ahead and dereferences the pointer anyway. I believe my git repository was tickling this bug..

Then I had a problem where all my branches were all propagating together. I believe this was due to the problems encountered when I initially imported the code.

I did cancel tags on my develop branch so it was only tagged with develop and not all the other ones. Perhaps a combination of the initial problem and the way I canceled tags has left me in the situation I'm in now where my attempts to rename the branch aren't quite working as expected.

(12) By Warren Young (wyoung) on 2023-02-15 04:49:13 in reply to 8 [source]

I do have backups in a normal situation, but recently the zpool backing store…

Use the 3-2-1 rule:

  • Three copies.1
  • Two different media.2
  • One copy off-site.3

Backups "too old to be useful" may at least contain configuration data that tends to stay static, so you might be able to use a week-old backup and then carefully bring the last week of commits into it from the local copies, which are otherwise unusable. Even if all 3+ copies you have under this system are shot full of holes, they may not all have the holes in the same locations, thus giving you a chance of assembling one hale copy from the mess.

But the bit about rewriting artifacts went right over my head.

First, give the branching doc a serious read. In this case, we're most interested in the "Tags and Properties" section near the end, but the whole thing is worth knowing even at the newbie level.

Considerably more advanced is the Fossil file format doc, which you generally do not need to understand until you're doing something clever…like renaming your entire main branch. :)

We aren't going to dive deeply into this second doc, but check out the manifest format, described up near the top, the T card format in particular. If you had the ability to rewrite all of those tags — which you now know from the first doc are how branches are implemented — it would change the Z card value, which is how a particular commit is identified. Since each commit refers to one or more parents, each of that commit's children would then have to be changed to refer to the new hash, which changes their manifests, and so on down the line until you get to the tips of the affected branches.

Git actually allows this kind of thing, but it leads to the "golden rule of rebase," which is to never do it on a public branch, for this very reason: it changes all the hashes, confusing everyone who has a different clone. It's one of the main reasons Fossil does not have rebase, a stance we're rather militant about.


  1. ^ Filesystem level snapshots count as one only, even if you have multiple levels.
  2. ^ Snapshots are ipso facto one medium.
  3. ^ Thus the Fossil backup doc's recommendation of automated encrypted cloud drive copies.

(16) By Michael Durian (durian) on 2023-02-15 17:40:53 in reply to 12 [link] [source]

I was familiar with the branching doc. I will read up on the file format doc and see if that helps clarify things for me.