-
Notifications
You must be signed in to change notification settings - Fork 291
Add branch.diff command
#5962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add branch.diff command
#5962
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aryairani
approved these changes
Nov 1, 2025
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds a
diff.branchcommand that displays two two-way diff previews between the common ancestor of two branches, and each branch head:Additionally, if the
UCM_DIFFTOOLenvironment variable is set, it will be executed with variables$LOCAL,$REMOTE,$BASE, and$MERGEDsubstituted, as described in https://git-scm.com/docs/git-difftool.Note: I haven't found a good diff tool that actually looks at
$BASEto produce a three-way diff. One popular one, delta, seems to only render three-way diffs if it's given a file with zdiff3-style markers in it. So, we may want to do something like that instead of the current implementation.Nonetheless, with this PR, you can at least get an off-the-shelf tool to show a two-way diff between two branch heads, which might look like:
Test coverage
I've added a transcript to capture the
diff.branchoutput.Loose ends
diff.branchcommand can't currently produce a diff between two branches that don't have a shared history. In this case, the plan is to treat the left argument as the LCA, so that (e.g.)diff.branch old_release new_releasewill show the changes innew_releaserelative toold_release. However, that work is left for a future PR.diff.branchcommand doesn't currently render changes to library dependencies. That's not hard to do, I just left it off this PR and intend to follow up.diff.branchdoesn't mentionUCM_DIFFTOOL(i.e. "Tip: consider setting theUCM_DIFFTOOLenvironment variable as documented ") if it isn't set. Should it?UCM_DIFFTOOLprocess is configured but fails, that also is just silenced, not included in an output message.