Skip to content

Discarding submodule changes while selecting parent folder does not work #3951

@brandondong

Description

@brandondong

Describe the bug
At work, we have a submodule in a nested folder:
image

All this time, I thought lazygit did not support discarding submodule changes because I would open the tool, get to this screen, press d (Discard changes), hit confirm, and then nothing would happen.

Only today did I discover lazygit does actually support this. I just needed to move the selection down one item and then pressing d + confirm would work as expected.

The behavior is due to this check:

if firstNode.File != nil && firstNode.File.IsSubmodule(submodules) {

To Reproduce
Steps to reproduce the behavior:

git init
git submodule add https://github.com/jesseduffield/lazygit.git external/buildtools
git commit -m "add submodule"
git -C external/buildtools checkout HEAD~
lazygit

Press d and hit confirm.

Expected behavior
The submodule changes should be discarded. The folder only contains submodule changes so it should be no different than pressing discard on the submodule entry itself.

Also, I noticed range selecting both the folder and the submodule and then pressing discard would be disallowed due to

if submoduleCount > 0 && len(selectedNodes) > 1 {

I feel like this should also be allowed.

Screenshots
If applicable, add screenshots to help explain your problem.

Version info:

> lazygit --version
commit=611fabde11d24d9acc71ee26077b9a1101f59f27, build date=2024-09-18T10:56:10Z, build source=binaryRelease, version=0.44.1, os=windows, arch=amd64, git version=2.43.0.windows.1
> git --version
git version 2.43.0.windows.1

Additional context
Add any other context about the problem here.

Note: please try updating to the latest version or manually building the latest master to see if the issue still occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions