twosigma / twosigma/git-meta

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

Open
#683 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
233
Forks
54
PR merge metrics
No merged PRs in 30d

Description

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.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.