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.

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 …”

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:

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:

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!