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

Crash after GC in Git #815

Closed
martinvonz opened this issue Nov 29, 2022 · 1 comment
Closed

Crash after GC in Git #815

martinvonz opened this issue Nov 29, 2022 · 1 comment

Comments

@martinvonz
Copy link
Member

Description

After importing a commit from Git, if that commit gets unreferenced and GC'd by Git, jj may crash.

Reported on Discord by @tp-woven.

Steps to Reproduce the Problem

  1. Create a Git repo with two commits on branch main. Check out main~.
  2. Initialize a jj repo backed by it
  3. In the Git repo, rewind the main branch (git branch -f main) and force GC (git -c gc.reflogExpire=now gc --prune=now)
  4. Go back to the jj repo and run e.g. jj log

Expected Behavior

jj log works fine and still sees the old location of the main branch (since we didn't re-import)

Actual Behavior

Crash:

Error: Unexpected error from store: Object not found

Specifications

  • Version: 0.5.1 (and at least back to 0.4.0)
@martinvonz
Copy link
Member Author

Here's a test script I've used for this (to be run in an empty temporary directory):

#!/bin/sh

rm -rf git jj

git init git
cd git
echo a > file
git add file
git commit -m a
echo b > file
git add file
git commit -m b
git checkout HEAD^
cd ..

jj init jj --git-repo=git

cd git
git branch -f main
git -c gc.reflogExpire=now gc --prune=now
cd ..

cd jj
jj log
cd ..

martinvonz added a commit that referenced this issue Dec 3, 2022
To prevent git's GC from breaking a repo, we already add a git ref to
commits we create in the git backend. However, we don't add refs to
commits we import from git. This fixes that.

Closes #815.
martinvonz added a commit that referenced this issue Dec 3, 2022
To prevent git's GC from breaking a repo, we already add a git ref to
commits we create in the git backend. However, we don't add refs to
commits we import from git. This fixes that.

Closes #815.
martinvonz added a commit that referenced this issue Dec 4, 2022
To prevent git's GC from breaking a repo, we already add a git ref to
commits we create in the git backend. However, we don't add refs to
commits we import from git. This fixes that.

Closes #815.
martinvonz added a commit that referenced this issue Dec 4, 2022
To prevent git's GC from breaking a repo, we already add a git ref to
commits we create in the git backend. However, we don't add refs to
commits we import from git. This fixes that.

Closes #815.
martinvonz added a commit that referenced this issue Dec 4, 2022
To prevent git's GC from breaking a repo, we already add a git ref to
commits we create in the git backend. However, we don't add refs to
commits we import from git. This fixes that.

Closes #815.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant