summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-18 16:33:50 -0500
committerEdward Thomson <ethomson@microsoft.com>2015-05-11 14:12:16 -0400
commit90f8408dacf0da9def636a042813822b078df735 (patch)
treeeb3836839447dd23ca108321f9dd01db03610adc /src
parentd0dd3fcee7943321784f5745d34130cacd5d9fb4 (diff)
downloadlibgit2-90f8408dacf0da9def636a042813822b078df735.tar.gz
stash: ensure a reflog has entries
Diffstat (limited to 'src')
-rw-r--r--src/stash.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/stash.c b/src/stash.c
index a316d18c2..899156d8d 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -564,7 +564,7 @@ static int retrieve_stash_commit(
goto cleanup;
max = git_reflog_entrycount(reflog);
- if (index > max - 1) {
+ if (!max || index > max - 1) {
error = GIT_ENOTFOUND;
giterr_set(GITERR_STASH, "No stashed state at position %" PRIuZ, index);
goto cleanup;
@@ -949,7 +949,7 @@ int git_stash_drop(
max = git_reflog_entrycount(reflog);
- if (index > max - 1) {
+ if (!max || index > max - 1) {
error = GIT_ENOTFOUND;
giterr_set(GITERR_STASH, "No stashed state at position %" PRIuZ, index);
goto cleanup;