jujutsu diverged commits
two changes diverged within a tree..
I’ve recently been using the jujutsu VCS after some urging by my colleague. That is, we work on Magic Cap together, and use JJ “natively”. (Don’t worry, you can still use Git if you’d like to contribute).
The Backstory
Yes, we get to shave Yaks even in this blog post!
I have a desktop and a laptop, both with “jj git clone” checkouts of the hosted repository. As is pretty usual for me, I also have a fork in my personal stuff, so I have two remotes: origin and github (for my personal fork).
I also have a gitolite3 instance on a VPS (and I cannot say enough good things about this software: “just works”, very nice config and admin). Typically I use this as a “don’t need to think” place to push stuff – I don’t have to think about whether a branch is “ready” or has secrets in it or I might rebase it several times still.
Okay, so I made a new repository there and pushed my stuff up off the desktop, as I was about to leave. I’d certainly done a bunch of stuff, including some “jj rebase” operations and other stuff that causes git force-pushes under the hood.
The Problem
So when I did a “jj git fetch” on my laptop, several bookmarks were marked as conflicted, and a bunch of commits had “??” after them. This indicates that they are “diverged”.
Did we say “Yak Shaving??” .. when I asked the nice people in #jujutsu about it, they pointed out my JJ was a bit old due to the way it reported diverged commits.
- one yak: okay, cool, so I upgrade jj
- two yaks: not so fast, Rust was a bit out of date as well
Great, that’s not so bad. Although it turns out JJ wants a particular minimum Git version, but only tells you this when you “jj git …”
- three yaks: install newer git (from source, because PureOS is behind).
Commits Diverged In a Wood?
Okay, so maybe I just want a silly Robert Frost pun too badly here, but now I had to learn a bunch about diverged commits.
I believe what actually happened was a little simpler:
- I did some work on the laptop, and pushed _much_ but not all of it to github
- I continued this work on the desktop, along with some “jj rebase” and other editing-type operations
So when I continued again on the laptop it wouldn’t have mattered that I pulled from this new “gitolite3” clone or from github – there were some similar (but different) changes on the laptop.
(I am a new JJ user, so this part might be wrong: please correct me if so!)
Git and JJ handle re-writing a bit differently. If I’d done a “git rebase –interactive” or similar to edit history, everything newer than my oldest history-edit would be a new commit. That is, Git re-creates the oldest edited commit, and then has to make new child commits with new hashes because they all point at different “parent” hashes.
JJ doesn’t do this. Instead, it changes the _contents_ of a commit (whose name / hash stays the same) so it results in different Git commits just like the Git case, but only when JJ exports them to Git. When the other JJ checkout imports them, it sees the (stable) JJ names for the commits, with two different contents.
This is a “diverged” commit, and you have to deal with it.
For my case, on some commits the content is exactly the same but something else (e.g. the timestamp) changed. Other commits do have different content.
I’m still working out some of these .. but for the “content is the same” you can usually just easily “jj abandon” one of them and it works out.
Some Notes To Help Future Meejah
Some of the relevant stuff I got from #jujutsu:
- lets say “xx” is a JJ commit name
- if you see the “diverged” contents referred to by a hash (and not “xx/0” and “xx/1” where “xx” is the jj commit name) then you have an old JJ
- there is
jj convergebut you still can’t refer to-r xxbecause it’s an error to give “a diverged commit” to-r– instead use ‘jj converge ‘diverged()’ to attempt convergence on all diverged commits - (you may still get an error about “immutable” commits)
- you can diff the two different contents:
jj diff --from xx/0 --to xx/1
There are documentations! But also there are a lot of them, and several reasons to choose from for “why did this diverge?”.
I’m not done looking at and figuring out ALL the divergences, so some updates may be coming as more Yak hairs fall!
txtorcon
carml
cuv’ner