Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Jujutsu (when using git store) #875

Closed
1 task done
kemitix opened this issue Sep 22, 2024 · 6 comments · Fixed by #930
Closed
1 task done

Add support for Jujutsu (when using git store) #875

kemitix opened this issue Sep 22, 2024 · 6 comments · Fixed by #930
Assignees
Labels
feature/request New feature or request

Comments

@kemitix
Copy link
Contributor

kemitix commented Sep 22, 2024

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Jujutsu is a version control system very similar to Git. It currently uses Git as it's local store. It can work with Git in one of two ways. One is 'co-located', where the .git repo is in it's normal location. The other stores the .git/ files in .jj/repo/store/git/. This second is the default when the user clones a Git repo without explicitly requesting that is be co-located.

I would like to be able to use git-cliff with a repo that I have checked out locally using the default non-co-located configuration.

Desired solution

Detecting the alternate location of the .git/ files should be straight forward. When the .git/ directory is not found, simply retry using the .jj/repo/store/git/ directory instead.

Jujutsu is branchless, so there may not be any local branches. There will still be references to the remote branches, e.g. origin/main, etc. e.g. .jj/repo/store/git/refs/remotes/origin/main.

So, when using the Jujutsu location for the git repo, using the remote branches rather than local ones may be required. (It is possible to have local branches, but this is up to the users discretion/workflow).

Alternatives considered

Only clone repos with Jujutsu using the co-located option. This is an easy solution with no real downside other than the need to remember to pass the required parameter when cloning.

Additional context

I recognise that git-cliff is aimed at Git compatibility (it's right there in the name!). Jujutsu uses the same on-disk store, so support shouldn't be too difficult to implement. (Then again there's the other 80% of the problem I can't see).

@kemitix kemitix added the feature/request New feature or request label Sep 22, 2024
Copy link

welcome bot commented Sep 22, 2024

Thanks for opening your first issue at git-cliff! Be sure to follow the issue template! ⛰️

@orhun
Copy link
Owner

orhun commented Oct 1, 2024

Hey, thanks for the suggestion! Jj is actually pretty nice, I maintain it and lazyjj in the Arch repos.

When the .git/ directory is not found, simply retry using the .jj/repo/store/git/ directory instead.
Jujutsu is branchless, so there may not be any local branches. There will still be references to the remote branches

It sounds quite straightforward! Would you be interested in trying that out and seeing if git-cliff works as usual? Also, hint: #426

Jujutsu uses the same on-disk store, so support shouldn't be too difficult to implement. (Then again there's the other 80% of the problem I can't see).

I think adding support for Jujutsu would be pretty cool, nevertheless!

Something that might come up later is #131 - do you have any idea if gitoxide already works well with jj repos?

@kemitix
Copy link
Contributor Author

kemitix commented Oct 5, 2024

I can certainly give it a go. Let me get my current project squared away and I can look at it then.

I used gitoxide a little in git-next, but I felt the documentation assumed you already knew the library. It could really do with a "Gitoxide for Git Users" guide (but this is the wrong place for that conversation). I ended up shelling out to git for most operations, partly because there are still gaps in the gitoxide api that I needed. From what I was able to understand, I thing that if it can do what git-cliff needs from it with a normal git repo, it shouldn't have any problems with a jj colocated git repo.

@orhun
Copy link
Owner

orhun commented Oct 5, 2024

That sounds great - I also think that implementation would be straightforward, all we need for git-cliff to work is retrieving the commits and tags from a repository :)

@kemitix
Copy link
Contributor Author

kemitix commented Oct 23, 2024

I've had a look at how the git repo is configured when it is located in .jj/repo/store/git/.

  • repo is 'bare'
  • remote origin is correctly configured
  • HEAD contains ref: refs/heads/master
  • the directory refs/heads/ is empty, i.e. HEAD points to an invalid ref
  • the directories refs/remotes/ and refs/tags/ are correctly populated

Having git-cliff do a simple swap to use .jj/repo/store/git/ if .git/ is missing, results in the error:

ERROR git_cliff > Git error: `reference 'refs/heads/master' not found; class=Reference (4); code=UnbornBranch (-9)`

So, HEAD is invalid.

To make the git repo usable we could:

  • have the user change HEAD manually: echo "ref: refs/remotes/origin/main" > .jj/repo/store/git/HEAD
  • do the same thing automatically, but selecting main, master, trunk depending on what is available - or allow the user to specify the branch in cliff.toml

I would lean towards having the user do it, at least for an initial implementation.

Thoughts @orhun?

@kemitix kemitix mentioned this issue Oct 23, 2024
12 tasks
@orhun
Copy link
Owner

orhun commented Oct 24, 2024

Thanks for investigating this!

ref: refs/heads/master

Not related, but it seems like doing jj clone on a Git repository assumes that master is the main tracking branch. Maybe we should report that to upstream? (if there isn't an issue already)

echo "ref: refs/remotes/origin/main" > .jj/repo/store/git/HEAD

I'm also wondering if this could be something solved in jujutsu itself 🤔

@orhun orhun closed this as completed in #930 Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants