1 #include "clar_libgit2.h"
3 #include "repository.h"
6 #include "config/config_helpers.h"
7 #include "repo/repo_helpers.h"
10 STANDARD_REPOSITORY
= 0,
14 static git_repository
*g_repo
= NULL
;
15 static git_str g_global_path
= GIT_STR_INIT
;
17 void test_repo_init__initialize(void)
21 git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH
, GIT_CONFIG_LEVEL_GLOBAL
,
25 void test_repo_init__cleanup(void)
27 git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH
, GIT_CONFIG_LEVEL_GLOBAL
,
29 git_str_dispose(&g_global_path
);
31 cl_fixture_cleanup("tmp_global_path");
34 static void cleanup_repository(void *path
)
36 git_repository_free(g_repo
);
39 cl_fixture_cleanup((const char *)path
);
42 static void ensure_repository_init(
43 const char *working_directory
,
45 const char *expected_path_repository
,
46 const char *expected_working_directory
)
50 cl_assert(!git_fs_path_isdir(working_directory
));
52 cl_git_pass(git_repository_init(&g_repo
, working_directory
, is_bare
));
54 workdir
= git_repository_workdir(g_repo
);
55 if (workdir
!= NULL
|| expected_working_directory
!= NULL
) {
57 git__suffixcmp(workdir
, expected_working_directory
) == 0
62 git__suffixcmp(git_repository_path(g_repo
), expected_path_repository
) == 0
65 cl_assert(git_repository_is_bare(g_repo
) == is_bare
);
69 DWORD fattrs
= GetFileAttributes(git_repository_path(g_repo
));
70 cl_assert((fattrs
& FILE_ATTRIBUTE_HIDDEN
) != 0);
74 cl_assert(git_repository_is_empty(g_repo
));
77 void test_repo_init__standard_repo(void)
79 cl_set_cleanup(&cleanup_repository
, "testrepo");
80 ensure_repository_init("testrepo/", 0, "testrepo/.git/", "testrepo/");
83 void test_repo_init__standard_repo_noslash(void)
85 cl_set_cleanup(&cleanup_repository
, "testrepo");
86 ensure_repository_init("testrepo", 0, "testrepo/.git/", "testrepo/");
89 void test_repo_init__bare_repo(void)
91 cl_set_cleanup(&cleanup_repository
, "testrepo.git");
92 ensure_repository_init("testrepo.git/", 1, "testrepo.git/", NULL
);
95 void test_repo_init__bare_repo_noslash(void)
97 cl_set_cleanup(&cleanup_repository
, "testrepo.git");
98 ensure_repository_init("testrepo.git", 1, "testrepo.git/", NULL
);
101 void test_repo_init__bare_repo_escaping_current_workdir(void)
103 git_str path_repository
= GIT_STR_INIT
;
104 git_str path_current_workdir
= GIT_STR_INIT
;
106 cl_git_pass(git_fs_path_prettify_dir(&path_current_workdir
, ".", NULL
));
108 cl_git_pass(git_str_joinpath(&path_repository
, git_str_cstr(&path_current_workdir
), "a/b/c"));
109 cl_git_pass(git_futils_mkdir_r(git_str_cstr(&path_repository
), GIT_DIR_MODE
));
111 /* Change the current working directory */
112 cl_git_pass(chdir(git_str_cstr(&path_repository
)));
114 /* Initialize a bare repo with a relative path escaping out of the current working directory */
115 cl_git_pass(git_repository_init(&g_repo
, "../d/e.git", 1));
116 cl_git_pass(git__suffixcmp(git_repository_path(g_repo
), "/a/b/d/e.git/"));
118 git_repository_free(g_repo
);
121 /* Open a bare repo with a relative path escaping out of the current working directory */
122 cl_git_pass(git_repository_open(&g_repo
, "../d/e.git"));
124 cl_git_pass(chdir(git_str_cstr(&path_current_workdir
)));
126 git_str_dispose(&path_current_workdir
);
127 git_str_dispose(&path_repository
);
129 cleanup_repository("a");
132 void test_repo_init__reinit_bare_repo(void)
134 cl_set_cleanup(&cleanup_repository
, "reinit.git");
136 /* Initialize the repository */
137 cl_git_pass(git_repository_init(&g_repo
, "reinit.git", 1));
138 git_repository_free(g_repo
);
141 /* Reinitialize the repository */
142 cl_git_pass(git_repository_init(&g_repo
, "reinit.git", 1));
145 void test_repo_init__reinit_too_recent_bare_repo(void)
149 /* Initialize the repository */
150 cl_git_pass(git_repository_init(&g_repo
, "reinit.git", 1));
151 git_repository_config(&config
, g_repo
);
154 * Hack the config of the repository to make it look like it has
155 * been created by a recenter version of git/libgit2
157 cl_git_pass(git_config_set_int32(config
, "core.repositoryformatversion", 42));
159 git_config_free(config
);
160 git_repository_free(g_repo
);
163 /* Try to reinitialize the repository */
164 cl_git_fail(git_repository_init(&g_repo
, "reinit.git", 1));
166 cl_fixture_cleanup("reinit.git");
169 void test_repo_init__additional_templates(void)
171 git_str path
= GIT_STR_INIT
;
173 cl_set_cleanup(&cleanup_repository
, "tester");
175 ensure_repository_init("tester", 0, "tester/.git/", "tester/");
178 git_str_joinpath(&path
, git_repository_path(g_repo
), "description"));
179 cl_assert(git_fs_path_isfile(git_str_cstr(&path
)));
182 git_str_joinpath(&path
, git_repository_path(g_repo
), "info/exclude"));
183 cl_assert(git_fs_path_isfile(git_str_cstr(&path
)));
186 git_str_joinpath(&path
, git_repository_path(g_repo
), "hooks"));
187 cl_assert(git_fs_path_isdir(git_str_cstr(&path
)));
188 /* won't confirm specific contents of hooks dir since it may vary */
190 git_str_dispose(&path
);
193 static void assert_config_entry_on_init_bytype(
194 const char *config_key
, int expected_value
, bool is_bare
)
197 int error
, current_value
;
198 const char *repo_path
= is_bare
?
199 "config_entry/test.bare.git" : "config_entry/test.non.bare.git";
201 cl_set_cleanup(&cleanup_repository
, "config_entry");
203 cl_git_pass(git_repository_init(&g_repo
, repo_path
, is_bare
));
205 cl_git_pass(git_repository_config(&config
, g_repo
));
206 error
= git_config_get_bool(¤t_value
, config
, config_key
);
207 git_config_free(config
);
209 if (expected_value
>= 0) {
210 cl_assert_equal_i(0, error
);
211 cl_assert_equal_i(expected_value
, current_value
);
213 cl_assert_equal_i(expected_value
, error
);
217 static void assert_config_entry_on_init(
218 const char *config_key
, int expected_value
)
220 assert_config_entry_on_init_bytype(config_key
, expected_value
, true);
221 git_repository_free(g_repo
);
224 assert_config_entry_on_init_bytype(config_key
, expected_value
, false);
227 void test_repo_init__detect_filemode(void)
229 assert_config_entry_on_init("core.filemode", cl_is_chmod_supported());
232 void test_repo_init__detect_ignorecase(void)
235 bool found_without_match
;
237 cl_git_write2file("testCAPS", "whatever\n", 0, O_CREAT
| O_WRONLY
, 0666);
238 found_without_match
= (p_stat("Testcaps", &st
) == 0);
239 cl_must_pass(p_unlink("testCAPS"));
241 assert_config_entry_on_init(
242 "core.ignorecase", found_without_match
? true : GIT_ENOTFOUND
);
246 * Windows: if the filesystem supports symlinks (because we're running
247 * as administrator, or because the user has opted into it for normal
248 * users) then we can also opt-in explicitly by settings `core.symlinks`
249 * in the global config. Symlinks remain off by default.
252 void test_repo_init__symlinks_win32_enabled_by_global_config(void)
257 git_config
*config
, *repo_config
;
260 if (!git_fs_path_supports_symlinks("link"))
263 create_tmp_global_config("tmp_global_config", "core.symlinks", "true");
266 * Create a new repository (can't use `assert_config_on_init` since we
267 * want to examine configuration levels with more granularity.)
269 cl_git_pass(git_repository_init(&g_repo
, "config_entry/test.non.bare.git", false));
271 /* Ensure that core.symlinks remains set (via the global config). */
272 cl_git_pass(git_repository_config(&config
, g_repo
));
273 cl_git_pass(git_config_get_bool(&val
, config
, "core.symlinks"));
274 cl_assert_equal_i(1, val
);
277 * Ensure that the repository config does not set core.symlinks.
278 * It should remain inherited.
280 cl_git_pass(git_config_open_level(&repo_config
, config
, GIT_CONFIG_LEVEL_LOCAL
));
281 cl_git_fail_with(GIT_ENOTFOUND
, git_config_get_bool(&val
, repo_config
, "core.symlinks"));
282 git_config_free(repo_config
);
284 git_config_free(config
);
286 git_repository_free(g_repo
);
291 void test_repo_init__symlinks_win32_off_by_default(void)
296 assert_config_entry_on_init("core.symlinks", false);
300 void test_repo_init__symlinks_posix_detected(void)
305 assert_config_entry_on_init(
306 "core.symlinks", git_fs_path_supports_symlinks("link") ? GIT_ENOTFOUND
: false);
310 void test_repo_init__detect_precompose_unicode_required(void)
313 char *composed
= "ḱṷṓn", *decomposed
= "ḱṷṓn";
317 cl_git_write2file(composed
, "whatever\n", 0, O_CREAT
| O_WRONLY
, 0666);
318 found_with_nfd
= (p_stat(decomposed
, &st
) == 0);
319 cl_must_pass(p_unlink(composed
));
321 assert_config_entry_on_init("core.precomposeunicode", found_with_nfd
);
323 assert_config_entry_on_init("core.precomposeunicode", GIT_ENOTFOUND
);
327 void test_repo_init__reinit_doesnot_overwrite_ignorecase(void)
332 /* Init a new repo */
333 cl_set_cleanup(&cleanup_repository
, "not.overwrite.git");
334 cl_git_pass(git_repository_init(&g_repo
, "not.overwrite.git", 1));
336 /* Change the "core.ignorecase" config value to something unlikely */
337 git_repository_config(&config
, g_repo
);
338 git_config_set_int32(config
, "core.ignorecase", 42);
339 git_config_free(config
);
340 git_repository_free(g_repo
);
343 /* Reinit the repository */
344 cl_git_pass(git_repository_init(&g_repo
, "not.overwrite.git", 1));
345 git_repository_config(&config
, g_repo
);
347 /* Ensure the "core.ignorecase" config value hasn't been updated */
348 cl_git_pass(git_config_get_int32(¤t_value
, config
, "core.ignorecase"));
349 cl_assert_equal_i(42, current_value
);
351 git_config_free(config
);
354 void test_repo_init__reinit_overwrites_filemode(void)
356 int expected
= cl_is_chmod_supported(), current_value
;
358 /* Init a new repo */
359 cl_set_cleanup(&cleanup_repository
, "overwrite.git");
360 cl_git_pass(git_repository_init(&g_repo
, "overwrite.git", 1));
362 /* Change the "core.filemode" config value to something unlikely */
363 cl_repo_set_bool(g_repo
, "core.filemode", !expected
);
365 git_repository_free(g_repo
);
368 /* Reinit the repository */
369 cl_git_pass(git_repository_init(&g_repo
, "overwrite.git", 1));
371 /* Ensure the "core.filemode" config value has been reset */
372 current_value
= cl_repo_get_bool(g_repo
, "core.filemode");
373 cl_assert_equal_i(expected
, current_value
);
376 void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
378 assert_config_entry_on_init_bytype("core.logallrefupdates", GIT_ENOTFOUND
, true);
379 git_repository_free(g_repo
);
380 assert_config_entry_on_init_bytype("core.logallrefupdates", true, false);
383 void test_repo_init__extended_0(void)
385 git_repository_init_options opts
= GIT_REPOSITORY_INIT_OPTIONS_INIT
;
387 /* without MKDIR this should fail */
388 cl_git_fail(git_repository_init_ext(&g_repo
, "extended", &opts
));
390 /* make the directory first, then it should succeed */
391 cl_git_pass(git_futils_mkdir("extended", 0775, 0));
392 cl_git_pass(git_repository_init_ext(&g_repo
, "extended", &opts
));
394 cl_assert(!git__suffixcmp(git_repository_workdir(g_repo
), "/extended/"));
395 cl_assert(!git__suffixcmp(git_repository_path(g_repo
), "/extended/.git/"));
396 cl_assert(!git_repository_is_bare(g_repo
));
397 cl_assert(git_repository_is_empty(g_repo
));
399 cleanup_repository("extended");
402 void test_repo_init__extended_1(void)
407 git_repository_init_options opts
= GIT_REPOSITORY_INIT_OPTIONS_INIT
;
409 opts
.flags
= GIT_REPOSITORY_INIT_MKPATH
|
410 GIT_REPOSITORY_INIT_NO_DOTGIT_DIR
;
411 opts
.mode
= GIT_REPOSITORY_INIT_SHARED_GROUP
;
412 opts
.workdir_path
= "../c_wd";
413 opts
.description
= "Awesomest test repository evah";
414 opts
.initial_head
= "development";
415 opts
.origin_url
= "https://github.com/libgit2/libgit2.git";
417 cl_git_pass(git_repository_init_ext(&g_repo
, "root/b/c.git", &opts
));
419 cl_assert(!git__suffixcmp(git_repository_workdir(g_repo
), "/c_wd/"));
420 cl_assert(!git__suffixcmp(git_repository_path(g_repo
), "/c.git/"));
421 cl_assert(git_fs_path_isfile("root/b/c_wd/.git"));
422 cl_assert(!git_repository_is_bare(g_repo
));
423 /* repo will not be counted as empty because we set head to "development" */
424 cl_assert(!git_repository_is_empty(g_repo
));
426 cl_git_pass(git_fs_path_lstat(git_repository_path(g_repo
), &st
));
427 cl_assert(S_ISDIR(st
.st_mode
));
428 if (cl_is_chmod_supported())
429 cl_assert((S_ISGID
& st
.st_mode
) == S_ISGID
);
431 cl_assert((S_ISGID
& st
.st_mode
) == 0);
433 cl_git_pass(git_reference_lookup(&ref
, g_repo
, "HEAD"));
434 cl_assert(git_reference_type(ref
) == GIT_REFERENCE_SYMBOLIC
);
435 cl_assert_equal_s("refs/heads/development", git_reference_symbolic_target(ref
));
436 git_reference_free(ref
);
438 cl_git_pass(git_remote_lookup(&remote
, g_repo
, "origin"));
439 cl_assert_equal_s("origin", git_remote_name(remote
));
440 cl_assert_equal_s(opts
.origin_url
, git_remote_url(remote
));
441 git_remote_free(remote
);
443 git_repository_free(g_repo
);
444 cl_fixture_cleanup("root");
447 void test_repo_init__relative_gitdir(void)
449 git_repository_init_options opts
= GIT_REPOSITORY_INIT_OPTIONS_INIT
;
450 git_str dot_git_content
= GIT_STR_INIT
;
452 opts
.workdir_path
= "../c_wd";
454 GIT_REPOSITORY_INIT_MKPATH
|
455 GIT_REPOSITORY_INIT_RELATIVE_GITLINK
|
456 GIT_REPOSITORY_INIT_NO_DOTGIT_DIR
;
458 /* make the directory first, then it should succeed */
459 cl_git_pass(git_repository_init_ext(&g_repo
, "root/b/my_repository", &opts
));
461 cl_assert(!git__suffixcmp(git_repository_workdir(g_repo
), "root/b/c_wd/"));
462 cl_assert(!git__suffixcmp(git_repository_path(g_repo
), "root/b/my_repository/"));
463 cl_assert(!git_repository_is_bare(g_repo
));
464 cl_assert(git_repository_is_empty(g_repo
));
466 /* Verify that the gitlink and worktree entries are relative */
468 /* Verify worktree */
469 assert_config_entry_value(g_repo
, "core.worktree", "../c_wd/");
472 cl_git_pass(git_futils_readbuffer(&dot_git_content
, "root/b/c_wd/.git"));
473 cl_assert_equal_s("gitdir: ../my_repository/", dot_git_content
.ptr
);
475 git_str_dispose(&dot_git_content
);
476 cleanup_repository("root");
479 void test_repo_init__relative_gitdir_2(void)
481 git_repository_init_options opts
= GIT_REPOSITORY_INIT_OPTIONS_INIT
;
482 git_str dot_git_content
= GIT_STR_INIT
;
483 git_str full_path
= GIT_STR_INIT
;
485 cl_git_pass(git_fs_path_prettify(&full_path
, ".", NULL
));
486 cl_git_pass(git_str_joinpath(&full_path
, full_path
.ptr
, "root/b/c_wd"));
488 opts
.workdir_path
= full_path
.ptr
;
490 GIT_REPOSITORY_INIT_MKPATH
|
491 GIT_REPOSITORY_INIT_RELATIVE_GITLINK
|
492 GIT_REPOSITORY_INIT_NO_DOTGIT_DIR
;
494 /* make the directory first, then it should succeed */
495 cl_git_pass(git_repository_init_ext(&g_repo
, "root/b/my_repository", &opts
));
496 git_str_dispose(&full_path
);
498 cl_assert(!git__suffixcmp(git_repository_workdir(g_repo
), "root/b/c_wd/"));
499 cl_assert(!git__suffixcmp(git_repository_path(g_repo
), "root/b/my_repository/"));
500 cl_assert(!git_repository_is_bare(g_repo
));
501 cl_assert(git_repository_is_empty(g_repo
));
503 /* Verify that the gitlink and worktree entries are relative */
505 /* Verify worktree */
506 assert_config_entry_value(g_repo
, "core.worktree", "../c_wd/");
509 cl_git_pass(git_futils_readbuffer(&dot_git_content
, "root/b/c_wd/.git"));
510 cl_assert_equal_s("gitdir: ../my_repository/", dot_git_content
.ptr
);
512 git_str_dispose(&dot_git_content
);
513 cleanup_repository("root");
516 void test_repo_init__can_reinit_an_initialized_repository(void)
518 git_repository
*reinit
;
520 cl_set_cleanup(&cleanup_repository
, "extended");
522 cl_git_pass(git_futils_mkdir("extended", 0775, 0));
523 cl_git_pass(git_repository_init(&g_repo
, "extended", false));
525 cl_git_pass(git_repository_init(&reinit
, "extended", false));
527 cl_assert_equal_s(git_repository_path(g_repo
), git_repository_path(reinit
));
529 git_repository_free(reinit
);
532 void test_repo_init__init_with_initial_commit(void)
536 cl_set_cleanup(&cleanup_repository
, "committed");
538 /* Initialize the repository */
539 cl_git_pass(git_repository_init(&g_repo
, "committed", 0));
541 /* Index will be automatically created when requested for a new repo */
542 cl_git_pass(git_repository_index(&index
, g_repo
));
544 /* Create a file so we can commit it
546 * If you are writing code outside the test suite, you can create this
547 * file any way that you like, such as:
548 * FILE *fp = fopen("committed/file.txt", "w");
549 * fputs("some stuff\n", fp);
551 * We like to use the help functions because they do error detection
552 * in a way that's easily compatible with our test suite.
554 cl_git_mkfile("committed/file.txt", "some stuff\n");
556 /* Add file to the index */
557 cl_git_pass(git_index_add_bypath(index
, "file.txt"));
558 cl_git_pass(git_index_write(index
));
560 /* Intentionally not using cl_repo_commit_from_index here so this code
561 * can be used as an example of how an initial commit is typically
562 * made to a repository...
565 /* Make sure we're ready to use git_signature_default :-) */
567 git_config
*cfg
, *local
;
568 cl_git_pass(git_repository_config(&cfg
, g_repo
));
569 cl_git_pass(git_config_open_level(&local
, cfg
, GIT_CONFIG_LEVEL_LOCAL
));
570 cl_git_pass(git_config_set_string(local
, "user.name", "Test User"));
571 cl_git_pass(git_config_set_string(local
, "user.email", "t@example.com"));
572 git_config_free(local
);
573 git_config_free(cfg
);
576 /* Create a commit with the new contents of the index */
579 git_oid tree_id
, commit_id
;
582 cl_git_pass(git_signature_default(&sig
, g_repo
));
583 cl_git_pass(git_index_write_tree(&tree_id
, index
));
584 cl_git_pass(git_tree_lookup(&tree
, g_repo
, &tree_id
));
586 cl_git_pass(git_commit_create_v(
587 &commit_id
, g_repo
, "HEAD", sig
, sig
,
588 NULL
, "First", tree
, 0));
591 git_signature_free(sig
);
594 git_index_free(index
);
597 void test_repo_init__at_filesystem_root(void)
599 git_repository
*repo
;
600 const char *sandbox
= clar_sandbox_path();
601 git_str root
= GIT_STR_INIT
;
604 if (!cl_is_env_set("GITTEST_INVASIVE_FS_STRUCTURE"))
607 root_len
= git_fs_path_root(sandbox
);
608 cl_assert(root_len
>= 0);
610 git_str_put(&root
, sandbox
, root_len
+1);
611 git_str_joinpath(&root
, root
.ptr
, "libgit2_test_dir");
613 cl_assert(!git_fs_path_exists(root
.ptr
));
615 cl_git_pass(git_repository_init(&repo
, root
.ptr
, 0));
616 cl_assert(git_fs_path_isdir(root
.ptr
));
617 cl_git_pass(git_futils_rmdir_r(root
.ptr
, NULL
, GIT_RMDIR_REMOVE_FILES
));
619 git_str_dispose(&root
);
620 git_repository_free(repo
);
623 void test_repo_init__nonexisting_directory(void)
625 git_repository_init_options opts
= GIT_REPOSITORY_INIT_OPTIONS_INIT
;
626 git_repository
*repo
;
629 * If creating a repo with non-existing parent directories, then libgit2
630 * will by default create the complete directory hierarchy if using
631 * `git_repository_init`. Thus, let's use the extended version and not
632 * set the `GIT_REPOSITORY_INIT_MKPATH` flag.
634 cl_git_fail(git_repository_init_ext(&repo
, "nonexisting/path", &opts
));
637 void test_repo_init__nonexisting_root(void)
640 git_repository
*repo
;
643 * This really only depends on the nonexistence of the Q: drive. We
644 * cannot implement the equivalent test on Unix systems, as there is
645 * fundamentally no path that is disconnected from the root directory.
647 cl_git_fail(git_repository_init(&repo
, "Q:/non/existent/path", 0));
648 cl_git_fail(git_repository_init(&repo
, "Q:\\non\\existent\\path", 0));
654 void test_repo_init__unwriteable_directory(void)
657 git_repository
*repo
;
663 * Create a non-writeable directory so that we cannot create directories
664 * inside of it. The root user has CAP_DAC_OVERRIDE, so he doesn't care
665 * for the directory permissions and thus we need to skip the test if
668 cl_must_pass(p_mkdir("unwriteable", 0444));
669 cl_git_fail(git_repository_init(&repo
, "unwriteable/repo", 0));
670 cl_must_pass(p_rmdir("unwriteable"));
676 void test_repo_init__defaultbranch_config(void)
680 cl_set_cleanup(&cleanup_repository
, "repo");
682 create_tmp_global_config("tmp_global_path", "init.defaultbranch", "my_default_branch");
684 cl_git_pass(git_repository_init(&g_repo
, "repo", 0));
685 cl_git_pass(git_reference_lookup(&head
, g_repo
, "HEAD"));
687 cl_assert_equal_s("refs/heads/my_default_branch", git_reference_symbolic_target(head
));
689 git_reference_free(head
);
692 void test_repo_init__defaultbranch_config_empty(void)
696 cl_set_cleanup(&cleanup_repository
, "repo");
698 create_tmp_global_config("tmp_global_path", "init.defaultbranch", "");
700 cl_git_pass(git_repository_init(&g_repo
, "repo", 0));
701 cl_git_pass(git_reference_lookup(&head
, g_repo
, "HEAD"));
703 cl_assert_equal_s("refs/heads/master", git_reference_symbolic_target(head
));
705 git_reference_free(head
);
708 void test_repo_init__longpath(void)
711 size_t padding
= CONST_STRLEN("objects/pack/pack-.pack.lock") + GIT_OID_HEXSZ
;
713 git_str path
= GIT_STR_INIT
;
714 git_repository
*one
= NULL
, *two
= NULL
;
717 * Files within repositories need to fit within MAX_PATH;
718 * that means a repo path must be at most (MAX_PATH - 18).
720 cl_git_pass(git_str_puts(&path
, clar_sandbox_path()));
721 cl_git_pass(git_str_putc(&path
, '/'));
723 max
= ((MAX_PATH
) - path
.size
) - padding
;
725 for (i
= 0; i
< max
- 1; i
++)
726 cl_git_pass(git_str_putc(&path
, 'a'));
728 cl_git_pass(git_repository_init(&one
, path
.ptr
, 1));
730 /* Paths longer than this are rejected */
731 cl_git_pass(git_str_putc(&path
, 'z'));
732 cl_git_fail(git_repository_init(&two
, path
.ptr
, 1));
734 git_repository_free(one
);
735 git_repository_free(two
);
736 git_str_dispose(&path
);