Skip to content

Conversation

stefanhaller
Copy link
Collaborator

@stefanhaller stefanhaller commented Oct 5, 2025

Our logic to decide if a file needs to be checked out from the previous commit or deleted because it didn't exist in the previous commit didn't work for submodules. We were using git cat-file -e to ask whether the file existed, but this returns an error for submodules, so we were always deleting those instead of reverting them back to their previous state.

Switch to using git ls-tree -- file instead, which works for both files and submodules.

Fixes #4932.

@stefanhaller stefanhaller added the bug Something isn't working label Oct 5, 2025
Copy link

codacy-production bot commented Oct 5, 2025

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 97762f41 97.14%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (97762f4) Report Missing Report Missing Report Missing
Head commit (33d4b40) 57816 50259 86.93%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4937) 70 68 97.14%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

It works for submodules too.

Also, pass file name and file content explicitly; the existing tests don't care
about these, but when writing tests that do, it makes them easier to understand.
When dropping changes to the submodule, we expect it to get rolled back to the
previous version; however, it is removed entirely instead.
Our logic to decide if a file needs to be checked out from the previous commit
or deleted because it didn't exist in the previous commit didn't work for
submodules. We were using `git cat-file -e` to ask whether the file existed, but
this returns an error for submodules, so we were always deleting those instead
of reverting them back to their previous state.

Switch to using `git ls-tree -- file` instead, which works for both files and
submodules.
@stefanhaller stefanhaller force-pushed the fix-dropping-submodule-updates-from-commit branch from 3dc7c57 to 33d4b40 Compare October 5, 2025 13:23
@stefanhaller stefanhaller marked this pull request as ready for review October 5, 2025 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"d" instead of reverting submodule, deletes it, inside a commit
1 participant