Skip to main content

revert

Function revert 

Source
pub fn revert(
    obj_store: &mut GitObjectStore,
    commits_table: &mut CommitsTable,
    commit_id: &str,
    head_commit_id: &str,
    author: &str,
) -> Result<String, RevertError>
Expand description

Revert a commit by creating a new commit that undoes its changes.

  1. Find the target commit’s parent
  2. Diff parent -> target to get what the commit changed
  3. Apply the inverse (add removed triples, remove added triples) to HEAD
  4. Create a new commit with the inverted changes

Returns the new revert commit’s ID.