Last active
August 29, 2015 14:23
-
-
Save swisspol/ebd25ab62da1aecd6f84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "clar_libgit2.h" | |
#include "fileops.h" | |
#include "stash_helpers.h" | |
static git_signature *signature; | |
static git_repository *repo; | |
static git_index *repo_index; | |
void test_stash_apply__initialize(void) | |
{ | |
cl_git_pass(git_signature_new(&signature, "nulltoken", "[email protected]", 1323847743, 60)); /* Wed Dec 14 08:29:03 2011 +0100 */ | |
cl_git_pass(git_repository_init(&repo, "stash", 0)); | |
cl_git_pass(git_repository_index(&repo_index, repo)); | |
} | |
void test_stash_apply__cleanup(void) | |
{ | |
git_signature_free(signature); | |
signature = NULL; | |
git_index_free(repo_index); | |
repo_index = NULL; | |
git_repository_free(repo); | |
repo = NULL; | |
cl_git_pass(git_futils_rmdir_r("stash", NULL, GIT_RMDIR_REMOVE_FILES)); | |
cl_fixture_cleanup("sorry-it-is-a-non-bare-only-party"); | |
} | |
void test_stash_apply__bug(void) | |
{ | |
git_oid oid; | |
cl_git_mkfile("stash/modified_staged", "\n"); | |
cl_git_pass(git_index_add_bypath(repo_index, "modified_staged")); | |
cl_git_mkfile("stash/modified_unstaged", "\n"); | |
cl_git_pass(git_index_add_bypath(repo_index, "modified_unstaged")); | |
cl_repo_commit_from_index(NULL, repo, signature, 0, "Initial commit"); | |
cl_git_mkfile("stash/new_staged", "\n"); | |
cl_git_pass(git_index_add_bypath(repo_index, "new_staged")); | |
cl_git_rewritefile("stash/modified_staged", "\n\n"); | |
cl_git_pass(git_index_add_bypath(repo_index, "modified_staged")); | |
cl_git_rewritefile("stash/modified_unstaged", "\n\n"); | |
cl_git_mkfile("stash/untracked", "\n"); | |
assert_status(repo, "new_staged", GIT_STATUS_INDEX_NEW); | |
assert_status(repo, "modified_staged", GIT_STATUS_INDEX_MODIFIED); | |
assert_status(repo, "modified_unstaged", GIT_STATUS_WT_MODIFIED); | |
assert_status(repo, "untracked", GIT_STATUS_WT_NEW); | |
cl_git_pass(git_stash_save(&oid, repo, signature, NULL, GIT_STASH_INCLUDE_UNTRACKED)); | |
assert_status(repo, "new_staged", GIT_ENOTFOUND); | |
assert_status(repo, "modified_staged", GIT_STATUS_CURRENT); | |
assert_status(repo, "modified_unstaged", GIT_STATUS_CURRENT); | |
assert_status(repo, "untracked", GIT_ENOTFOUND); | |
cl_git_pass(git_stash_apply(repo, 0, NULL)); | |
cl_git_pass(git_index_write(repo_index)); // <---- This doesn't make a difference | |
/* | |
$ git stash apply | |
On branch master | |
Changes to be committed: | |
(use "git reset HEAD <file>..." to unstage) | |
new file: new_staged | |
Changes not staged for commit: | |
(use "git add <file>..." to update what will be committed) | |
(use "git checkout -- <file>..." to discard changes in working directory) | |
modified: modified_staged | |
modified: modified_unstaged | |
Untracked files: | |
(use "git add <file>..." to include in what will be committed) | |
untracked | |
*/ | |
assert_status(repo, "new_staged", GIT_STATUS_INDEX_NEW); // <---- BUG: This is WT_NEW instead | |
assert_status(repo, "modified_staged", GIT_STATUS_WT_MODIFIED); | |
assert_status(repo, "modified_unstaged", GIT_STATUS_WT_MODIFIED); | |
assert_status(repo, "untracked", GIT_STATUS_WT_NEW); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment