diff options
Diffstat (limited to 'src/stash.c')
-rw-r--r-- | src/stash.c | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/stash.c b/src/stash.c index 083c2a4cd..66b1cd7c5 100644 --- a/src/stash.c +++ b/src/stash.c @@ -412,25 +412,12 @@ static int update_reflog( const char *message) { git_reference *stash; - git_reflog *reflog = NULL; int error; - if ((error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1)) < 0) - goto cleanup; + error = git_reference_create_with_log(&stash, repo, GIT_REFS_STASH_FILE, w_commit_oid, 1, stasher, message); git_reference_free(stash); - if ((error = git_reflog_read(&reflog, repo, GIT_REFS_STASH_FILE) < 0)) - goto cleanup; - - if ((error = git_reflog_append(reflog, w_commit_oid, stasher, message)) < 0) - goto cleanup; - - if ((error = git_reflog_write(reflog)) < 0) - goto cleanup; - -cleanup: - git_reflog_free(reflog); return error; } @@ -636,7 +623,11 @@ int git_stash_drop( entry = git_reflog_entry_byindex(reflog, 0); git_reference_free(stash); - error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, &entry->oid_cur, 1); + if ((error = git_reference_create(&stash, repo, GIT_REFS_STASH_FILE, &entry->oid_cur, 1) < 0)) + goto cleanup; + + /* We need to undo the writing that we just did */ + error = git_reflog_write(reflog); } cleanup: |