Editing Message of Previous Commits#55
Merged
Merged
Conversation
Collaborator
|
Thanks for the proposal and implementation! Right now, improving the broader command surface is a higher priority, but I’ll record this in the roadmap and merge that direction for now. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently,
h5idoes not provide functionality for editing the message of previously-made commits. As projects develop, and as different aspects of past commits grow more relevant to current development, this immutability may be an inconvenience.To address this issue, the
edit-messagefunction provides functionality for editing the message of a previously-made commit. The function may be called as follows:h5i edit-message <oid> --edit <new message>The function returns the new OID of the commit whose message was edited.
Commits with or without dependencies may be edited. If the commit whose message was edited has dependencies, the parent OID of each dependency is updated accordingly.
Example usage:
Attached are screenshots of the h5i UI after each of the calls to edit-message in the example above.
Intial:

First Call:

Second Call:

Comprehensive testcases are included in CI.
UPDATE:
Instead of using
filter-branch, which poses several stability concerns, this new implementation ofedit-messageemploys a Breadth-First Search to find the target commit from the HEAD commit. The process for editing the message of a commit is as follows:caused_byandcausesfields in itsh5i Note, maintaining bidirectional causal links.HEADthrough Git parent links locates the target commit, recording the path from target toHEADas an ordered sequence.h5i Noteis moved to the new OID.HEADis iterated linearly. Each commit is rewritten with remapped parent OIDs, and itsh5i Noteis moved to the new OID.caused_byandcausesNote fields.caused_byreferenced an old OID have their Notes patched in place, without OID changes.HEADis advanced to the new tip commit.