#include "clar_libgit2.h"
#include "fileops.h"
#include "stash_helpers.h"
void setup_stash(git_repository *repo, git_signature *signature)
{
git_index *index;
cl_git_pass(git_repository_index(&index, repo));
cl_git_mkfile("stash/what", "hello\n");
cl_git_mkfile("stash/how", "small\n");
cl_git_mkfile("stash/who", "world\n");
cl_git_mkfile("stash/when", "now\n");
cl_git_mkfile("stash/just.ignore", "me\n");
cl_git_mkfile("stash/.gitignore", "*.ignore\n");
cl_git_pass(git_index_add_bypath(index, "what"));
cl_git_pass(git_index_add_bypath(index, "how"));
cl_git_pass(git_index_add_bypath(index, "who"));
cl_git_pass(git_index_add_bypath(index, ".gitignore"));
cl_repo_commit_from_index(NULL, repo, signature, 0, "Initial commit");
cl_git_rewritefile("stash/what", "goodbye\n");
cl_git_rewritefile("stash/how", "not so small and\n");
cl_git_rewritefile("stash/who", "funky world\n");
cl_git_mkfile("stash/why", "would anybody use stash?\n");
cl_git_mkfile("stash/where", "????\n");
cl_git_pass(git_index_add_bypath(index, "what"));
cl_git_pass(git_index_add_bypath(index, "how"));
cl_git_pass(git_index_add_bypath(index, "why"));
cl_git_pass(git_index_add_bypath(index, "where"));
cl_git_pass(git_index_write(index));
cl_git_rewritefile("stash/what", "see you later\n");
cl_git_mkfile("stash/where", "....\n");
git_index_free(index);
}
void assert_status(
git_repository *repo,
const char *path,
int status_flags)
{
unsigned int status;
if (status_flags < 0)
cl_assert_equal_i(status_flags, git_status_file(&status, repo, path));
else {
cl_git_pass(git_status_file(&status, repo, path));
cl_assert_equal_i((unsigned int)status_flags, status);
}
}