-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Fix index out of bounds panic when repository has massive tags #4776
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
Fix index out of bounds panic when repository has massive tags #4776
Conversation
Thanks for the fix. Please edit the PR description, this only fixes #4765, but not #4770. You should change the order of the fields so that extraInfo comes second to last, right before the message. The reason is that parentHashes and divergence are essential fields that we should never skip; extraInfo and message are the ones that are only used for display, so it's not that bad if we lose them. (Might be good to make this change in a separate commit, like I did in e0a2d97.) |
77b01ca
to
d61ea8d
Compare
@stefanhaller Thanks, I updated the order. |
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.
Thanks, looks great now, except for a small nitpick below.
if len(split) > 5 { | ||
parentHashes = split[5] | ||
if len(split) > 4 { | ||
parentHashes = split[4] |
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.
I think it would make more sense to increase the if len(split) < 5 {
above to 7 in this commit, and access the parentHashes and divergence fields unconditionally; they will never be missing (unless you have a commit with thousands of parent commits, which is not going to happen).
Of course, the commit history would be a lot cleaner if you had swapped the first two commits, but I can understand if you don't want to go to the trouble now. (If this were my PR, I'd do it. 😉)
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.
Yeah I think that's right. I updated pr to access parentHashes and divergence unconditionally.
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.
Ok, I really dislike commit histories that go back-and-forth like this, so I spent some time cleaning up and squashing the commits to make them reviewable.
Also, I added a fixup commit for amending the new tests with actual commit expectations; for an extractCommitFromLine
test it makes sense to test the data that was extracted, rather than check if it succeeded. Please have a look; I think this is ready to merge now.
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.
Thanks. I checked it.
…ormat Like message, extraField can get very long (when there are thousands of tags on a single commit), so move it to the end; this allows us to truncate overly long lines in the output and still get all the essential fields. Co-authored-by: Stefan Haller <[email protected]>
911c6a1
to
dd53ed2
Compare
Co-authored-by: Stefan Haller <[email protected]>
dd53ed2
to
1c67093
Compare
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [jesseduffield/lazygit](https://github.com/jesseduffield/lazygit) | minor | `v0.53.0` -> `v0.54.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jesseduffield/lazygit (jesseduffield/lazygit)</summary> ### [`v0.54.0`](https://github.com/jesseduffield/lazygit/releases/tag/v0.54.0) [Compare Source](jesseduffield/lazygit@v0.53.0...v0.54.0) <!-- Release notes generated using configuration in .github/release.yml at v0.54.0 --> Again we don't have any major new features this time (unless you count the support for alt-backspace for deleting words in the commit message editor, which is one of my favorite additions), but lots of smaller quality-of-life improvements and bug fixes. The most notable one is probably the fix for the stale index.lock problem, which was a very long-standing bug that seemed to affect some users much more than others for some reason. #### What's Changed ##### Enhancements 🔥 - Add confirmation for hard reset by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4704 - Provide user config defaults for UI-changeable settings by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4717 - Improve mouse handling of suggestions panel by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4726 - Add new command "Checkout previous branch" by [@​kyu08](https://github.com/kyu08) in jesseduffield/lazygit#4728 - Add confirmation for nuking the working tree by [@​DawidPietrykowski](https://github.com/DawidPietrykowski) in jesseduffield/lazygit#4727 - Support Alt+Backspace for word deletion in text areas by [@​rtzll](https://github.com/rtzll) in jesseduffield/lazygit#4741 - Don't use hunk mode for added or deleted files even when useHunkModeInStagingView config is on by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4758 - Show \[0] keybinding in main view title by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4754 - Draw divergence from base branch right-aligned in branches view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4785 - Enable hunk staging mode by default by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4780 ##### Fixes 🔧 - Fix scrolling hunk into view when selecting next hunk by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4709 - Fix stale main view content when entering/exiting filtering view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4719 - Detect double-clicks properly by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4725 - Fix commit searching during rebase or in divergence from upstream view by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4730 - Fix amending commits whose commit message is empty by [@​aidancz](https://github.com/aidancz) in jesseduffield/lazygit#4732 - Several small fixes to filtering mode (by path or author) by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4749 - Show diff for renamed file when filtering by path by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4750 - Allow rewording or dropping commits in filtering mode by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4756 - Fix index out of bounds panic when repository has massive tags by [@​chojs23](https://github.com/chojs23) in jesseduffield/lazygit#4776 - When pressing `a` to stage all files, don't include untracked files when showing only tracked files by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4779 - Fix commit hash colors when filtering by path or aythor by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4789 - Improve temp dir handling by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4784 - Terminate git processes more gracefully to avoid the stale index.lock problem by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4782 ##### Maintenance ⚙️ - Raise sponsors MRs as a draft by [@​jesseduffield](https://github.com/jesseduffield) in jesseduffield/lazygit#4694 - Update the peter-evans/create-pull-request action to v7 by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4695 - Update release workflow by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4703 - Clean up the .gitignore file by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4706 - Remove unused code and texts by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4715 - Remove deprecated edit configs by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4716 - Bump minimum required git version to 2.32 by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4718 - Use a better way of pinning the version of golangci-lint by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4733 - Make the minimum required git version a placeholder in the error text by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4778 - refactor: use slices.Equal to simplify code by [@​jishudashu](https://github.com/jishudashu) in jesseduffield/lazygit#4764 ##### Docs 📖 - Fix broken markdown in auto-generated keybindings documentation by [@​KEY60228](https://github.com/KEY60228) in jesseduffield/lazygit#4690 - Remove the homebrew tap from the readme by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4705 ##### I18n 🌎 - Update translations from Crowdin by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4791 ##### Performance Improvements 📊 - Fix performance regression on startup in repos with many tags by [@​stefanhaller](https://github.com/stefanhaller) in jesseduffield/lazygit#4777 #### New Contributors - [@​KEY60228](https://github.com/KEY60228) made their first contribution in jesseduffield/lazygit#4690 - [@​DawidPietrykowski](https://github.com/DawidPietrykowski) made their first contribution in jesseduffield/lazygit#4727 - [@​rtzll](https://github.com/rtzll) made their first contribution in jesseduffield/lazygit#4741 - [@​chojs23](https://github.com/chojs23) made their first contribution in jesseduffield/lazygit#4776 - [@​jishudashu](https://github.com/jishudashu) made their first contribution in jesseduffield/lazygit#4764 **Full Changelog**: jesseduffield/lazygit@v0.53.0...v0.54.0 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0MS40Ni43IiwidXBkYXRlZEluVmVyIjoiNDEuNDYuNyIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90Il19-->
Fixes an index out of bounds panic that occurs when lazygit starts up in repositories with a large number of tags on a single commit.
When a commit has thousands of tags, the git log output can become malformed or truncated, causing the
extractCommitFromLine
function to receive fewer than the expected 8 null-separated fields. This results in an index out of bounds panic when trying to accesssplit[5]
and beyond.Closes #4765
go generate ./...
)