-
Notifications
You must be signed in to change notification settings - Fork 372
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
FR: Command for resetting change ID #4451
Comments
How about |
Those could be good names! I think it is technically not possible to modify the change ID without also modifying the commit ID because of how the change ID is stored for the Git backend (I think if you try it, |
I don't know jj code, but I've assumed it stores references to Git commits and it'd be possible to only recrate the reference. |
Is it really the change ID that is divergent? It seems like the change ID is the thing being managed by the tool, so there are commands to manipulate commits that comprise the change. |
Correct. "commit ID" should be considered a content hash including "change ID". The change ID isn't actually stored in Git commit object, but changing it without updating commit ID would lead to internal data inconsistency. Regarding command name, I feel reassigning change IDs is quite different operation than resetting author or description (even though the underlying representation is similar.) |
I am frequently switching between repos on the desktop and laptop, which leads to divergent revision more often that I'd like. Ideally, pushing between the repos would not create divergent change IDs in the first place, but simply create new change IDs instead. Short of that however, I'd hope for JJ to add a command:
While tedious, this would allow to fixup a single divergent change with a single command. I think I have managed to script a somewhat reliable implementation of a divergent change_id reassignment in jj-fzf, that allows me to at least fixup branches with a single hotkey per divergent change at a time: |
Does the |
I really fail to understand how duplicate+abandon is supposed to work in practice.
That is why my script does new --before + squash --from, this preserves the children, and re-finding the commit id after new --before is only somewhat tricky, at least the divergent commit still points to it.
The last point is probably most important, because it affects a bunch scripting brittleness. What I mean is this:
Here are examples that show how the commands can now reliably be used in scripts:
Other commands should follow suit. |
One use case that I'd love this for is when another dev creates a commit on top of mine in git:
Now there are 2 commits with the id
What I would love is the ability to give the old commit a new change id to resolve this problem. |
This reminded me to post #4708, where resetting the change ID could be expressed as |
[Merging request from #5116] Is your feature request related to a problem? Please describe. Currently, jj has no command that supports creating a new commit with a specific change ID or changing an existing change ID. This limitation makes it close to impossible to recreate a specific change ID that has been observed in another repository, e.g. through jj-am.sh which can be used to mirror commits across different repositories. Additionally, there are divergent change_id cases, where keeping a commit, but under a new (different) change_id would be desirable. In such cases it would be nice to simply regenerate a new change_id with a single (simple) command for such a commit (possibly keeping a short prefix similar to the divergent change ID at the user's discretion). Describe the solution you'd like jj describe --help
--reset-change-id=<CHANGE_ID> Assign a specific change ID or prefix to an existing revision.
--random-change-id Assign a newly generated random change ID to an existing revision. Implementation Notes
Describe alternatives you've considered Not support change_id transfers between repos, we have that now and experience its downsides daily. Additional context Note that this feature will need implementation anyway, when support for a custom header like Related Discord discussion: |
This sounds to me like micromanaging the VCS tool. Instead, the scenarios where a change ID is needed should be evaluated to find a way for the tool to handle it gracefully, internally. Perhaps rules of which repo is "source of truth" could be formulated, or meta data about change hierarchy is needed. |
I agree that we should probably figure out more details of the intended semantics for change IDs. There's some more discussion in this GitHub Discussions comment and this linked Discord thread.
However, I expect that there exists a significant workflow that does involve "micromanaging" the VCS tool and very carefully assigning change IDs, etc., in the same way that there are significant workflows that involve micromanaging the specific commits/patches and rewriting large parts of the commit graph, so my expectation is that an ultimate solution will support manual change ID assignment. Regarding "source of truth", I suspect that jj intends to preserve existing distributed VCS workflows and not consider any one repo as the "source of truth", but we should certainly consider things more carefully given that we don't have to automatically adopt all Git workflows, and that a majority of development work happens in a centralized fashion regardless.
|
This brings up an interesting question: Should change IDs be expected to be unique across repos? To me it seems like they shouldn't, because of the very use-case I posted above: If you and I both modify a change ID, which modification wins? The only solutions I can see are picking one of our changes somehow as the official one or requiring that we work together to merge our commits together. Both seem impractical and against the spirit of a distributed VCS. Maybe part of the solution here is to decide that change IDs are local to a repo, like branch/bookmark names. If two different repos disagree on a change ID, that's fine and doesn't count as a conflict. |
I was wondering the same, but see the Discord discussion that arxanas linked to in his last comment and also this one from Martin: #5074 (reply in thread) |
Is your feature request related to a problem? Please describe.
If there are multiple commits with the same change ID and I want to keep both versions of them for some reason, it can be difficult to resolve the divergent change ID. I think it would be nice if there was a command that just replaces all commits in a revset with identical commits, except with new change IDs.
Describe the solution you'd like
I'm not sure what a good name for such a command would be, since
jj reset-change-id
seems too long. Maybe it would be good to have a general commandjj reset
that takes different flags depending on what needs to be reset:This might be confusing with
git reset
, so it might not be a good idea. I do feel like this would be a better place to put "reset author" though, since the currentjj describe --reset-author
feels like an unintuitive place to put it.Another option might be a
change-id
subcommand, but I'm not sure if there's any other operations on change IDs that would be useful. Maybe swapping change IDs could be useful (e.g. ifjj split
left the change ID on the wrong commit), but that seems like a weird solution.Describe alternatives you've considered
jj duplicate
followed byjj abandon
of the original commits works. This could maybe be done with an alias if aliases could execute multiple commands and take arguments to pass to each. Or maybe a new option likejj duplicate --replace <REVSET>
could duplicate the commits, but automatically abandon the previous versions and rebase their descendants onto the new commits.The text was updated successfully, but these errors were encountered: