Skip to content

Conversation

@mitchellwrosen
Copy link
Member

@mitchellwrosen mitchellwrosen commented Oct 27, 2025

Overview

This PR adds a diff.branch command that displays two two-way diff previews between the common ancestor of two branches, and each branch head:

Screenshot 2025-10-30 at 10 28 13 AM

Additionally, if the UCM_DIFFTOOL environment variable is set, it will be executed with variables $LOCAL, $REMOTE, $BASE, and $MERGED substituted, as described in https://git-scm.com/docs/git-difftool.

Note: I haven't found a good diff tool that actually looks at $BASE to 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:

Screenshot 2025-10-30 at 10 40 21 AM

Test coverage

I've added a transcript to capture the diff.branch output.

Loose ends

  • The diff.branch command 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_release will show the changes in new_release relative to old_release. However, that work is left for a future PR.
  • The diff.branch command 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.
  • The output message of diff.branch doesn't mention UCM_DIFFTOOL (i.e. "Tip: consider setting the UCM_DIFFTOOL environment variable as documented ") if it isn't set. Should it?
  • If UCM_DIFFTOOL process is configured but fails, that also is just silenced, not included in an output message.

@aryairani aryairani added this to the 1.0.0 milestone Oct 29, 2025
@mitchellwrosen mitchellwrosen marked this pull request as ready for review October 31, 2025 17:03
@mitchellwrosen mitchellwrosen merged commit f60764a into trunk Nov 4, 2025
59 of 60 checks passed
@mitchellwrosen mitchellwrosen deleted the 25-09-25-difftool branch November 4, 2025 15:46
@aryairani aryairani mentioned this pull request Nov 6, 2025
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.

3 participants