Skip to content

Commit view should use first-parent diff for merge commits, or make merge diff strategy configurable #1948

@tcstory

Description

@tcstory

Problem

When opening a merge commit in Neogit's commit view, the displayed diff uses Git's default merge diff behavior.

For merge commits, this is often not the most useful view when reviewing history on the main branch. In practice, I would expect the commit view to show the changes introduced to the first parent (mainline), i.e. the equivalent of:

git show --diff-merges=first-parent <merge-commit>

instead of the default combined merge diff.

Why this is confusing

For a merge commit on master or main, the most natural review question is usually:

"What did this merge introduce to the main branch?"

That corresponds to diffing the merge commit against its first parent.

The current behavior makes merge commits harder to read, because the combined diff mixes both parents and can make the result feel like it is biased toward the merged branch instead of the target branch.

Example

Suppose master has a merge commit like:

  • first parent: master
  • second parent: feat/modify-a

In commit view, I would expect Neogit to show the diff relative to the first parent (master), not the default combined merge diff.

Expected behavior

One of these would solve the issue:

  1. Use first-parent diff in commit view for merge commits by default.
  2. Add a configuration option for commit view merge diff strategy, for example:
    • default / combined
    • first-parent

Possible implementation direction

It looks like commit view currently builds its contents from git show <commit> and git show --stat <commit>.

For merge commits, using --diff-merges=first-parent would make the view align better with mainline history review.

Environment

  • Neovim: NVIM v0.11.6
  • Neogit: e0674522
  • Git: git version 2.53.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions