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

cli: reorder import of git head/refs and snapshot #2888

Merged
merged 6 commits into from
Jan 26, 2024

Conversation

yuja
Copy link
Contributor

@yuja yuja commented Jan 26, 2024

#2876

Checklist

If applicable:

  • I have updated CHANGELOG.md
  • I have updated the documentation (README.md, docs/, demos/)
  • I have updated the config schema (cli/src/config-schema.json)
  • I have added tests to cover my changes

yuja added 6 commits January 26, 2024 21:16
I'm going to make WorkspaceCommandHelper::maybe_snapshot() snapshot the working
copy before importing refs. git::import_some_refs() can rebase the working copy
branch and therefore @ can be moved. git::import_head() doesn't, and it should
be invoked before snapshotting.

git::import_head() is inserted to some of the git:import_refs() callers where
HEAD seems to matter. I feel it's a bit odd that the HEAD ref is imported to
non-colocated repo, but "jj init --git-repo" relies on that, and I think the
existence of HEAD@git is harmless. It's merely a ref to the revision checked
out somewhere else.
Also added status message to import_git_head() as I think it's an unusual
event.
The "::HEAD" set is usually smaller than "::git_refs". If these sets were
imported in that order, "HEAD..git_refs" commits would be indexed on top of
the "::HEAD" commits. It's not a problem, but undesirable.
Since import_git_refs() may check out new working-copy commit, it shouldn't be
triggered before the snapshot.

Fixes jj-vcs#2876
This is the source of the problem I noticed when debugging jj-vcs#924 and jj-vcs#1608. I
don't think this can be easily fixed, so let's document it.
Copy link
Member

@martinvonz martinvonz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. Thank you!

lib/src/git.rs Show resolved Hide resolved
@yuja yuja merged commit 1330381 into jj-vcs:main Jan 26, 2024
15 checks passed
@yuja yuja deleted the push-punvukktprut branch January 26, 2024 15:02
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

Successfully merging this pull request may close these issues.

2 participants