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

HEAD@git gets misplaced when the first non-root commit is edited in a colocated repo #1495

Closed
ilyagr opened this issue Apr 7, 2023 · 2 comments
Labels
🐛bug Something isn't working colocated

Comments

@ilyagr
Copy link
Contributor

ilyagr commented Apr 7, 2023

Let's say I do the following in an empty repo:

$ git init
Initialized empty Git repository in /home/ilyagr/dev/temp/a/.git/
$ jj init --git-repo=.
Initialized repo in "."
$ jj describe -m 'commit'
$ jj duplicate

At this point, things are OK. jj log looks like

◉  TQXLZQ ilyagr@ 58 seconds ago e3cfcf
│  (empty) commit
│ @  QSTUSW ilyagr@ 1 minute ago 684d5d
├─╯  (empty) commit
◉  ZZZZZZ @ 53 years ago 000000
   (empty) (no description set)

and git status reports "no commits yet". There isn't yet a HEAD.

If I then do jj co t && jj edit q, I end up in this bad state:

◉  TQXLZQ ilyagr@ 1 minute ago main HEAD@git e3cfcf
│  (empty) commit
│ @  QSTUSW ilyagr@ 1 minute ago 684d5d
├─╯  (empty) commit
◉  ZZZZZZ @ 53 years ago 000000
   (empty) (no description set)

Note how HEAD is in the wrong place.

@ilyagr ilyagr added the 🐛bug Something isn't working label Apr 7, 2023
@martinvonz
Copy link
Member

I think this is a limitation in Git. See the comment here:
https://github.com/martinvonz/jj/blob/cfdfc452dc9fecb3fd962dedbf0a183b91d502a8/lib/tests/test_git.rs#L743-L745

@martinvonz
Copy link
Member

I think an alternative might be to create a placeholder branch when we export to git from this state.

@ilyagr ilyagr changed the title Colocated repos misplace HEAD@git when the first non-root commit is edited HEAD@git gets misplaced when the first non-root commit is edited in a colocated repo Apr 7, 2023
yuja added a commit to yuja/jj that referenced this issue Oct 3, 2023
I'll add a workaround for the root parent issue jj-vcs#1495 there. We can pass in
the wc parent id instead of the wc_commit object, but we might want to use
wc_commit.id() to generate a unique placeholder ref name.
yuja added a commit that referenced this issue Oct 3, 2023
I'll add a workaround for the root parent issue #1495 there. We can pass in
the wc parent id instead of the wc_commit object, but we might want to use
wc_commit.id() to generate a unique placeholder ref name.
yuja added a commit to yuja/jj that referenced this issue Oct 4, 2023
I considered using the working-copy commit id to generate a unique ref, but the
placeholder ref can be "born" by committing changes by git, and the ref name can
conflict later by editing the original (hidden) commit. So I think it's better
to generate a random name instead.

Fixes jj-vcs#1495
yuja added a commit to yuja/jj that referenced this issue Oct 4, 2023
As we can set HEAD to an arbitrary ref by using .reference_symbolic(), we don't
have to manage a ref that can also be valid as a branch name.

Fixes jj-vcs#1495
yuja added a commit to yuja/jj that referenced this issue Oct 4, 2023
As we can set HEAD to an arbitrary ref by using .reference_symbolic(), we don't
have to manage a ref that can also be valid as a branch name.

Fixes jj-vcs#1495
@yuja yuja closed this as completed in a302090 Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working colocated
Projects
None yet
Development

No branches or pull requests

2 participants