git-meta icon indicating copy to clipboard operation
git-meta copied to clipboard

"git meta status" crashes when submodule entry is missing from tree

Open abliss opened this issue 7 years ago • 0 comments

Deleting/creating an open submodule is a 5-step process. The error happens when 1 of the 5 is out of sync:

A. the path foo/bar is NOT in the tree of the current commit (nor index); B. foo/bar IS in the .gitmodules C. submodule.foo/bar.url IS in the git config D. the git database at .git/modules/foo/bar IS initialized E. the working-directory foo/bar IS present and contains a .git pointing to (D)

I don't know exactly what "natural" combination of steps got me into this state, but I was able to recreate it with the following unnatural steps starting from an existing submodule foo/bar:

  1. git rm foo/bar
  2. git commit -m "XXX Partial deletion" foo/bar
  3. git checkout -b badbranch
  4. git checkout HEAD~
  5. git checkout HEAD .gitmodules
  6. git meta open foo/bar
  7. git meta checkout badbranch
  8. git meta status
Error: the path 'bar' does not exist in the given tree
    at Error (native)

A better error message might be something like:

Error: You appear to have a submodule half-initialized at foo/bar . Run `git meta repair` to get back to a consistent state.

abliss avatar Oct 29 '18 16:10 abliss