Skip to content

[pre-push] Remove redundant local refs/gherrit/ creation#269

Merged
joshlf merged 1 commit intomainfrom
Gd0071e39b5188a2f146a2f9f5899f0e3fdf1da83
Jan 20, 2026
Merged

[pre-push] Remove redundant local refs/gherrit/ creation#269
joshlf merged 1 commit intomainfrom
Gd0071e39b5188a2f146a2f9f5899f0e3fdf1da83

Conversation

@joshlf
Copy link
Owner

@joshlf joshlf commented Jan 20, 2026

This change removes the create_gherrit_refs step from the pre-push
hook workflow. Previously, this step created local refs/gherrit/<ID>
references pointing to the commits in the stack before attempting to
push them.

The core synchronization logic in push_to_origin operates directly on
commit objects and does not read these local references. They were
effectively unused by the internal logic and served only as local
"bookmarks" for the user.

Crucially, removing this step eliminates a potential "torn state" bug
regarding local consistency. Previously, create_gherrit_refs would
update local references before the network push occurred. If the
subsequent git push failed (e.g., due to network error or an
optimistic locking failure on the server), the local refs/gherrit/<ID>
would be updated to the new commit, but the remote state and local
version tags would effectively still be "old."

By removing these intermediate refs, we ensure that the state is atomic:
either the push succeeds and version tags are persisted, or the push
fails and no local state is modified.

Makes progress on #264


Latest Update: v3 — Compare vs v2

📚 Full Patch History

Links show the diff between the row version and the column version.

Version v2 v1 Base
v3 vs v2 vs v1 vs Base
v2 vs v1 vs Base
v1 vs Base

@gemini-code-assist
Copy link

Summary of Changes

Hello @joshlf, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the pre-push hook by removing the creation of redundant local refs/gherrit/<ID> references. This change streamlines the push process, eliminates unnecessary local state management, and critically, resolves a race condition that could lead to inconsistent local and remote states if a network push failed. The overall impact is improved robustness and atomicity of the Git push operation within the gherrit system, accompanied by relevant documentation and test utility updates.

Highlights

  • Removal of Redundant Local References: The create_gherrit_refs step, which previously created local refs/gherrit/<ID> references in the pre-push hook, has been eliminated. These local references were found to be unused by the core synchronization logic.
  • Resolution of "Torn State" Bug: This change addresses a potential "torn state" bug where local refs/gherrit/<ID> could be updated before a network push completed. By removing these intermediate refs, the system now ensures atomicity: either the push fully succeeds and version tags are persisted, or it fails and no local state is modified.
  • Documentation Update: The AGENTS.md documentation has been updated to accurately reflect the revised process, stating that refs/gherrit/<id> are now pushed directly to the remote, rather than being created locally first.
  • Test Utility Enhancement: A new gherrit_id helper function has been added to the test utilities. This function simplifies the extraction of the gherrit-pr-id from commit messages, improving the readability and maintainability of integration tests.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly removes the creation of redundant local refs/gherrit/ references, which improves the atomicity of the push operation and resolves a potential 'torn state' bug. The changes are well-contained, and the documentation and tests are updated accordingly. I have one suggestion on the new test helper function to improve the maintainability of the test suite by abstracting common command execution logic.

This change removes the `create_gherrit_refs` step from the pre-push
hook workflow. Previously, this step created local `refs/gherrit/<ID>`
references pointing to the commits in the stack before attempting to
push them.

The core synchronization logic in `push_to_origin` operates directly on
commit objects and does not read these local references. They were
effectively unused by the internal logic and served only as local
"bookmarks" for the user.

Crucially, removing this step eliminates a potential "torn state" bug
regarding local consistency. Previously, `create_gherrit_refs` would
update local references *before* the network push occurred. If the
subsequent `git push` failed (e.g., due to network error or an
optimistic locking failure on the server), the local `refs/gherrit/<ID>`
would be updated to the new commit, but the remote state and local
version tags would effectively still be "old."

By removing these intermediate refs, we ensure that the state is atomic:
either the push succeeds and version tags are persisted, or the push
fails and no local state is modified.

Makes progress on #264

gherrit-pr-id: Gd0071e39b5188a2f146a2f9f5899f0e3fdf1da83
@joshlf joshlf force-pushed the Gd0071e39b5188a2f146a2f9f5899f0e3fdf1da83 branch from f9d72eb to 2b19bc6 Compare January 20, 2026 02:03
@joshlf joshlf merged commit de98e7e into main Jan 20, 2026
1 check passed
@joshlf joshlf deleted the Gd0071e39b5188a2f146a2f9f5899f0e3fdf1da83 branch January 20, 2026 02:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant