Skip to content
This repository was archived by the owner on Mar 24, 2026. It is now read-only.

Limit git rev-list to one result#344

Merged
kenotron merged 2 commits intomicrosoft:masterfrom
reillysiemens:limit-rev-list
Mar 24, 2025
Merged

Limit git rev-list to one result#344
kenotron merged 2 commits intomicrosoft:masterfrom
reillysiemens:limit-rev-list

Conversation

@reillysiemens
Copy link
Copy Markdown
Member

Currently getFileAddedHash gets all commits that changed the given path and then discards all but the first result. By using --max-count=1 we can avoid getting more commits than necessary. This can lead to significant performance improvements in large repos.

Copy link
Copy Markdown

@derrickstolee derrickstolee left a comment

Choose a reason for hiding this comment

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

Contributing my 👍 even though we paired on this. The git rev-list --max-count=1 parameter is understood for Git versions in at least the last 15 years.

We've seen that this speeds up the command significantly even when there is only one result, as long as that result is in the recent history. Git keeps looking for more versions even when the file disappears (since it was added recently).

@kenotron kenotron merged commit fb38907 into microsoft:master Mar 24, 2025
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants