Show index changes in the main view when filtering by file - #1451
Open
halfcrazy wants to merge 1 commit into
Open
Show index changes in the main view when filtering by file#1451halfcrazy wants to merge 1 commit into
halfcrazy wants to merge 1 commit into
Conversation
halfcrazy
force-pushed
the
show-changes-when-filtering
branch
from
September 9, 2026 01:06
1b3d925 to
2900aec
Compare
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
force-pushed
the
show-changes-when-filtering
branch
from
September 9, 2026 01:35
2900aec to
28bbb7f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 thegit logoutput. 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:
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