twosigma / git-meta

Repository for the git-meta project -- build your own monorepo using Git submodules
http://twosigma.github.io/git-meta
BSD 3-Clause "New" or "Revised" License
220 stars 51 forks source link

git meta stash pop should not drop item in case of conflict #747

Open shijinglu opened 4 years ago

shijinglu commented 4 years ago

As vanilla git says:

pop [--index] [-q|--quiet] [] Remove a single stashed state from the stash list and apply it on top of the current working tree state, i.e., do the inverse operation of git stash push. The working directory must match the index. Applying the state can fail with conflicts; in this case, it is not removed from the stash list. You need to resolve the conflicts by hand and call git stash drop manually afterwards.

shijinglu commented 4 years ago

I don't think this can be fixed easily, because NodeGit.Stash.apply does not return the code it promised to:

> NodeGit.Repository.open('/Users/abc/workspace/twosigma/big-mono/s123').then(function (repo){
... NodeGit.Stash.apply(repo, 0, null).then( function(result){
..... console.log(" result = " + result);
..... });
... })
Promise { _55: 0, _87: null, _28: [] }
>  result = undefined

Supposedly, it should return something like

result = 0, 1, -13 etc

We need this code so we can tell if there is a conflict at applying: https://github.com/libgit2/libgit2/blob/HEAD/include/git2/stash.h#L182