Skip to content

Show index changes in the main view when filtering by file - #1451

Open
halfcrazy wants to merge 1 commit into
jonas:masterfrom
halfcrazy:show-changes-when-filtering
Open

Show index changes in the main view when filtering by file#1451
halfcrazy wants to merge 1 commit into
jonas:masterfrom
halfcrazy:show-changes-when-filtering

Conversation

@halfcrazy

@halfcrazy halfcrazy commented Sep 8, 2026

Copy link
Copy Markdown

When filtering the main view by file (e.g. tig -- foo), the changes commits ("Staged/Unstaged/Untracked changes") often fail to appear. As noted in #592, the current heuristic anchors them to the current branch commit: main_register_commit() only adds them when it encounters the HEAD commit in the git log output. With pathspec filtering, git's history simplification may prune the HEAD commit itself (e.g. when HEAD is a TREESAME merge), so the anchor never appears and no changes commits are shown at all. If the filtered path has no commit history at all, tig simply dies with "No revisions match the given arguments."

This change:

  • Anchors the changes commits to the first commit of the filtered log, which is guaranteed to be rendered, so they stay at the top of the view with the graph edge intact. When the filtered log is empty, they are added on their own, which also makes paths without any commit history show their index changes instead of dying.
  • Limits the index_diff() check to the filtered files, so changes commits are only shown when the filtered paths actually have changes (this is the other half of the stash posted in tig with filename on the command line doesn't show changes to that file #592).

Adds a regression test covering: HEAD pruned by history simplification, filtered paths without changes, and filtered paths without history.

Fixes #592

@halfcrazy
halfcrazy force-pushed the show-changes-when-filtering branch from 1b3d925 to 2900aec Compare September 9, 2026 01:06
When filtering by file, history simplification may prune the HEAD
commit from the log, leaving main_register_commit() without a place
to anchor the changes commits. As a result, staged, unstaged and
untracked changes were not shown at all in filtered main views.

Anchor the changes commits to the first commit of the filtered log
instead so they stay at the top of the view, or add them on their
own when the filtered log is empty. Also limit the index check to
the filtered files so changes commits are only shown when the
filtered paths have changes. This makes the main view usable for
paths without any commit history instead of dying with "No
revisions match the given arguments." when the paths have index
changes.

The index check runs in the current directory so relative file
arguments resolve like they do for the main view, and is only
limited to the file arguments while file filtering is enabled.

Fixes jonas#592
@halfcrazy
halfcrazy force-pushed the show-changes-when-filtering branch from 2900aec to 28bbb7f Compare September 9, 2026 01:35
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.

tig with filename on the command line doesn't show changes to that file

1 participant