helix icon indicating copy to clipboard operation
helix copied to clipboard

Integration with Jujutsu

Open yoav-lavi opened this issue 1 year ago • 18 comments

Jujutsu (or jj) is a git compatible distributed version control system (DVCS). When working in a repository managed by Jujutsu, Helix will not display any gutter change indicators, as that functionality currently works with a standard git repository.

Support may be relatively simple, see https://github.com/martinvonz/jj/blob/main/docs/github.md#using-github-cli (using .jj/repo/store/git)

yoav-lavi avatar Aug 16 '23 20:08 yoav-lavi

Jujutsu is git compatible so it should be fine to simply rely on git functionality.

archseer avatar Aug 16 '23 20:08 archseer

@archseer as far as I can tell it doesn't work out of the box, do you mean using the same mechanism but changing the detection of git repositories?

yoav-lavi avatar Aug 16 '23 20:08 yoav-lavi

I just ran jj init --git-repo=. on my existing repository. jj is tracking changes in my working copy just fine. If I check git status those changes are still unstaged and helix displays a diff.

archseer avatar Aug 16 '23 20:08 archseer

@archseer that's a co-located jj repo, they retain the .git folder AFAIK. If you jj git clone ... or use something other than =. the .git isn't there and no changes are displayed as far as I can tell

yoav-lavi avatar Aug 16 '23 20:08 yoav-lavi

For compatibility I'd recommend using a clone that contains the .git folder. We're unlikely to add any other VCS any time soon (we don't even support Mercurial or Pijul so Jujutsu would be an even harder sell right now)

archseer avatar Aug 16 '23 20:08 archseer

https://github.com/martinvonz/jj/blob/main/docs/git-compatibility.md#co-located-jujutsugit-repos

yoav-lavi avatar Aug 16 '23 20:08 yoav-lavi

It's also useful when tools (e.g. build tools) expect a Git repo to be present.

archseer avatar Aug 16 '23 20:08 archseer

To clarify I saw this with jj git clone specifically

yoav-lavi avatar Aug 16 '23 20:08 yoav-lavi

@archseer sure, this isn't a bug, it's an enhancement suggestion (full jj support without co-locating)

yoav-lavi avatar Aug 16 '23 20:08 yoav-lavi

Hmm since jj does use a proper git store (.jj/repo/store/git) it might be possible it could work by modifying the search path but I'm not sure if working changes would be detected properly.

\cc @pascalkuthe

archseer avatar Aug 16 '23 20:08 archseer

For compatibility I'd recommend using a clone that contains the .git folder. We're unlikely to add any other VCS any time soon (we don't even support Mercurial or Pijul so Jujutsu would be an even harder sell right now)

@archseer Sorry, I'm on mobile and missed this!

I'm suggesting this since as you said it uses a proper git store, but I'd 100% completely understand if this isn't one of Helix's goals. Suggested specifically since I thought it might be a relatively painless and useful addition.

yoav-lavi avatar Aug 16 '23 21:08 yoav-lavi

@archseer I may also be able to look into contributing this if it's something a newcomer to the codebase would be able to add / makes sense with the way it's currently implemented

yoav-lavi avatar Aug 16 '23 21:08 yoav-lavi

We use gitoxide for repo discovery so the way to make this work in helix is to contribute that upstream. Altough we also use .git for workspace root discovery so having a .git folder present is likely a good idea anyway

pascalkuthe avatar Aug 16 '23 21:08 pascalkuthe

Ok makes sense, thank you both @archseer @pascalkuthe!

Thanks for making an amazing editor!

yoav-lavi avatar Aug 16 '23 21:08 yoav-lavi

on a separate note: jj uses a different system for managing the working tree: https://github.com/martinvonz/jj#the-working-copy-is-automatically-committed, they always automatically commit the worktree. I am not sure how they handle the rev names here. Helix is currently hardcoded to always diff against HEAD. If jj automatically makes the worktree HEAD, the diff gutter would be empty too. I would hope that they would just use a different ref name here tough.

Either way we want to add a config option to change which commit we diff against anyway so that could be fixed in the future if its a problem.

pascalkuthe avatar Aug 16 '23 22:08 pascalkuthe

In Jujutsu, the working copy doesn't automatically become the HEAD ref in Git -- it is committed separately, without affecting HEAD. Only if you run something like jj commit does HEAD get updated.

sunshowers avatar Feb 12 '24 23:02 sunshowers

A key difference between jj diff and git diff, though, is that jj does not have the notion of untracked files.

% git init
% jj git init --git-repo .  # creates a colocated jj repo
% touch a
% git status
(shows a as untracked)
% git diff
(nothing)
% jj status
(shows a as added)
% jj diff
(shows a)

There are also other differences, e.g. if you jj amend, the change ID stays the same, but if you run git commit --amend, a new change ID is assigned.

So while just relying on Git support is not the worst thing, integrating better with jj would be ideal.

(I use jj but not Helix, mostly offering this as help)

sunshowers avatar Feb 12 '24 23:02 sunshowers

May be resolved by https://github.com/helix-editor/helix/pull/9643

kirawi avatar Apr 05 '24 12:04 kirawi