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

jj undo apparently "undid" automatic git-refs import (but may have simply done nothing) #4625

Open
BatmanAoD opened this issue Oct 11, 2024 · 2 comments

Comments

@BatmanAoD
Copy link
Collaborator

Description

According to the op log, I ran jj undo, and it did an import git refs immediately followed by "undoing" that import, which doesn't make sense.

Steps to Reproduce the Problem

  1. Do something undo-able (e.g. jj abandon)
  2. Make a change in git that must be imported
  3. jj undo

Expected Behavior

Step one is undone.

Actual Behavior

Apparently a no-op. jj op log shows:

○  0ad61fffcb63 kstrand@RM-LOSX-0F2WP14 29 seconds ago, lasted 9 milliseconds
│  undo operation d90b70abbd980b9e82885f150cb7d1c469ace0c998539212f273e199f5b19418d0dd3b7853e52bee727826576499eec4c404c8934b519f62a150cf98170ab455
│  args: jj undo
○  d90b70abbd98 kstrand@RM-LOSX-0F2WP14 29 seconds ago, lasted 43 milliseconds
│  import git refs
│  args: jj undo
○  336abf42c84e kstrand@RM-LOSX-0F2WP14 12 minutes ago, lasted 29 milliseconds
│  abandon commit 9650f41f53d3a36f299042afbfa1e26f1e61428a
│  args: jj abandon

The second jj undo node claims to "undo" the import git refs node. I'm pretty sure the import is not reversible, though.

Specifications

  • Platform: Mac OS
  • Version: 0.22.0-67c2ae0a9e3e445f034a456b299e3f37c4dc4b93
@martinvonz
Copy link
Owner

The import can be undone. For example, lets say you had moved a branch in git, and you then run jj undo. That will import the moved branch and then immediately undo it. It will also export the changes back to Git. Like this:

$ jj log
@  m [email protected] 2024-10-11 12:49:07 125bcd2a
│  (empty) (no description set)
○  v [email protected] 2024-10-11 12:47:30 main HEAD@git f3421f8e
│  bar
○  r [email protected] 2024-10-11 12:47:06 0dfbd820
│  foo
◆  z root() 00000000

$ git branch -f main 0dfbd820

$ jj undo
Abandoned 1 commits that are no longer reachable.
Rebased 1 descendant commits off of commits rewritten from git
Working copy now at: m c92ce1fb (empty) (no description set)
Parent commit      : r 0dfbd820 main | foo
Added 0 files, modified 1 files, removed 0 files
Done importing changes from the underlying Git repo.
Undid operation 4fb019417b7b now, lasted 668 milliseconds import git refs
Working copy now at: m 125bcd2a (empty) (no description set)
Parent commit      : v f3421f8e main | bar
Added 0 files, modified 1 files, removed 0 files

$ jj log
@  m [email protected] 2024-10-11 12:49:07 125bcd2a
│  (empty) (no description set)
○  v [email protected] 2024-10-11 12:47:30 main HEAD@git f3421f8e
│  bar
○  r [email protected] 2024-10-11 12:47:06 0dfbd820
│  foo
◆  z root() 00000000

@BatmanAoD
Copy link
Collaborator Author

Huh. That's not what I would have expected, but it makes some sense that jj would be able to reverse things you did in git. But I don't actually know in this case what was being undone; I think it was just a git fetch, but I don't remember intentionally doing anything with git.

How much "undoing" is possible? If I make five new commits with git, without running any jj commands, and then run jj undo, does it import and then "hide" all five commits?

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

2 participants