Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: git/git
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 05ddb9ee8a4c619fbb0e7309fe291bff5cd7c987
Choose a base ref
...
head repository: git/git
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2760ee49834953c0860fa5d7983a6af4d27cb6a9
Choose a head ref
  • 2 commits
  • 7 files changed
  • 1 contributor

Commits on Mar 25, 2026

  1. sequencer: extract revert message formatting into shared function

    The logic for formatting revert commit messages (handling "Revert" and
    "Reapply" cases, appending "This reverts commit <ref>.", and handling
    merge-parent references) currently lives inline in do_pick_commit().
    The upcoming replay --revert mode needs to reuse this logic.
    
    Extract all of this into a new sequencer_format_revert_message()
    function. The function takes a repository, the subject line, commit,
    parent, a use_commit_reference flag, and the output strbuf. It handles
    both regular reverts ("Revert "<subject>"") and revert-of-revert cases
    ("Reapply "<subject>""), and uses refer_to_commit() internally to
    format the commit reference.
    
    Update refer_to_commit() to take a struct repository parameter instead
    of relying on the_repository, and a bool instead of reading from
    replay_opts directly. This makes it usable from the new shared function
    without pulling in sequencer-specific state.
    
    Signed-off-by: Siddharth Asthana <siddharthasthana31@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    edith007 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    1e6434e View commit details
    Browse the repository at this point in the history
  2. replay: add --revert mode to reverse commit changes

    Add a `--revert <branch>` mode to git replay that undoes the changes
    introduced by the specified commits. Like --onto and --advance, --revert
    is a standalone mode: it takes a branch argument and updates that branch
    with the newly created revert commits.
    
    At GitLab, we need this in Gitaly for reverting commits directly on bare
    repositories without requiring a working tree checkout.
    
    The approach is the same as sequencer.c's do_pick_commit() -- cherry-pick
    and revert are just the same three-way merge with swapped arguments:
    
      - Cherry-pick: merge(ancestor=parent, ours=current, theirs=commit)
      - Revert: merge(ancestor=commit, ours=current, theirs=parent)
    
    We swap the base and pickme trees passed to merge_incore_nonrecursive()
    to reverse the diff direction.
    
    Reverts are processed newest-first (matching git revert behavior) to
    reduce conflicts by peeling off changes from the top. Each revert
    builds on the result of the previous one via the last_commit fallback
    in the main replay loop, rather than relying on the parent-mapping
    used for cherry-pick.
    
    Revert commit messages follow the usual git revert conventions: prefixed
    with "Revert" (or "Reapply" when reverting a revert), and including
    "This reverts commit <hash>.". The author is set to the current user
    rather than preserving the original author, matching git revert behavior.
    
    Helped-by: Christian Couder <christian.couder@gmail.com>
    Helped-by: Patrick Steinhardt <ps@pks.im>
    Helped-by: Elijah Newren <newren@gmail.com>
    Helped-by: Phillip Wood <phillip.wood123@gmail.com>
    Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
    Helped-by: Junio C Hamano <gitster@pobox.com>
    Helped-by: Toon Claes <toon@iotcl.com>
    Signed-off-by: Siddharth Asthana <siddharthasthana31@gmail.com>
    Signed-off-by: Junio C Hamano <gitster@pobox.com>
    edith007 authored and gitster committed Mar 25, 2026
    Configuration menu
    Copy the full SHA
    2760ee4 View commit details
    Browse the repository at this point in the history
Loading