You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Files/directories with a shared name prefix are dropped from a multi-selection (custom patch, discard) #5866
When I select multiple files in a commit's file view and their names share a prefix, one of them is silently left out of the operation.
I hit this while building a custom patch from a commit: I range-selected a couple of entries and pressed space to add them all to the patch, but one of them just never got added — no error, it simply stayed unselected. It turned out the two names shared a prefix (in my case a file and its .orig leftover). The same thing happens with directories like foo and foobar, and it also affects "discard changes" on a multi-selection, not just custom patches.
To Reproduce
Minimal repro with two sibling directories whose names share a prefix:
mkdir repro &&cd repro && git init
mkdir foo foobar
echo x > foo/file
echo x > foobar/file
git add -A && git commit -m "first commit"
lazygit
Then:
Focus the Commits panel and press enter on first commit to open its files.
You'll see the tree:
▼ /
▼ foo
A file
▼ foobar
A file
Put the cursor on the foo directory, press v to start a range selection, and move down to the foobar directory so both directories are selected.
Press space to add the selection to a custom patch.
Result — only foo gets added:
▼ /
▼ foo
● file
▼ foobar
A file <- never added to the patch
The same happens with plain files whose names share a prefix, e.g. a.txt and a.txt.orig, or app.js and app.js.map: select both, and the longer-named one is dropped.
Expected behavior
Both selected entries should be added to the patch (both showing ●). foobar is not inside foo, and a.txt.orig is not inside a.txt, so neither should be treated as a descendant of the other and skipped.
Screenshots
(Text output above shows it — foobar/file stays A instead of becoming ●.)
I had a quick look out of curiosity. In pkg/gui/controllers/commits_files_controller.go, isDescendentOfSelectedCommitFileNodes filters a node out of the selection when its path starts with another selected node's path:
That matches foobar against foo (and a.txt.orig against a.txt) even though neither is actually a descendant. There's even a comment right above saying this function is "identical to those in files_controller.go", and the version there (isDescendentOfSelectedNodes) does the check differently — it skips selected files and requires a path-segment boundary (selectedNodePath + "/"), which wouldn't have this problem. So the two seem to have drifted apart. (Just a hunch from reading.)
@ZekiLiu Thanks; you are right that the code has drifted. This is a bug that was fixed in the Files panel a long time ago, but we forgot to make the equivalent change in the commit files panel. Fixed in #5868.
Activity
stefanhaller commentedon Jul 28, 2026
@ZekiLiu Thanks; you are right that the code has drifted. This is a bug that was fixed in the Files panel a long time ago, but we forgot to make the equivalent change in the commit files panel. Fixed in #5868.
Fix multi-selection of files with common prefix not working in commit…