Skip to content

Fix commit graph order when using --all with date-order#5307

Open
bk-simon wants to merge 1 commit intojesseduffield:masterfrom
bk-simon:fix-5162-commit-graph-order
Open

Fix commit graph order when using --all with date-order#5307
bk-simon wants to merge 1 commit intojesseduffield:masterfrom
bk-simon:fix-5162-commit-graph-order

Conversation

@bk-simon
Copy link

Fixes #5162

Problem

When toggling "show whole git graph" before changing to "date order", the commit graph was displaying in the wrong order compared to the output of git log --graph --all --oneline.

Root Cause

The git log command was constructed with arguments in the wrong order:

git log HEAD --date-order --all

This caused git to apply date-order to HEAD first, then try to apply --all, resulting in incorrect graph ordering.

Solution

Moved the --all flag to appear before the refSpec:

git log --all HEAD --date-order

This ensures git applies the date-order sorting to the entire graph from all refs.

Testing

  • Existing unit tests all pass
  • The fix addresses the exact scenario described in the issue: toggling "show whole git graph" and then changing to "date order" now produces the correct commit order matching git log --graph --all --oneline

When toggling "show whole git graph" before changing to "date order",
the commit graph was displaying in the wrong order compared to the
output of `git log --graph --all --oneline`.

The issue was in the order of git log arguments. The command was
constructed as:
  git log HEAD --date-order --all

But git needs --all to appear before the refSpec for proper ordering:
  git log --all HEAD --date-order

This ensures git applies the date-order sorting to the entire graph
from all refs, not just from HEAD.

Fixes jesseduffield#5162
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.

incorrect commit graph (steps to reproduce available)

1 participant