ArticlesLeer en españolLire en français
ArticleBy Piotr MyszkiewiczPublished: Nov 26, 20264 min read

Review a Revised Agent Patch with Git range-diff

You reviewed a patch that raised the retry limit from two attempts to three. After you asked a coding agent to revise it, the branch still contained one commit titled “Define retry policy.” Would your approval cover the new version? In our example, the second draft quietly raised the limit to five. The commit title stayed the same.

Git range-diff compares two versions of a patch series. It helps a reviewer find which commits deserve a second look after an agent amends or rebases its work. A file comparison answers a different part of the review: what would actually change in the resulting tree? In this example you need both views. Git range-diff manual

Save the version you reviewed

On the feature branch, before requesting revisions, save a local branch pointing at the reviewed commit. For a series based on the current main branch, you can also save its common ancestor. Choose unused names for these references.

git branch review-v1 HEAD
git branch review-base "$(git merge-base main HEAD)"

Once the agent has committed the revision, compare the two series. This invocation assumes the revision still has the same base.

git range-diff review-base..review-v1 review-base..HEAD

Each range selects the feature commits after its base. If the agent also rebased onto a newer main, use the actual new base on the right. Comparing the two tips directly in that case can include unrelated upstream edits. Uncommitted edits also need a separate look with git diff.

Two revisions branch from a retry limit of two. The reviewed draft sets three attempts and the revised draft sets five.
Both drafts change the same setting from the same base. Comparing their final files reveals the extra two attempts. Diagram: sAIgnals.

Read the result when Git cannot match two commits

We ran a small local example with Git 2.47.0. Both drafts changed a single line of retry.conf. Git's default matching reported one commit on the left and one on the right, each without a partner. The commit subjects were identical. Here is the observed output:

1:  701adc8 < -:  ------- Define retry policy
-:  ------- > 1:  4fdb38d Define retry policy

Read the left arrow as “only in the first series” and the right arrow as “only in the second.” Git estimates which patches correspond. An unmatched pair is a reason to open the files before approving. When it does find a pair, an equals sign denotes an unchanged patch and an exclamation mark flags a difference. Git documents the matching algorithm and describes the output as intended for human readers. How Git pairs commits

Here the two versions shared the same base, so we compared their final file directly:

git diff review-v1 HEAD -- retry.conf

The old line was max_attempts=3 and the new line was max_attempts=5. Backoff and timeout were unchanged. That gives the reviewer a specific question for the agent or author: why should a failed request now get two more attempts? A passing test that checks only whether a request eventually succeeds might miss that change.

Reproduce the example

Download the example shell script, inspect it, then run it locally:

sh git-range-diff-retry.sh

The script creates a fresh temporary repository, commits the two-attempt baseline, saves the first revision under a tag, then amends the commit and prints both comparisons. It uses Git and standard Unix shell utilities. Commit IDs vary with commit metadata. The script exercises Git on synthetic data and requires no model account.

For one file on an unchanged base, the direct file diff may be all you need. Reach for range-diff when the review spans several commits and you want to recover the structure of the earlier review. Then open the affected files and run the checks that establish the intended behavior. Git diff reference

Your next step

Keep building with Codex

Explore Codex updates and practical guides in one place.

Explore Codex →

Keep up at your pace

Get useful changes, a workflow to try, and a repository to explore. Choose a twice-weekly, weekly or monthly briefing.

Preview the briefing and subscribe →

Explore these tool hubs

CodexClaude Code

Related guides

4 min readWhat Is Kody Koala? Shared Memory, Tools, and Automations for Your AI Agents

Build a weekly merged-PR report in Kody, share it between Claude Code and Codex, and check its results, permissions, and scheduled-job costs.

11 min readThree Trending AI Repositories for Outputs You Can Inspect

Univer, ffmpeg-skill and AG-UI: editable office content, local media tools and agent interfaces, with setup, licenses and practical limitations.

7 min readFind the Commit That Broke Your App with Git Bisect

Use a repeatable check and a disposable worktree to locate a regression before asking an AI agent to fix it. Includes a runnable, locally verified demo.