JGit SubmoduleDeinitCommand can delete files from a dirty requested submodule
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 83/100
Rechercherichtung
Beginne in org.eclipse.jgit/src/org/eclipse/jgit/api/SubmoduleDeinitCommand.java: checkDirty() (etwa L194-L210) öffnet einen ungefilterten SubmoduleWalk.forIndex(repo) und untersucht nur den ersten Index-Eintrag, daher muss es auf die über addPath() übergebenen Pfade eingeschränkt werden. Lies call() (L92-L111) und deinit() (L140-L152), um zu sehen, wie der DIRTY-Status das rekursive Löschen steuert. Füge einen Test unter org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule hinzu, mit zwei Submodule-Einträgen, die dieselbe Object ID teilen, wobei nur der angeforderte Pfad dirty ist; fertig, wenn es SubmoduleDeinitStatus.DIRTY zurückgibt, die untracked Datei überlebt und die bestehenden deinit-Tests weiterhin bestehen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Version
v7.8.0.202609011348-r-10-g87ec21000
Operating System
Linux/Unix
Bug description
SubmoduleDeinitCommand can deinitialize a dirty requested submodule without
force when another earlier submodule entry records the same object ID.
The command is expected to check the requested path and refuse to remove its
worktree when it contains local changes. In the reproducing repository,
submodules a and b both point to the same commit. a is clean and b
contains an untracked file. The call below requests only b and does not call
setForce(true):
new SubmoduleDeinitCommand(db).addPath("b").call();
call() initially walks the requested path, but checkDirty() then opens a
second SubmoduleWalk.forIndex(repo) without a path filter and examines only
the first index entry. Because a appears before b and has the same object
ID, the status of clean submodule a is used for the requested path b.
The command consequently proceeds to deinit("b"), which recursively deletes
the contents of b.
Relevant source at the tested revision:
call()and the deletion decision- unfiltered index walk in
checkDirty() - recursive deletion in
deinit()
Actual behavior
The requested dirty submodule is reported as successfully deinitialized, and
its untracked file is deleted even though force was not requested:
OBSERVED deinit requested=b status=SUCCESS dirty_file_exists=false
The control case, with only submodule b present, correctly detects the same
dirty file:
CONTROL deinit only=b status=DIRTY dirty_file_exists=true
Expected behavior
Because b contains local modifications and force was not requested, the
command should return SubmoduleDeinitStatus.DIRTY for b and leave all files
under b intact. This is also the behavior documented by setForce(false).
Relevant log output
OBSERVED deinit requested=b status=SUCCESS dirty_file_exists=false
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
CONTROL deinit only=b status=DIRTY dirty_file_exists=true
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
BUILD SUCCESS
Other information
The standalone reproducer is included in the accompanying archive:
reproduce.shcopiesreproduce_test.javainto
org.eclipse.jgit.test/tst/org/eclipse/jgit/submodule, runs the two tests,
records the environment and revision, and removes the temporary test source
and generated test artifacts.- The test source is
org.eclipse.jgit.submodule.SubmoduleDeinitReproductionTest. - Run it from the repository root with:
findings/submodules/jgit-deinit-unfiltered-dirty-check/reproduce.sh \
findings/submodules/jgit-deinit-unfiltered-dirty-check/evidence/20260909
The effective Maven command uses -Pjavac -pl org.eclipse.jgit.test -am and
the following environment was used:
Git 2.39.5
Java openjdk version "17.0.20.1" 2026-08-18
Maven 3.8.7
The issue causes local data loss: uncommitted, untracked, generated, or other
files in the requested submodule can be removed by a non-forced deinit. The
demonstration requires two submodule entries with the same recorded object ID,
an initialized dirty target submodule, and an application or user invoking
deinit for that target. It does not demonstrate deletion outside the requested
submodule, code execution, privilege escalation, or a remote-only trigger.
The complete reproduction output is in
evidence/20260909/run.log. The implementation contract is documented by
setForce(),
which states that deinitialization should refuse local modifications unless
force is enabled.
Attachments
- Vorherrschende Sprache
- Java
- Sterne
- 427
- Forks
- 116
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus eclipse-jgit/jgit
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
eclipse-jgit/jgit#329 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
eclipse-jgit/jgit#327 ·
-
Repository.create(boolean bare) should provide a no-arg overload that uses isBare()Evtl. wieder frei @hardikyadav12 hat das vor 77 Tagen übernommen, und es ist kein Pull Request offen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
eclipse-jgit/jgit#297 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
eclipse-jgit/jgit#288 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
eclipse-jgit/jgit#273 · 1 Kommentar ·
Alle Issues in eclipse-jgit/jgit
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
constellation-app/constellation#2613 ·
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
Vakore/ZappierGames#334 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
IETF-Hackathon/pqc-certificates#369 ·
Maintainer antworten meist innerhalb von 1 Tag
-
? - Needs Triage bot_watch bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
NVIDIA/cudf-spark-jni#5594 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100