Skip to content
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

Search in git history #79

Open
aciceri opened this issue Jan 31, 2025 · 1 comment
Open

Search in git history #79

aciceri opened this issue Jan 31, 2025 · 1 comment

Comments

@aciceri
Copy link

aciceri commented Jan 31, 2025

@zkry Probably the discussion section on GitHub would be better for this but it looks that it's not enabled for this repository.

I've no idea if this is really doable and how coherent with p-search goals is, but I would love to also see candidates from past commits, similar to what one gets with git grep "string" $(git rev-list <commit_a>..<commit_b> (probably searching across all commits by default may be a bad idea, especially on big/old repos...)

What do you think?

@zkry zkry added this to the 2025 - Milestone 1 milestone Feb 1, 2025
@zkry
Copy link
Owner

zkry commented Feb 1, 2025

Thanks for reaching out! As it turns out, this is a feature that has crossed my mind too and is definitely in line with what p-search is intended for. There are a couple of ways that this could be implemented with varying levels of effort. I'll write my initial thoughts for future reference when I'm available to work on this:

Perhaps the simplest way to implement this would be to add a new search tool (alongside the currently existing rg, ag, grep) for git grep. This should be a rather simple way to implement this, except there'd need to be a way to specify commit ranges for which nothing exists yet.

Other possible implementations are:

  • creating a new candidate generator specifically to search git history. This could then set the content to be the history of all revisions. There could be a candidate for each revision.
  • A mapping could be created to tack-on the contents of specified revisious. Search for this would be slow though and incorporating this with git grep rouldn't be trivial.
  • Create a specialized prior for git repositories to do git grep. This would require re-implementing the BM25 algorithm. Also, there would be no way to view the preview the match if it was in a previous revision.

I'll add this feature to my batch of upcoming features to work on.

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

No branches or pull requests

2 participants