Commit 14304b0e by Edward Thomson

stash tests: ensure we save the workdir file

Ensure that when a file is added in the index and subsequently
modified in the working directory, the stashed working directory
tree contains the actual working directory contents.
parent 5ef43d41
......@@ -69,16 +69,16 @@ void test_stash_foreach__enumerating_a_empty_repository_doesnt_fail(void)
void test_stash_foreach__can_enumerate_a_repository(void)
{
char *oids_default[] = {
"1d91c842a7cdfc25872b3a763e5c31add8816c25", NULL };
"493568b7a2681187aaac8a58d3f1eab1527cba84", NULL };
char *oids_untracked[] = {
"7f89a8b15c878809c5c54d1ff8f8c9674154017b",
"1d91c842a7cdfc25872b3a763e5c31add8816c25", NULL };
"493568b7a2681187aaac8a58d3f1eab1527cba84", NULL };
char *oids_ignored[] = {
"c95599a8fef20a7e57582c6727b1a0d02e0a5828",
"7f89a8b15c878809c5c54d1ff8f8c9674154017b",
"1d91c842a7cdfc25872b3a763e5c31add8816c25", NULL };
"493568b7a2681187aaac8a58d3f1eab1527cba84", NULL };
cl_git_pass(git_repository_init(&repo, REPO_NAME, 0));
......@@ -96,9 +96,7 @@ void test_stash_foreach__can_enumerate_a_repository(void)
cl_git_pass(git_stash_foreach(repo, callback_cb, &data));
cl_assert_equal_i(1, data.invokes);
data.oids = oids_untracked;
data.invokes = 0;
/* ensure stash_foreach operates with INCLUDE_UNTRACKED */
cl_git_pass(git_stash_save(
&stash_tip_oid,
repo,
......@@ -106,12 +104,13 @@ void test_stash_foreach__can_enumerate_a_repository(void)
NULL,
GIT_STASH_INCLUDE_UNTRACKED));
data.oids = oids_untracked;
data.invokes = 0;
cl_git_pass(git_stash_foreach(repo, callback_cb, &data));
cl_assert_equal_i(2, data.invokes);
data.oids = oids_ignored;
data.invokes = 0;
/* ensure stash_foreach operates with INCLUDE_IGNORED */
cl_git_pass(git_stash_save(
&stash_tip_oid,
repo,
......@@ -119,6 +118,9 @@ void test_stash_foreach__can_enumerate_a_repository(void)
NULL,
GIT_STASH_INCLUDE_IGNORED));
data.oids = oids_ignored;
data.invokes = 0;
cl_git_pass(git_stash_foreach(repo, callback_cb, &data));
cl_assert_equal_i(3, data.invokes);
}
......@@ -100,12 +100,18 @@ $ git status --short
assert_blob_oid("refs/stash:how", "e6d64adb2c7f3eb8feb493b556cc8070dca379a3"); /* not so small and */
assert_blob_oid("refs/stash:who", "a0400d4954659306a976567af43125a0b1aa8595"); /* funky world */
assert_blob_oid("refs/stash:when", NULL);
assert_blob_oid("refs/stash:why", "88c2533e21f098b89c91a431d8075cbdbe422a51"); /* would anybody use stash? */
assert_blob_oid("refs/stash:where", "e3d6434ec12eb76af8dfa843a64ba6ab91014a0b"); /* .... */
assert_blob_oid("refs/stash:.gitignore", "ac4d88de61733173d9959e4b77c69b9f17a00980");
assert_blob_oid("refs/stash:just.ignore", NULL);
assert_blob_oid("refs/stash^2:what", "dd7e1c6f0fefe118f0b63d9f10908c460aa317a6"); /* goodbye */
assert_blob_oid("refs/stash^2:how", "e6d64adb2c7f3eb8feb493b556cc8070dca379a3"); /* not so small and */
assert_blob_oid("refs/stash^2:who", "cc628ccd10742baea8241c5924df992b5c019f71"); /* world */
assert_blob_oid("refs/stash^2:when", NULL);
assert_blob_oid("refs/stash^2:why", "88c2533e21f098b89c91a431d8075cbdbe422a51"); /* would anybody use stash? */
assert_blob_oid("refs/stash^2:where", "e08f7fbb9a42a0c5367cf8b349f1f08c3d56bd72"); /* ???? */
assert_blob_oid("refs/stash^2:.gitignore", "ac4d88de61733173d9959e4b77c69b9f17a00980");
assert_blob_oid("refs/stash^2:just.ignore", NULL);
assert_blob_oid("refs/stash^3", NULL);
......@@ -243,11 +249,13 @@ void test_stash_save__cannot_stash_when_there_are_no_local_change(void)
cl_git_pass(git_repository_index(&index, repo));
/*
* 'what' and 'who' are being committed.
* 'when' remain untracked.
* 'what', 'where' and 'who' are being committed.
* 'when' remains untracked.
*/
cl_git_pass(git_index_add_bypath(index, "what"));
cl_git_pass(git_index_add_bypath(index, "where"));
cl_git_pass(git_index_add_bypath(index, "who"));
cl_repo_commit_from_index(NULL, repo, signature, 0, "Initial commit");
git_index_free(index);
......
......@@ -26,12 +26,17 @@ void setup_stash(git_repository *repo, git_signature *signature)
cl_git_rewritefile("stash/what", "goodbye\n"); /* dd7e1c6f0fefe118f0b63d9f10908c460aa317a6 */
cl_git_rewritefile("stash/how", "not so small and\n"); /* e6d64adb2c7f3eb8feb493b556cc8070dca379a3 */
cl_git_rewritefile("stash/who", "funky world\n"); /* a0400d4954659306a976567af43125a0b1aa8595 */
cl_git_mkfile("stash/why", "would anybody use stash?\n"); /* 88c2533e21f098b89c91a431d8075cbde422a51 */
cl_git_mkfile("stash/where", "????\n"); /* e08f7fbb9a42a0c5367cf8b349f1f08c3d56bd72 */
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"); /* bc99dc98b3eba0e9157e94769cd4d49cb49de449 */
cl_git_mkfile("stash/where", "....\n"); /* e3d6434ec12eb76af8dfa843a64ba6ab91014a0b */
git_index_free(index);
}
......
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