-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
git-grep UI #11350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git-grep UI #11350
Conversation
72c412b
to
e2fef91
Compare
Just a point. Not saying git grep shouldn't be used. Just saying ripgrep is very speedy. So if searching working directory vs git history. |
To clarify if someone is wondering: This feature is primarily to search Git commit history without a checkout. This feature is not really competing with searching in the worktree. Searching in the editor and specific tools will normally be a better choice. |
If noone has any other preferences, I plan to add an extra searchbox to diff. |
e2fef91
to
1ce8926
Compare
My 2ct: This feature seems to be pretty related to the "Find" function - particularly to "Find all" in IDEs. I guess I would use it more often if the search could be limited to the changes instead of searching the entire file tree of the selected commit (which can be useful in other cases). The detection of "-e" does not work in all locations. I have tried to ignore the character case: |
It is similar to Find all, but only for the files in Git and only for the selected commit, you do not have to check out the commits.
"Find & highlight all" is only for current file, should be renamed (moved to context menu in fileviewer?).
git-grep works quite different from current find, so a separate popup is probably better than a combined form - maybe a button to switch to the other form. But I may prefer the searchbox anyway, you can search interactively, get feedback faster.
git-grep cannot search the diff, that would be a completely different algorithm.
Will try to tweak this. |
I prefer code browsing in an IDE ("go to definition", "browse references", "exclude unit tests"). So I guess I will use grep rarely and rather save the space in favor of the Git Output Control.
I think this is acceptable for the Diff tab - especially as grep is kind of a generalization of "find file". And one can quickly switch to the File Tree. |
1ce8926
to
6aa88a8
Compare
Implemented a searchbox.
Will squash if mstv agrees |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will squash if mstv agrees
I have not looked into the code yet.
mstv wanted to search with a popup instead. That could be added in addition to the searchbox, the box could be hidden.
My main point is that I do not want this searchbox to consume space all the time because I will rarely use it.
I admit it is really quick and it can be (mis-)used to get all files for the artificial commits (by searching for ".").
Could we add a toggle button right of the Filter files
box?
Though it would need to remain visible if there are "No changes".
... which does not look good (distracting) in the current state IMO:
SearchWatermarkLabel.Location = new Point(4, 27); | ||
SearchWatermarkLabel.Name = "SearchWatermarkLabel"; | ||
SearchWatermarkLabel.Size = new Size(184, 13); | ||
SearchWatermarkLabel.Text = "Search files in revision using a regular expression..."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❔
SearchWatermarkLabel.Text = "Search files in revision using a regular expression..."; | |
SearchWatermarkLabel.Text = "Search text in all files of revision using a regular expression..."; |
might be clearer
If you have not reviewed the previous code, I assume I can squash.
I rather have an enable toggle in the context menu as for Show file differences popup would be a way to configure the options though, maybe additional control. |
It is useful to filter grep files too, grep and filter are not exclusive. The POC I had initially separating with :: was better this way... Maybe the popup is needed. I still like the extra search bar, may want to keep it as an option. Edit: Would a hidden feature searching with :: in filter be acceptable for an initial merge, keeping as a hidden feature, to get some way of feedback? |
Having it in one line with "::" feels too cryptic to me. In case of "no changes", I would always hide the search bar - but not change the setting. |
I am adding a configuration, default off, maybe even a popup. I want the options to be persistent though, not just runtime.
Yes, in the same way as the filterbox is hidden if no changes. |
That's what
Not exactly, the search box still makes sense for empty commits. The user should be able to activate it. |
57e818c
to
075e8b1
Compare
I've incorporated this branch into my custom build and have already made use of it at least 3 times. Loving it! At the same time I am getting strong vibes that GitExtensions is turning in the kind of software where one needs to watch a youtube video or someone else using it to learn of these power-user features. Regardless, I still welcome this feature! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works better
Choosing an entry from the dropdown
- clears the search string of the FileStatusList
- in the Search form affects the FileStatusList at once - intentionally?
- should set the cursor behind the search string
- using cursor keys is not possible (only the first two entries can be reached)
Activating the Search button should keep the cursor position.
Combobox handling is complex - the toolbar filter comboboxes are horrible.
Added back the text assignment in dropdown update, but moving the cursor to the end.
It was intentional, but I changed it to avoid the strange workarounds in FormSearchCommit
This occurred when the dropdown was updated and in the list but not the latest.
It is either keeping the list as a last-recently used sorted (this toggles the order) or just having a fifo queue.
In the popup, occurred when the list was resorted. The list is not saved in settings and I set it to 30 items, it is maybe not a problem to have it as fifo. Maybe even skip a maximal size, then most special handling can be removed? Note: popup search is by Enter only. The optional combobox is when typing, both because I prefer it that way and because Enter is not seen by the control. |
Yes, it is. It works much better now. I would not switch to FIFO mode and throw away the working code. Remaining point: When changing the search string using the FileStatusList, only the dropdown of the SearchForm combobox is updated but not its text. |
👍 35bdaec works well. Just focus the search form on context menu and hotkey yet, please. |
Do you mean when the popup is already open? |
I mean 563c1cf |
Thanks (you could have pushed to my branch directly, if I had not liked it I would revert...) Setting Location was intentional, to avoid that the popup got lost. Also a minor tweak. I am sure there will be more tweaks to the functionality when there are more users |
Would like to change this back so when using the hotkey/menu to invoke git-grep popup, show it at the default location. |
My usecase: Fingers at keyboard and wanting to focus the search form using |
Not how I use it, but I rather accept this and move on. |
@gerhardol do we have any docs on how to use this feature? It took me awhile to find that I have to use CTRL + SHIFT + F to open the new dialog, and I'm fairly certain our users won't find that easily. |
More info in the PR.
The name of the function settled on "Search files in commit" not including git-grep. Mentioning the Git concept could be good, but "Search files in commit with gith git-grep using a regular expression" is quite long |
This is a good description for the docs. 😉 |
Align names: FindInCommitFilesGitGrep in names (not Using) Find in commit files using git-grep in texts Addendum to gitextensions#11350
Align names: FindInCommitFilesGitGrep in names (not Using) Find in commit files using git-grep in texts Addendum to gitextensions#11350
Align names: FindInCommitFilesGitGrep in names (not Using) Find in commit files using git-grep in texts Refs: gitextensions#11858, addendum to gitextensions#11350
Fixes #4912
Depends on #11590 , only 92d937e (and forward if added later) to be reviewed
Proposed changes
An UI for git-grep, to search commits without checking out those commits. (When working with this I have often used it to view worktree too.)
https://git-scm.com/docs/git-grep
The UI in this PR adds a popup as well as a searchbox to the Diff tab.
The searchbox dropdown has the search history for the GE session, not persistent.
The popup and searchbox are kept in sync.
Search in the popup is done when button is pressed (or Enter),
the diff tab box is searching when typing (similar in the filter).
If there is no
-e
in the search string, this is added to the search string.Most git-grep options can be added, including
--and
etc.git-grep options to handle case insensitive is available, but most options can be added in the searchbox.
Persistent options can be added too for instance
--show-function
.The output of git-grep is always for a commit, including index and worktree.
Note that the selected file in the grep group is not always followed when a new commit is selected, as it is not the primary group. This could be specially handled (but "grep" knowledge need to be added to RevDiff).
Performance
In the Git repo, the git-grep requires about 200 ms for me, the information is added async after normal diff so no visible.
For the Linux repo, git-grep can require several seconds. As the current search is aborted when a new is started, works fine for me.
The processing in the fileviewer is faster than for normal diffs.
Limitations are basically the same as #11590 ,missing
Screenshots
After
The popup window and the optional FileStatusList combobox

Example usage.

Test methodology
Manual
Merge strategy
squash.
✒️ I contribute this code under The Developer Certificate of Origin.