NeogitOrg / NeogitOrg/neogit

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

Open
#1,948 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
5.6k
Forks
357
Avg merge
15h 47m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the commit view entry points that assemble git show <commit> and git show --stat <commit>. Compare merge-commit output with --diff-merges=first-parent, then determine how the selected default or configuration should affect both views; the work is done when the agreed strategy is applied consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, lua, neovim
Domain
cli, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.