eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
121 stars 34 forks source link

Submodule update fails if submodule was previously deleted then reinitialized #79

Open eder-s opened 1 month ago

eder-s commented 1 month ago

Version

5.x 6.x

Operating System

Windows

Bug description

Original bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=477642

JGit fails to update/restore a submodule for which the worktree was deleted but the gitdir under ".git/modules/subrepo" is still existing.

Steps to reproduce(copied from bugzilla):

  1. Create two repos, a remote repo and a submodule repo. Commit a file to the submodule repo, then add it as a submodule to the remote repo and do a commit in the remote repo.
  2. Clone the remote repo, then in the clone, perform a submodule init and a submodule update.
  3. Delete the submodule directory in the local clone, then perform a hard reset. Perform another submodule init, then another submodule update, and JGit will throw an exception.

Actual behavior

JGit throws an exception instead of updating/restoring the submodule.

Expected behavior

Updating the submodule succeeds.

Relevant log output

No response

Other information

No response

msohn commented 2 weeks ago

Simon proposed this fix https://eclipse.gerrithub.io/c/eclipse-jgit/jgit/+/1198662