martinvonz / jj

A Git-compatible VCS that is both simple and powerful
https://martinvonz.github.io/jj/
Apache License 2.0
8.15k stars 271 forks source link

Cannot run `jj git push` #1957

Open lazywei opened 1 year ago

lazywei commented 1 year ago

Description

On a colocated repo with Git, it seems I'm unable to run jj git push

git-playground (4344105) ❯ jj git push --change 43
Creating branch push-uxzzrmkpoqrl for revision 43
Branch changes to push to origin:
  Add branch push-uxzzrmkpoqrl to 434410530c08
Error: failed to lock file '/foo/bar/git-playground/.git/refs/jj/git-push/434410530c0892d3b2e2abbcde610e8f165e2b81.lock' for writing: ; class=Os (2); code=Locked (-14)

Steps to Reproduce the Problem

Not quite sure what I did that messed up the repo and not sure how I can revert back to a good state.

Specifications

martinvonz commented 1 year ago

I think that's a lock on a git ref, presumably taken in accordance with git's spec. Either a jj process took that via libgit2 or a git process took it. First make sure you don't have a running process accessing your repo. If .git/refs/jj/git-push/434410530c0892d3b2e2abbcde610e8f165e2b81 (without the .lock suffix) doesn't exist, I think the right next step is to rename .git/refs/jj/git-push/434410530c0892d3b2e2abbcde610e8f165e2b81.lock to .git/refs/jj/git-push/434410530c0892d3b2e2abbcde610e8f165e2b81.

I don't know if this is a bug in libgit2 or how jj uses it or something else.

lazywei commented 1 year ago

Thank you @martinvonz I will try that! So it's safe to release the lock as long as there is no other running process accessing the repo right?

martinvonz commented 1 year ago

Thank you @martinvonz I will try that! So it's safe to release the lock as long as there is no other running process accessing the repo right?

Yes. And I think the way to release the lock is not to delete the file but to rename it.