Skip to content

Conversation

gerhardol
Copy link
Member

@gerhardol gerhardol commented Jun 22, 2025

fixes #12413
fixes #12464

Proposed changes

Improve performance (especially for lfs files) to display the file tree if no grep filter is active.
See the issue for the reduced time to run the command.

This could be moved to GitModule instead.
GitModule is a better place for checking that

Note: ls-tree cannot be used for artificial commits, but ls-files could be used
That is a separate optimization

Test methodology

view manual git log

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

Copy link
Member

@pmiossec pmiossec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great: 138ms instead of 17s.

@pmiossec
Copy link
Member

@gerhardol I don't know if you noticed but it has the strange side effect that in the filetree, all the files are displayed with the 'add' icon instead of the file type icon (until the grep command is run and after that the icons are good):
image

@mstv
Copy link
Member

mstv commented Jun 24, 2025

@gerhardol I don't know if you noticed but it has the strange side effect that in the filetree, all the files are displayed with the 'add' icon instead of the file type icon (until the grep command is run and after that the icons are good)

I have noticed this, too. I think I will see the cause when I am going to review this later.

@mstv mstv added this to the v6.0.1 milestone Jun 24, 2025
Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The major change LGTM.
It needs two additions:
29d9822
dc2d21c

@gerhardol gerhardol force-pushed the feature/i12413-file-filter branch from 45dd640 to ec0ce1a Compare June 24, 2025 22:08
@gerhardol
Copy link
Member Author

There is something still that is not right, but it probably works:
If grep status is set once, icon is updated from that on without manipulating the status (why I got it working without the grep string). But GitItemStatus is set with prefix:
summary: $"{_grepSummaryPrefix}{_fileStatusDiffCalculatorInfo.GrepArguments} {GetDescriptionForRevision(selectedRev.ObjectId)}",

@mstv
Copy link
Member

mstv commented Jun 25, 2025

There is something still that is not right, but it probably works: If grep status is set once, icon is updated from that on without manipulating the status (why I got it working without the grep string).

This is not wrong: Icons are cached. If they have already been loaded, they can be used at once.
The loading of icons is triggered for git-grep results only because actual status items have their special icon.

But GitItemStatus is set with prefix: summary: $"{_grepSummaryPrefix}{_fileStatusDiffCalculatorInfo.GrepArguments} {GetDescriptionForRevision(selectedRev.ObjectId)}",

How is this related to this PR?
This summary is used for diff groups (FileStatusWithDescription) but not for single items (GitItemStatus).
For file tree, there is only one "group" without heading.

@gerhardol
Copy link
Member Author

How is this related to this PR?
This summary is used for diff groups (FileStatusWithDescription) but not for single items (GitItemStatus).
For file tree, there is only one "group" without heading.

I fixed this
The icon was set from the GitItemStatus properties. The check for grepstring was not first but before added.
But there is no pint to look at the status if we know the grep/filetree status already.
The update is slightly shorter and less risky for similar changes

@gerhardol gerhardol marked this pull request as draft June 25, 2025 22:47
@gerhardol
Copy link
Member Author

submodules are not displayed correctly after my latest change

@gerhardol gerhardol force-pushed the feature/i12413-file-filter branch from 334ffde to ec097fc Compare June 26, 2025 22:19
@gerhardol gerhardol marked this pull request as ready for review June 26, 2025 22:21
@gerhardol
Copy link
Member Author

gerhardol commented Jun 26, 2025

Two commits added, left a branch behind and squashed and rebased
ls-files works fine, could remove the special submodule handling too. Some optimizations, probably not possible to see. (I belive that there are no additional async added.)
Limitations in git-doc should be updated.

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works well and fast for me, have not tested with removed submodule
In GetLsTreeOutput for GitTreeParserTests.Parse_should_return_the_list, the '\n' need to be replaced with '\0'.

@gerhardol
Copy link
Member Author

have not tested with removed submodule

A removed subm is not included in the output, except for git ls-files --no-cached
The attempt to get data is obviously failing
This is a Git issue, ignore

image

Before the subm information could be incorrect, the following lists also the removed

HEAD
image

index
it is a bug to attempt getting the treeid here
image

worktree
image

--
In diff the behavior is the same as before
New submodule is wrong, but the subm info is not available

image

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is actually more efficient than just
return items.Select(ParseSingle).WhereNotNull();

(The implementation of WhereNotNull could be turned into Where(item => item is not null) in order to let the IL compiler optimize it. I guess there is also a cost to the statemachine for IEnumerable and yield.)

@gerhardol
Copy link
Member Author

If it is actually more efficient than just return items.Select(ParseSingle).WhereNotNull();

(The implementation of WhereNotNull could be turned into Where(item => item is not null) in order to let the IL compiler optimize it. I guess there is also a cost to the statemachine for IEnumerable and yield.)

Do you suggest to change to
items.Select(ParseSingle).WhereNotNull();

@mstv
Copy link
Member

mstv commented Jun 29, 2025

Do you suggest to change to

I assume you have changed it because it costs less time / allocations. Then, no.
(When using WhereNotNull, it should be simplified so that the compiler can apply its LINQ optimizations.)

@gerhardol gerhardol force-pushed the feature/i12413-file-filter branch from 7a9b273 to 392f338 Compare June 29, 2025 14:00
@gerhardol
Copy link
Member Author

gerhardol commented Jul 29, 2025

added commit for #12464

edit: also used a few lines from the followup in in #12436 for the #12464 change

@gerhardol gerhardol force-pushed the feature/i12413-file-filter branch from 392f338 to 2abd635 Compare July 30, 2025 13:31
as well as ls-files for artificial commits.
This improves the performance (especially for lfs files) to display
the file tree if no grep filter is active.

Some cleanup for special cases for icons in FileStatus.

Optimizations for parsing file trees in GitModule.

Simplification of merge commit check in CalculateDiffs().

Co-authored-by: <mstv@gmx.net>
@gerhardol gerhardol force-pushed the feature/i12413-file-filter branch from 7df22af to 49d9da5 Compare August 7, 2025 16:27
@gerhardol
Copy link
Member Author

squashed, rebased and added #12436 (comment)
Plan to merge tomorrow together with #12421

@gerhardol gerhardol merged commit f9cd1dd into gitextensions:master Aug 10, 2025
3 of 4 checks passed
@gerhardol gerhardol deleted the feature/i12413-file-filter branch August 10, 2025 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[NBug] Sequence contains more than one matching element First opening of file tree is slow
4 participants