[go: up one dir, main page]

Skip to content

replay: make atomic ref updates the default behavior

Hello 👋🏻

With the extensive feedback from Git maintainers on the mailing list, we have transformed git replay to address all performance and usability concerns raised by the community. The original v1 patch introduced --update-refs as an opt-in feature, but after thorough discussion with Elijah Newren, Patrick Steinhardt, Christian Couder, and Junio C Hamano we have made atomic ref updates the default behavior.

The git replay command currently outputs "update" commands that need to be piped to git update-ref --stdin:

git replay --onto main topic1..topic2 | git update-ref --stdin

This design had significant limitations for server-side operations. The two-command pipeline created coordination complexity, provided no atomic transaction guarantees by default, and complicated automation in bare repository environments where git replay is primarily used.

However the feedback revealed two critical issues with the original v1 approach:

When using individual ref updates (refs_update_ref calls) as proposed in v1:

  • Patrick Steinhardt identified severe performance degradation with the reftable backend
  • Individual updates bypass the efficiency of batched transactions
  • This approach contradicted Git's move toward batched operations across the codebase

When using confusing option names like --update-refs:

  • Christian Couder noted naming collision with git rebase --update-refs which serves a different purpose
  • The opt-in approach forced users to learn new flags for better behavior
  • Elijah Newren and Junio C Hamano suggested making atomic updates the default since git replay is marked experimental

This is resolved in this patch by making atomic ref updates the default behavior using ref_store_transaction_begin(). This provides the performance benefits of batched transactions while giving users atomic guarantees by default:

git replay --onto main topic1..topic2
# No output; all refs updated atomically or none

The second issue is fixed by introducing --output-commands to preserve the traditional pipeline workflow for users who need it:

git replay --output-commands --onto main topic1..topic2 | git update-ref --stdin

We also add --allow-partial which uses REF_TRANSACTION_ALLOW_FAILURE for cases where some ref updates may fail but others should succeed.

This change specifically addresses all mailing list feedback: \

• Eliminates individual ref updates completely (addressing Patrick's reftable performance concerns)
• Uses only batched ref transactions for optimal performance across all ref backends
• Avoids naming collision with git rebase --update-refs by using distinct option names
• Defaults to atomic behavior while preserving pipeline compatibility (Elijah and Junio's preference)
• Combines documentation with implementation in single commit (Christian's feedback)
• Uses proper die_for_incompatible_opt2() validation helpers (Patrick's code review)

Git mailing list: https://public-inbox.org/git/20250908043620.57848-1-siddharthasthana31@gmail.com/T/ \

Git #232

Edited by Siddharth Asthana

Merge request reports

Loading