Apply applies a single stashed state from the stash list. If local changes in the working directory conflict with changes in the stash then ErrorCodeConflict will be returned. In this case, the index will always remain unmodified and all files in the working directory will remain unmodified. Howe
(index int, opts StashApplyOptions)
| 215 | // |
| 216 | // Error codes can be interogated with IsErrorCode(err, ErrorCodeNotFound). |
| 217 | func (c *StashCollection) Apply(index int, opts StashApplyOptions) error { |
| 218 | var err error |
| 219 | optsC := populateStashApplyOptions(&C.git_stash_apply_options{}, &opts, &err) |
| 220 | defer freeStashApplyOptions(optsC) |
| 221 | |
| 222 | runtime.LockOSThread() |
| 223 | defer runtime.UnlockOSThread() |
| 224 | |
| 225 | ret := C.git_stash_apply(c.repo.ptr, C.size_t(index), optsC) |
| 226 | runtime.KeepAlive(c) |
| 227 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 228 | return err |
| 229 | } |
| 230 | if ret < 0 { |
| 231 | return MakeGitError(ret) |
| 232 | } |
| 233 | return nil |
| 234 | } |
| 235 | |
| 236 | // StashCallback is called per entry when interating over all |
| 237 | // the stashed states. |