summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAxel Rasmussen <axelrasmussen@google.com>2015-10-01 18:01:32 -0700
committerAxel Rasmussen <axelrasmussen@google.com>2015-10-01 18:01:32 -0700
commitc7b17fb5cd1adac57c4300e95cef8c7064b0601a (patch)
treeb1a1bcd6e1d88f1cd48b7fdb414d6444c28eb896 /tests
parent28cdb3153c8c6d651c5b2afcf315a2d188e9fde9 (diff)
parenta99f33e9b05504ea5eccd9c9210cd4a9e8d11695 (diff)
downloadlibgit2-c7b17fb5cd1adac57c4300e95cef8c7064b0601a.tar.gz
Merge branch 'master' into nsec_fix_next
Diffstat (limited to 'tests')
-rw-r--r--tests/core/mkdir.c2
-rw-r--r--tests/diff/binary.c21
-rw-r--r--tests/index/rename.c5
-rw-r--r--tests/network/remote/defaultbranch.c6
-rw-r--r--tests/network/remote/local.c8
-rw-r--r--tests/network/remote/remotes.c6
-rw-r--r--tests/odb/sorting.c1
-rw-r--r--tests/online/badssl.c27
-rw-r--r--tests/online/clone.c27
-rw-r--r--tests/online/fetch.c12
-rw-r--r--tests/online/push.c2
-rw-r--r--tests/repo/reservedname.c24
-rw-r--r--tests/resources/sub.git/HEAD1
-rw-r--r--tests/resources/sub.git/config8
-rw-r--r--tests/resources/sub.git/indexbin0 -> 405 bytes
-rw-r--r--tests/resources/sub.git/logs/HEAD1
-rw-r--r--tests/resources/sub.git/logs/refs/heads/master1
-rw-r--r--tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741dbin0 -> 22 bytes
-rw-r--r--tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623bin0 -> 28 bytes
-rw-r--r--tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fbbin0 -> 132 bytes
-rw-r--r--tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8bin0 -> 139 bytes
-rw-r--r--tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773bin0 -> 54 bytes
-rw-r--r--tests/resources/sub.git/refs/heads/master1
-rw-r--r--tests/resources/super/.gitted/COMMIT_EDITMSG1
-rw-r--r--tests/resources/super/.gitted/HEAD1
-rw-r--r--tests/resources/super/.gitted/config10
-rw-r--r--tests/resources/super/.gitted/indexbin0 -> 217 bytes
-rw-r--r--tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4bin0 -> 90 bytes
-rw-r--r--tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91bin0 -> 132 bytes
-rw-r--r--tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034bin0 -> 87 bytes
-rw-r--r--tests/resources/super/.gitted/refs/heads/master1
-rw-r--r--tests/resources/super/gitmodules3
-rw-r--r--tests/submodule/submodule_helpers.c16
-rw-r--r--tests/submodule/submodule_helpers.h1
-rw-r--r--tests/win32/longpath.c60
35 files changed, 222 insertions, 24 deletions
diff --git a/tests/core/mkdir.c b/tests/core/mkdir.c
index 5e6a06002..96c972396 100644
--- a/tests/core/mkdir.c
+++ b/tests/core/mkdir.c
@@ -48,6 +48,8 @@ void test_core_mkdir__absolute(void)
cl_assert(!git_path_isdir(path.ptr));
cl_git_fail(git_futils_mkdir(path.ptr, 0755, 0));
cl_assert(!git_path_isdir(path.ptr));
+
+ git_buf_free(&path);
}
void test_core_mkdir__basic(void)
diff --git a/tests/diff/binary.c b/tests/diff/binary.c
index 5298e9ebb..173a5994e 100644
--- a/tests/diff/binary.c
+++ b/tests/diff/binary.c
@@ -96,7 +96,8 @@ void test_diff_binary__add(void)
"Kc${Nk-~s>u4FC%O\n"
"\n" \
"literal 0\n" \
- "Hc$@<O00001\n";
+ "Hc$@<O00001\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
@@ -136,7 +137,8 @@ void test_diff_binary__modify(void)
"Mc${NkU}WL~000&M4gdfE\n" \
"\n" \
"literal 3\n" \
- "Kc${Nk-~s>u4FC%O\n";
+ "Kc${Nk-~s>u4FC%O\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY;
@@ -177,7 +179,8 @@ void test_diff_binary__delete(void)
"Hc$@<O00001\n" \
"\n" \
"literal 3\n" \
- "Kc${Nk-~s>u4FC%O\n";
+ "Kc${Nk-~s>u4FC%O\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
@@ -208,7 +211,8 @@ void test_diff_binary__delta(void)
"delta 198\n" \
"zc$}LmI8{(0BqLQJI6p64AwNwaIJGP_Pr*5}Br~;mqJ$<Jl;sX*mF<MGCYv&*L7AHu\n" \
"zGA1*^gt?gYVN82wTbPO_W)+x<&1+cP;HrPHR>PQ;Y(X&QMK*C5^Br3bjG4d=XI^5@\n" \
- "JfH567LIF3FM2!Fd\n";
+ "JfH567LIF3FM2!Fd\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
@@ -249,7 +253,8 @@ void test_diff_binary__delta_append(void)
"nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
"\n" \
"delta 7\n" \
- "Oc%18D`@*{63ljhg(E~C7\n";
+ "Oc%18D`@*{63ljhg(E~C7\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
@@ -314,7 +319,8 @@ void test_diff_binary__index_to_workdir(void)
"nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
"\n" \
"delta 7\n" \
- "Oc%18D`@*{63ljhg(E~C7\n";
+ "Oc%18D`@*{63ljhg(E~C7\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
@@ -379,7 +385,8 @@ void test_diff_binary__print_patch_from_diff(void)
"nc%1vf+QYWt3zLL@hC)e3Vu?a>QDRl4f_G*?PG(-ZA}<#J$+QbW\n" \
"\n" \
"delta 7\n" \
- "Oc%18D`@*{63ljhg(E~C7\n";
+ "Oc%18D`@*{63ljhg(E~C7\n" \
+ "\n";
opts.flags = GIT_DIFF_SHOW_BINARY | GIT_DIFF_FORCE_BINARY;
opts.id_abbrev = GIT_OID_HEXSZ;
diff --git a/tests/index/rename.c b/tests/index/rename.c
index ebaa9b740..86eaf0053 100644
--- a/tests/index/rename.c
+++ b/tests/index/rename.c
@@ -77,5 +77,10 @@ void test_index_rename__casechanging(void)
cl_assert_equal_i(1, git_index_entrycount(index));
else
cl_assert_equal_i(2, git_index_entrycount(index));
+
+ git_index_free(index);
+ git_repository_free(repo);
+
+ cl_fixture_cleanup("rename");
}
diff --git a/tests/network/remote/defaultbranch.c b/tests/network/remote/defaultbranch.c
index e83755ef6..5edd79fb8 100644
--- a/tests/network/remote/defaultbranch.c
+++ b/tests/network/remote/defaultbranch.c
@@ -26,7 +26,7 @@ static void assert_default_branch(const char *should)
{
git_buf name = GIT_BUF_INIT;
- cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_git_pass(git_remote_default_branch(&name, g_remote));
cl_assert_equal_s(should, name.ptr);
git_buf_free(&name);
@@ -57,7 +57,7 @@ void test_network_remote_defaultbranch__no_default_branch(void)
git_buf buf = GIT_BUF_INIT;
cl_git_pass(git_remote_create(&remote_b, g_repo_b, "self", git_repository_path(g_repo_b)));
- cl_git_pass(git_remote_connect(remote_b, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote_b, GIT_DIRECTION_FETCH, NULL, NULL));
cl_git_pass(git_remote_ls(&heads, &len, remote_b));
cl_assert_equal_i(0, len);
@@ -80,7 +80,7 @@ void test_network_remote_defaultbranch__detached_sharing_nonbranch_id(void)
cl_git_pass(git_reference_create(&ref, g_repo_a, "refs/foo/bar", &id, 1, NULL));
git_reference_free(ref);
- cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(g_remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_git_fail_with(GIT_ENOTFOUND, git_remote_default_branch(&buf, g_remote));
cl_git_pass(git_clone(&cloned_repo, git_repository_path(g_repo_a), "./local-detached", NULL));
diff --git a/tests/network/remote/local.c b/tests/network/remote/local.c
index 5d726c958..4d990ab71 100644
--- a/tests/network/remote/local.c
+++ b/tests/network/remote/local.c
@@ -40,7 +40,7 @@ static void connect_to_local_repository(const char *local_repository)
git_buf_sets(&file_path_buf, cl_git_path_url(local_repository));
cl_git_pass(git_remote_create_anonymous(&remote, repo, git_buf_cstr(&file_path_buf)));
- cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
}
void test_network_remote_local__connected(void)
@@ -214,7 +214,7 @@ void test_network_remote_local__push_to_bare_remote(void)
/* Connect to the bare repo */
cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localbare.git"));
- cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
+ cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL));
/* Try to push */
cl_git_pass(git_remote_upload(localremote, &push_array, NULL));
@@ -253,7 +253,7 @@ void test_network_remote_local__push_to_bare_remote_with_file_url(void)
/* Connect to the bare repo */
cl_git_pass(git_remote_create_anonymous(&localremote, repo, url));
- cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
+ cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL));
/* Try to push */
cl_git_pass(git_remote_upload(localremote, &push_array, NULL));
@@ -290,7 +290,7 @@ void test_network_remote_local__push_to_non_bare_remote(void)
/* Connect to the bare repo */
cl_git_pass(git_remote_create_anonymous(&localremote, repo, "./localnonbare"));
- cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL));
+ cl_git_pass(git_remote_connect(localremote, GIT_DIRECTION_PUSH, NULL, NULL));
/* Try to push */
cl_git_fail_with(GIT_EBAREREPO, git_remote_upload(localremote, &push_array, NULL));
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index 2fa21d460..46abc6d33 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -93,7 +93,7 @@ void test_network_remote_remotes__error_when_no_push_available(void)
cl_git_pass(git_remote_create_anonymous(&r, _repo, cl_fixture("testrepo.git")));
callbacks.transport = git_transport_local;
- cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks));
+ cl_git_pass(git_remote_connect(r, GIT_DIRECTION_PUSH, &callbacks, NULL));
/* Make sure that push is really not available */
r->transport->push = NULL;
@@ -359,7 +359,7 @@ void test_network_remote_remotes__can_load_with_an_empty_url(void)
cl_assert(remote->url == NULL);
cl_assert(remote->pushurl == NULL);
- cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_assert(giterr_last() != NULL);
cl_assert(giterr_last()->klass == GITERR_INVALID);
@@ -376,7 +376,7 @@ void test_network_remote_remotes__can_load_with_only_an_empty_pushurl(void)
cl_assert(remote->url == NULL);
cl_assert(remote->pushurl == NULL);
- cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_fail(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
git_remote_free(remote);
}
diff --git a/tests/odb/sorting.c b/tests/odb/sorting.c
index 147a160c8..d24c49c69 100644
--- a/tests/odb/sorting.c
+++ b/tests/odb/sorting.c
@@ -14,6 +14,7 @@ static git_odb_backend *new_backend(size_t position)
if (b == NULL)
return NULL;
+ b->base.free = (void (*)(git_odb_backend *)) git__free;
b->base.version = GIT_ODB_BACKEND_VERSION;
b->position = position;
return (git_odb_backend *)b;
diff --git a/tests/online/badssl.c b/tests/online/badssl.c
new file mode 100644
index 000000000..850468320
--- /dev/null
+++ b/tests/online/badssl.c
@@ -0,0 +1,27 @@
+#include "clar_libgit2.h"
+
+#include "git2/clone.h"
+
+static git_repository *g_repo;
+
+#if defined(GIT_OPENSSL) || defined(GIT_WINHTTP) || defined(GIT_SECURE_TRANSPORT)
+
+void test_online_badssl__expired(void)
+{
+ cl_git_fail_with(GIT_ECERTIFICATE,
+ git_clone(&g_repo, "https://expired.badssl.com/fake.git", "./fake", NULL));
+}
+
+void test_online_badssl__wrong_host(void)
+{
+ cl_git_fail_with(GIT_ECERTIFICATE,
+ git_clone(&g_repo, "https://wrong.host.badssl.com/fake.git", "./fake", NULL));
+}
+
+void test_online_badssl__self_signed(void)
+{
+ cl_git_fail_with(GIT_ECERTIFICATE,
+ git_clone(&g_repo, "https://self-signed.badssl.com/fake.git", "./fake", NULL));
+}
+
+#endif
diff --git a/tests/online/clone.c b/tests/online/clone.c
index 225b3abe2..b84be405c 100644
--- a/tests/online/clone.c
+++ b/tests/online/clone.c
@@ -213,6 +213,33 @@ void test_online_clone__custom_remote_callbacks(void)
cl_assert(callcount > 0);
}
+void test_online_clone__custom_headers(void)
+{
+ char *empty_header = "";
+ char *unnamed_header = "this is a header about nothing";
+ char *newlines = "X-Custom: almost OK\n";
+ char *conflict = "Accept: defined-by-git";
+ char *ok = "X-Custom: this should be ok";
+
+ g_options.fetch_opts.custom_headers.count = 1;
+
+ g_options.fetch_opts.custom_headers.strings = &empty_header;
+ cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
+
+ g_options.fetch_opts.custom_headers.strings = &unnamed_header;
+ cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
+
+ g_options.fetch_opts.custom_headers.strings = &newlines;
+ cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
+
+ g_options.fetch_opts.custom_headers.strings = &conflict;
+ cl_git_fail(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
+
+ /* Finally, we got it right! */
+ g_options.fetch_opts.custom_headers.strings = &ok;
+ cl_git_pass(git_clone(&g_repo, LIVE_REPO_URL, "./foo", &g_options));
+}
+
static int cred_failure_cb(
git_cred **cred,
const char *url,
diff --git a/tests/online/fetch.c b/tests/online/fetch.c
index 72e7c24e3..c12df069f 100644
--- a/tests/online/fetch.c
+++ b/tests/online/fetch.c
@@ -81,11 +81,11 @@ void test_online_fetch__fetch_twice(void)
{
git_remote *remote;
cl_git_pass(git_remote_create(&remote, _repo, "test", "git://github.com/libgit2/TestGitRepository.git"));
- cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_git_pass(git_remote_download(remote, NULL, NULL));
git_remote_disconnect(remote);
- git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL);
+ git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL);
cl_git_pass(git_remote_download(remote, NULL, NULL));
git_remote_disconnect(remote);
@@ -117,7 +117,7 @@ void test_online_fetch__doesnt_retrieve_a_pack_when_the_repository_is_up_to_date
cl_git_pass(git_repository_open(&_repository, "./fetch/lg2"));
cl_git_pass(git_remote_lookup(&remote, _repository, "origin"));
- cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_assert_equal_i(false, invoked);
@@ -155,7 +155,7 @@ void test_online_fetch__can_cancel(void)
options.callbacks.transfer_progress = cancel_at_half;
options.callbacks.payload = &bytes_received;
- cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_git_fail_with(git_remote_download(remote, NULL, &options), -4321);
git_remote_disconnect(remote);
git_remote_free(remote);
@@ -169,7 +169,7 @@ void test_online_fetch__ls_disconnected(void)
cl_git_pass(git_remote_create(&remote, _repo, "test",
"http://github.com/libgit2/TestGitRepository.git"));
- cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
cl_git_pass(git_remote_ls(&refs, &refs_len_before, remote));
git_remote_disconnect(remote);
cl_git_pass(git_remote_ls(&refs, &refs_len_after, remote));
@@ -187,7 +187,7 @@ void test_online_fetch__remote_symrefs(void)
cl_git_pass(git_remote_create(&remote, _repo, "test",
"http://github.com/libgit2/TestGitRepository.git"));
- cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL));
+ cl_git_pass(git_remote_connect(remote, GIT_DIRECTION_FETCH, NULL, NULL));
git_remote_disconnect(remote);
cl_git_pass(git_remote_ls(&refs, &refs_len, remote));
diff --git a/tests/online/push.c b/tests/online/push.c
index 4d2b1d310..77c437622 100644
--- a/tests/online/push.c
+++ b/tests/online/push.c
@@ -372,7 +372,7 @@ void test_online_push__initialize(void)
record_callbacks_data_clear(&_record_cbs_data);
- cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH, &_record_cbs));
+ cl_git_pass(git_remote_connect(_remote, GIT_DIRECTION_PUSH, &_record_cbs, NULL));
/* Clean up previously pushed branches. Fails if receive.denyDeletes is
* set on the remote. Also, on Git 1.7.0 and newer, you must run
diff --git a/tests/repo/reservedname.c b/tests/repo/reservedname.c
index faea0cc2b..2a5b38239 100644
--- a/tests/repo/reservedname.c
+++ b/tests/repo/reservedname.c
@@ -106,3 +106,27 @@ void test_repo_reservedname__submodule_pointer(void)
git_repository_free(sub_repo);
#endif
}
+
+/* Like the `submodule_pointer` test (above), this ensures that we do not
+ * follow the gitlink to the submodule's repository location and treat that
+ * as a reserved name. This tests at an initial submodule update, where the
+ * submodule repo is being created.
+ */
+void test_repo_reservedname__submodule_pointer_during_create(void)
+{
+ git_repository *repo;
+ git_submodule *sm;
+ git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
+ git_buf url = GIT_BUF_INIT;
+
+ repo = setup_fixture_super();
+
+ cl_git_pass(git_buf_joinpath(&url, clar_sandbox_path(), "sub.git"));
+ cl_repo_set_string(repo, "submodule.sub.url", url.ptr);
+
+ cl_git_pass(git_submodule_lookup(&sm, repo, "sub"));
+ cl_git_pass(git_submodule_update(sm, 1, &update_options));
+
+ git_submodule_free(sm);
+ git_buf_free(&url);
+}
diff --git a/tests/resources/sub.git/HEAD b/tests/resources/sub.git/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/tests/resources/sub.git/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests/resources/sub.git/config b/tests/resources/sub.git/config
new file mode 100644
index 000000000..78387c50b
--- /dev/null
+++ b/tests/resources/sub.git/config
@@ -0,0 +1,8 @@
+[core]
+ repositoryformatversion = 0
+ filemode = false
+ bare = false
+ logallrefupdates = true
+ symlinks = false
+ ignorecase = true
+ hideDotFiles = dotGitOnly
diff --git a/tests/resources/sub.git/index b/tests/resources/sub.git/index
new file mode 100644
index 000000000..54be69e33
--- /dev/null
+++ b/tests/resources/sub.git/index
Binary files differ
diff --git a/tests/resources/sub.git/logs/HEAD b/tests/resources/sub.git/logs/HEAD
new file mode 100644
index 000000000..f636268f6
--- /dev/null
+++ b/tests/resources/sub.git/logs/HEAD
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000 b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Edward Thomson <ethomson@microsoft.com> 1442522322 -0400 commit (initial): Initial revision
diff --git a/tests/resources/sub.git/logs/refs/heads/master b/tests/resources/sub.git/logs/refs/heads/master
new file mode 100644
index 000000000..f636268f6
--- /dev/null
+++ b/tests/resources/sub.git/logs/refs/heads/master
@@ -0,0 +1 @@
+0000000000000000000000000000000000000000 b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8 Edward Thomson <ethomson@microsoft.com> 1442522322 -0400 commit (initial): Initial revision
diff --git a/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d b/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d
new file mode 100644
index 000000000..a095b3fb8
--- /dev/null
+++ b/tests/resources/sub.git/objects/10/ddd6d257e01349d514541981aeecea6b2e741d
Binary files differ
diff --git a/tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623 b/tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623
new file mode 100644
index 000000000..ef8316670
--- /dev/null
+++ b/tests/resources/sub.git/objects/17/6a458f94e0ea5272ce67c36bf30b6be9caf623
Binary files differ
diff --git a/tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb b/tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb
new file mode 100644
index 000000000..9adc11d71
--- /dev/null
+++ b/tests/resources/sub.git/objects/94/c7d78d85c933d1d95b56bc2de01833ba8559fb
Binary files differ
diff --git a/tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8 b/tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8
new file mode 100644
index 000000000..221b55de7
--- /dev/null
+++ b/tests/resources/sub.git/objects/b7/a59b3f4ea13b985f8a1e0d3757d5cd3331add8
Binary files differ
diff --git a/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773 b/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773
new file mode 100644
index 000000000..d9bb9c84d
--- /dev/null
+++ b/tests/resources/sub.git/objects/d0/ee23c41b28746d7e822511d7838bce784ae773
Binary files differ
diff --git a/tests/resources/sub.git/refs/heads/master b/tests/resources/sub.git/refs/heads/master
new file mode 100644
index 000000000..0e4d6e2a7
--- /dev/null
+++ b/tests/resources/sub.git/refs/heads/master
@@ -0,0 +1 @@
+b7a59b3f4ea13b985f8a1e0d3757d5cd3331add8
diff --git a/tests/resources/super/.gitted/COMMIT_EDITMSG b/tests/resources/super/.gitted/COMMIT_EDITMSG
new file mode 100644
index 000000000..e2d6b8987
--- /dev/null
+++ b/tests/resources/super/.gitted/COMMIT_EDITMSG
@@ -0,0 +1 @@
+submodule
diff --git a/tests/resources/super/.gitted/HEAD b/tests/resources/super/.gitted/HEAD
new file mode 100644
index 000000000..cb089cd89
--- /dev/null
+++ b/tests/resources/super/.gitted/HEAD
@@ -0,0 +1 @@
+ref: refs/heads/master
diff --git a/tests/resources/super/.gitted/config b/tests/resources/super/.gitted/config
new file mode 100644
index 000000000..06a8b7790
--- /dev/null
+++ b/tests/resources/super/.gitted/config
@@ -0,0 +1,10 @@
+[core]
+ repositoryformatversion = 0
+ filemode = false
+ bare = false
+ logallrefupdates = true
+ symlinks = false
+ ignorecase = true
+ hideDotFiles = dotGitOnly
+[submodule "sub"]
+ url = ../sub.git
diff --git a/tests/resources/super/.gitted/index b/tests/resources/super/.gitted/index
new file mode 100644
index 000000000..cc2ffffb9
--- /dev/null
+++ b/tests/resources/super/.gitted/index
Binary files differ
diff --git a/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4 b/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4
new file mode 100644
index 000000000..727d3a696
--- /dev/null
+++ b/tests/resources/super/.gitted/objects/51/589c218bf77a8da9e9d8dbc097d76a742726c4
Binary files differ
diff --git a/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91 b/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91
new file mode 100644
index 000000000..7fd889d5f
--- /dev/null
+++ b/tests/resources/super/.gitted/objects/79/d0d58ca6aa1688a073d280169908454cad5b91
Binary files differ
diff --git a/tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034 b/tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034
new file mode 100644
index 000000000..f26c68c54
--- /dev/null
+++ b/tests/resources/super/.gitted/objects/d7/57768b570a83e80d02edcc1032db14573e5034
Binary files differ
diff --git a/tests/resources/super/.gitted/refs/heads/master b/tests/resources/super/.gitted/refs/heads/master
new file mode 100644
index 000000000..663a9dcd9
--- /dev/null
+++ b/tests/resources/super/.gitted/refs/heads/master
@@ -0,0 +1 @@
+79d0d58ca6aa1688a073d280169908454cad5b91
diff --git a/tests/resources/super/gitmodules b/tests/resources/super/gitmodules
new file mode 100644
index 000000000..a3d8f7f5a
--- /dev/null
+++ b/tests/resources/super/gitmodules
@@ -0,0 +1,3 @@
+[submodule "sub"]
+ path = sub
+ url = ../sub.git
diff --git a/tests/submodule/submodule_helpers.c b/tests/submodule/submodule_helpers.c
index 1dc687231..cde69d92d 100644
--- a/tests/submodule/submodule_helpers.c
+++ b/tests/submodule/submodule_helpers.c
@@ -126,6 +126,22 @@ git_repository *setup_fixture_submod2(void)
return repo;
}
+git_repository *setup_fixture_super(void)
+{
+ git_repository *repo = cl_git_sandbox_init("super");
+
+ cl_fixture_sandbox("sub.git");
+ p_mkdir("super/sub", 0777);
+
+ rewrite_gitmodules(git_repository_workdir(repo));
+
+ cl_set_cleanup(cleanup_fixture_submodules, "sub.git");
+
+ cl_git_pass(git_repository_reinit_filesystem(repo, 1));
+
+ return repo;
+}
+
git_repository *setup_fixture_submodule_simple(void)
{
git_repository *repo = cl_git_sandbox_init("submodule_simple");
diff --git a/tests/submodule/submodule_helpers.h b/tests/submodule/submodule_helpers.h
index 1493f245f..1191ab35b 100644
--- a/tests/submodule/submodule_helpers.h
+++ b/tests/submodule/submodule_helpers.h
@@ -4,6 +4,7 @@ extern void rewrite_gitmodules(const char *workdir);
extern git_repository *setup_fixture_submodules(void);
extern git_repository *setup_fixture_submod2(void);
extern git_repository *setup_fixture_submodule_simple(void);
+extern git_repository *setup_fixture_super(void);
extern unsigned int get_submodule_status(git_repository *, const char *);
diff --git a/tests/win32/longpath.c b/tests/win32/longpath.c
new file mode 100644
index 000000000..6de7d389a
--- /dev/null
+++ b/tests/win32/longpath.c
@@ -0,0 +1,60 @@
+#include "clar_libgit2.h"
+
+#include "git2/clone.h"
+#include "clone.h"
+#include "buffer.h"
+#include "fileops.h"
+
+static git_buf path = GIT_BUF_INIT;
+
+void test_win32_longpath__initialize(void)
+{
+#ifdef GIT_WIN32
+ const char *base = clar_sandbox_path();
+ size_t base_len = strlen(base);
+ size_t remain = MAX_PATH - base_len;
+ size_t i;
+
+ git_buf_clear(&path);
+ git_buf_puts(&path, base);
+ git_buf_putc(&path, '/');
+
+ cl_assert(remain < (MAX_PATH - 5));
+
+ for (i = 0; i < (remain - 5); i++)
+ git_buf_putc(&path, 'a');
+#endif
+}
+
+void test_win32_longpath__cleanup(void)
+{
+ git_buf_free(&path);
+}
+
+#ifdef GIT_WIN32
+void assert_name_too_long(void)
+{
+ const git_error *err;
+ size_t expected_len, actual_len;
+ const char *expected_msg;
+
+ err = giterr_last();
+ actual_len = strlen(err->message);
+
+ expected_msg = git_win32_get_error_message(ERROR_FILENAME_EXCED_RANGE);
+ expected_len = strlen(expected_msg);
+
+ /* check the suffix */
+ cl_assert_equal_s(expected_msg, err->message + (actual_len - expected_len));
+}
+#endif
+
+void test_win32_longpath__errmsg_on_checkout(void)
+{
+#ifdef GIT_WIN32
+ git_repository *repo;
+
+ cl_git_fail(git_clone(&repo, cl_fixture("testrepo.git"), path.ptr, NULL));
+ assert_name_too_long();
+#endif
+}