Commit a6a82e1a by Russell Belfer

Improve error propagation in stash

Stash was sometimes obscuring the actual error code, replacing it
with a -1 when there was more descriptive value.  This updates
stash to preserve the original error code more reliably along
with a variety of other error handling tweaks.

I believe this is an improvement, but arguably, preserving the
underlying error code may result in values that are harder to
interpret by the caller who does not understand the internals.
Discussion is welcome!
parent 8fe713cc
...@@ -36,15 +36,22 @@ static void push_three_states(void) ...@@ -36,15 +36,22 @@ static void push_three_states(void)
cl_git_pass(git_repository_index(&index, repo)); cl_git_pass(git_repository_index(&index, repo));
cl_git_pass(git_index_add_from_workdir(index, "zero.txt")); cl_git_pass(git_index_add_from_workdir(index, "zero.txt"));
commit_staged_files(&oid, index, signature); commit_staged_files(&oid, index, signature);
cl_assert(git_path_exists("stash/zero.txt"));
cl_git_mkfile("stash/one.txt", "content\n"); cl_git_mkfile("stash/one.txt", "content\n");
cl_git_pass(git_stash_save(&oid, repo, signature, "First", GIT_STASH_INCLUDE_UNTRACKED)); cl_git_pass(git_stash_save(&oid, repo, signature, "First", GIT_STASH_INCLUDE_UNTRACKED));
cl_assert(!git_path_exists("stash/one.txt"));
cl_assert(git_path_exists("stash/zero.txt"));
cl_git_mkfile("stash/two.txt", "content\n"); cl_git_mkfile("stash/two.txt", "content\n");
cl_git_pass(git_stash_save(&oid, repo, signature, "Second", GIT_STASH_INCLUDE_UNTRACKED)); cl_git_pass(git_stash_save(&oid, repo, signature, "Second", GIT_STASH_INCLUDE_UNTRACKED));
cl_assert(!git_path_exists("stash/two.txt"));
cl_assert(git_path_exists("stash/zero.txt"));
cl_git_mkfile("stash/three.txt", "content\n"); cl_git_mkfile("stash/three.txt", "content\n");
cl_git_pass(git_stash_save(&oid, repo, signature, "Third", GIT_STASH_INCLUDE_UNTRACKED)); cl_git_pass(git_stash_save(&oid, repo, signature, "Third", GIT_STASH_INCLUDE_UNTRACKED));
cl_assert(!git_path_exists("stash/three.txt"));
cl_assert(git_path_exists("stash/zero.txt"));
git_index_free(index); git_index_free(index);
} }
......
...@@ -38,10 +38,10 @@ void test_stash_foreach__cleanup(void) ...@@ -38,10 +38,10 @@ void test_stash_foreach__cleanup(void)
} }
static int callback_cb( static int callback_cb(
size_t index, size_t index,
const char* message, const char* message,
const git_oid *stash_oid, const git_oid *stash_oid,
void *payload) void *payload)
{ {
struct callback_data *data = (struct callback_data *)payload; struct callback_data *data = (struct callback_data *)payload;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment