| 1150 | self.gl_repo._ref_rm('GL_FUSE_ORIG_HEAD') |
| 1151 | |
| 1152 | def _safe_reset(self, cid, msg_fn, save_fn=None): |
| 1153 | git_repo = self.gl_repo.git_repo |
| 1154 | tree = git_repo[cid].tree |
| 1155 | try: |
| 1156 | git_repo.checkout_tree(tree) |
| 1157 | except pygit2.GitError: # conflicts prevent checkout |
| 1158 | # TODO: this hack will cover most cases, but it won't help if the conflict |
| 1159 | # is caused by untracked files (nonetheless `stash pop` won't work in that |
| 1160 | # case either so we need to find an alternative way of doing this) |
| 1161 | if save_fn: |
| 1162 | save_fn() |
| 1163 | git.stash.save('--', msg_fn(self)) |
| 1164 | git_repo.checkout_tree(tree) |
| 1165 | git_repo.reset(cid, pygit2.GIT_RESET_SOFT) |
| 1166 | |
| 1167 | def _safe_restore(self, msg_fn, restore_fn=None): |
| 1168 | s_id, _ = _stash(msg_fn(self)) |