diff options
author | Edward Thomson <ethomson@microsoft.com> | 2015-06-23 16:27:17 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@microsoft.com> | 2015-06-23 18:17:24 -0400 |
commit | 14304b0e87e92291a1265d5e692bd2d21ba59a62 (patch) | |
tree | af57eba33eee8cf31405f0817791706d2b3c316c | |
parent | 5ef43d41b036d4178c6d886c2222db9dd7f32fc1 (diff) | |
download | libgit2-14304b0e87e92291a1265d5e692bd2d21ba59a62.tar.gz |
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.
-rw-r--r-- | tests/stash/foreach.c | 20 | ||||
-rw-r--r-- | tests/stash/save.c | 12 | ||||
-rw-r--r-- | tests/stash/stash_helpers.c | 5 |
3 files changed, 26 insertions, 11 deletions
diff --git a/tests/stash/foreach.c b/tests/stash/foreach.c index f1983625f..57dc8eeb4 100644 --- a/tests/stash/foreach.c +++ b/tests/stash/foreach.c @@ -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); } diff --git a/tests/stash/save.c b/tests/stash/save.c index e07877516..edcee820f 100644 --- a/tests/stash/save.c +++ b/tests/stash/save.c @@ -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); diff --git a/tests/stash/stash_helpers.c b/tests/stash/stash_helpers.c index ff683eced..0398757c2 100644 --- a/tests/stash/stash_helpers.c +++ b/tests/stash/stash_helpers.c @@ -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); } |