tests: repo: move template tests into their own suite There's quite a lot of supporting code for our templates and they are an obvious standalone feature. Thus, let's extract those tests into their own suite to also make refactoring of them easier.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
diff --git a/tests/repo/init.c b/tests/repo/init.c
index f2155b4..9879ef1 100644
--- a/tests/repo/init.c
+++ b/tests/repo/init.c
@@ -13,20 +13,13 @@ enum repo_mode {
static git_repository *_repo = NULL;
static git_buf _global_path = GIT_BUF_INIT;
-static mode_t g_umask = 0;
void test_repo_init__initialize(void)
{
_repo = NULL;
- /* load umask if not already loaded */
- if (!g_umask) {
- g_umask = p_umask(022);
- (void)p_umask(g_umask);
- }
-
- git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
- &_global_path);
+ git_libgit2_opts(GIT_OPT_GET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
+ &_global_path);
}
void test_repo_init__cleanup(void)
@@ -380,17 +373,6 @@ void test_repo_init__sets_logAllRefUpdates_according_to_type_of_repository(void)
assert_config_entry_on_init_bytype("core.logallrefupdates", true, false);
}
-void test_repo_init__empty_template_path(void)
-{
- git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- opts.template_path = "";
-
- cl_git_pass(git_futils_mkdir("foo", 0755, 0));
- cl_git_pass(git_repository_init_ext(&_repo, "foo", &opts));
-
- cleanup_repository("foo");
-}
-
void test_repo_init__extended_0(void)
{
git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
@@ -524,253 +506,6 @@ void test_repo_init__relative_gitdir_2(void)
cleanup_repository("root");
}
-#define CLEAR_FOR_CORE_FILEMODE(M) ((M) &= ~0177)
-
-static void assert_hooks_match(
- const char *template_dir,
- const char *repo_dir,
- const char *hook_path,
- bool core_filemode)
-{
- git_buf expected = GIT_BUF_INIT;
- git_buf actual = GIT_BUF_INIT;
- struct stat expected_st, st;
-
- cl_git_pass(git_buf_joinpath(&expected, template_dir, hook_path));
- cl_git_pass(git_path_lstat(expected.ptr, &expected_st));
-
- cl_git_pass(git_buf_joinpath(&actual, repo_dir, hook_path));
- cl_git_pass(git_path_lstat(actual.ptr, &st));
-
- cl_assert(expected_st.st_size == st.st_size);
-
- if (GIT_MODE_TYPE(expected_st.st_mode) != GIT_FILEMODE_LINK) {
- mode_t expected_mode =
- GIT_MODE_TYPE(expected_st.st_mode) |
- (GIT_PERMS_FOR_WRITE(expected_st.st_mode) & ~g_umask);
-
- if (!core_filemode) {
- CLEAR_FOR_CORE_FILEMODE(expected_mode);
- CLEAR_FOR_CORE_FILEMODE(st.st_mode);
- }
-
- cl_assert_equal_i_fmt(expected_mode, st.st_mode, "%07o");
- }
-
- git_buf_dispose(&expected);
- git_buf_dispose(&actual);
-}
-
-static void assert_mode_seems_okay(
- const char *base, const char *path,
- git_filemode_t expect_mode, bool expect_setgid, bool core_filemode)
-{
- git_buf full = GIT_BUF_INIT;
- struct stat st;
-
- cl_git_pass(git_buf_joinpath(&full, base, path));
- cl_git_pass(git_path_lstat(full.ptr, &st));
- git_buf_dispose(&full);
-
- if (!core_filemode) {
- CLEAR_FOR_CORE_FILEMODE(expect_mode);
- CLEAR_FOR_CORE_FILEMODE(st.st_mode);
- expect_setgid = false;
- }
-
- if (S_ISGID != 0)
- cl_assert_equal_b(expect_setgid, (st.st_mode & S_ISGID) != 0);
-
- cl_assert_equal_b(
- GIT_PERMS_IS_EXEC(expect_mode), GIT_PERMS_IS_EXEC(st.st_mode));
-
- cl_assert_equal_i_fmt(
- GIT_MODE_TYPE(expect_mode), GIT_MODE_TYPE(st.st_mode), "%07o");
-}
-
-static const char *template_sandbox(const char *name)
-{
- git_buf hooks_path = GIT_BUF_INIT, link_path = GIT_BUF_INIT,
- dotfile_path = GIT_BUF_INIT;
- const char *path = cl_fixture(name);
-
- cl_fixture_sandbox(name);
-
- /* create a symlink from link.sample to update.sample if the filesystem
- * supports it.
- */
-
- cl_git_pass(git_buf_joinpath(&hooks_path, name, "hooks"));
- cl_git_pass(git_buf_joinpath(&link_path, hooks_path.ptr, "link.sample"));
-
-#ifdef GIT_WIN32
- cl_git_mkfile(link_path.ptr, "#!/bin/sh\necho hello, world\n");
-#else
- cl_must_pass(symlink("update.sample", link_path.ptr));
-#endif
-
- /* create a file starting with a dot */
- cl_git_pass(git_buf_joinpath(&dotfile_path, hooks_path.ptr, ".dotfile"));
- cl_git_mkfile(dotfile_path.ptr, "something\n");
- git_buf_dispose(&dotfile_path);
-
- git_buf_dispose(&dotfile_path);
- git_buf_dispose(&link_path);
- git_buf_dispose(&hooks_path);
-
- return path;
-}
-
-static void configure_templatedir(const char *template_path)
-{
- create_tmp_global_config("tmp_global_path", "init.templatedir", template_path);
-}
-
-static void validate_templates(git_repository *repo, const char *template_path)
-{
- git_buf template_description = GIT_BUF_INIT;
- git_buf repo_description = GIT_BUF_INIT;
- git_buf expected = GIT_BUF_INIT;
- git_buf actual = GIT_BUF_INIT;
- int filemode;
-
- cl_git_pass(git_buf_joinpath(&template_description, template_path,
- "description"));
- cl_git_pass(git_buf_joinpath(&repo_description, git_repository_path(repo),
- "description"));
-
- cl_git_pass(git_futils_readbuffer(&expected, template_description.ptr));
- cl_git_pass(git_futils_readbuffer(&actual, repo_description.ptr));
-
- cl_assert_equal_s(expected.ptr, actual.ptr);
-
- filemode = cl_repo_get_bool(repo, "core.filemode");
-
- assert_hooks_match(
- template_path, git_repository_path(repo),
- "hooks/update.sample", filemode);
-
- assert_hooks_match(
- template_path, git_repository_path(repo),
- "hooks/link.sample", filemode);
-
- assert_hooks_match(
- template_path, git_repository_path(repo),
- "hooks/.dotfile", filemode);
-
- git_buf_dispose(&expected);
- git_buf_dispose(&actual);
- git_buf_dispose(&repo_description);
- git_buf_dispose(&template_description);
-}
-
-void test_repo_init__external_templates_specified_in_options(void)
-{
- git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
-
- cl_set_cleanup(&cleanup_repository, "templated.git");
- template_sandbox("template");
-
- opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
- GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
- opts.template_path = "template";
-
- cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));
-
- cl_assert(git_repository_is_bare(_repo));
-
- cl_assert(!git__suffixcmp(git_repository_path(_repo), "/templated.git/"));
-
- validate_templates(_repo, "template");
- cl_fixture_cleanup("template");
-}
-
-void test_repo_init__external_templates_specified_in_config(void)
-{
- git_buf template_path = GIT_BUF_INIT;
-
- git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
-
- cl_set_cleanup(&cleanup_repository, "templated.git");
- template_sandbox("template");
-
- cl_git_pass(git_buf_joinpath(&template_path, clar_sandbox_path(),
- "template"));
-
- configure_templatedir(template_path.ptr);
-
- opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
- GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
-
- cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));
-
- validate_templates(_repo, "template");
- cl_fixture_cleanup("template");
-
- git_buf_dispose(&template_path);
-}
-
-void test_repo_init__external_templates_with_leading_dot(void)
-{
- git_buf template_path = GIT_BUF_INIT;
-
- git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
-
- cl_set_cleanup(&cleanup_repository, "templated.git");
- template_sandbox("template");
-
- cl_must_pass(p_rename("template", ".template_with_leading_dot"));
-
- cl_git_pass(git_buf_joinpath(&template_path, clar_sandbox_path(),
- ".template_with_leading_dot"));
-
- configure_templatedir(template_path.ptr);
-
- opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
- GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
-
- cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));
-
- validate_templates(_repo, ".template_with_leading_dot");
- cl_fixture_cleanup(".template_with_leading_dot");
-
- git_buf_dispose(&template_path);
-}
-
-void test_repo_init__extended_with_template_and_shared_mode(void)
-{
- git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
- int filemode = true;
- const char *repo_path = NULL;
-
- cl_set_cleanup(&cleanup_repository, "init_shared_from_tpl");
- template_sandbox("template");
-
- opts.flags = GIT_REPOSITORY_INIT_MKPATH |
- GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
- opts.template_path = "template";
- opts.mode = GIT_REPOSITORY_INIT_SHARED_GROUP;
-
- cl_git_pass(git_repository_init_ext(&_repo, "init_shared_from_tpl", &opts));
-
- cl_assert(!git_repository_is_bare(_repo));
- cl_assert(!git__suffixcmp(git_repository_path(_repo), "/init_shared_from_tpl/.git/"));
-
- filemode = cl_repo_get_bool(_repo, "core.filemode");
-
- repo_path = git_repository_path(_repo);
- assert_mode_seems_okay(repo_path, "hooks",
- GIT_FILEMODE_TREE | GIT_REPOSITORY_INIT_SHARED_GROUP, true, filemode);
- assert_mode_seems_okay(repo_path, "info",
- GIT_FILEMODE_TREE | GIT_REPOSITORY_INIT_SHARED_GROUP, true, filemode);
- assert_mode_seems_okay(repo_path, "description",
- GIT_FILEMODE_BLOB, false, filemode);
-
- validate_templates(_repo, "template");
-
- cl_fixture_cleanup("template");
-}
-
void test_repo_init__can_reinit_an_initialized_repository(void)
{
git_repository *reinit;
diff --git a/tests/repo/template.c b/tests/repo/template.c
new file mode 100644
index 0000000..9b89043
--- /dev/null
+++ b/tests/repo/template.c
@@ -0,0 +1,294 @@
+#include "clar_libgit2.h"
+
+#include "fileops.h"
+#include "repo/repo_helpers.h"
+
+#define CLEAR_FOR_CORE_FILEMODE(M) ((M) &= ~0177)
+
+static git_repository *_repo = NULL;
+static mode_t g_umask = 0;
+static git_buf _global_path = GIT_BUF_INIT;
+
+void test_repo_template__initialize(void)
+{
+ _repo = NULL;
+
+ /* load umask if not already loaded */
+ if (!g_umask) {
+ g_umask = p_umask(022);
+ (void)p_umask(g_umask);
+ }
+}
+
+void test_repo_template__cleanup(void)
+{
+ git_libgit2_opts(GIT_OPT_SET_SEARCH_PATH, GIT_CONFIG_LEVEL_GLOBAL,
+ _global_path.ptr);
+ git_buf_dispose(&_global_path);
+
+ cl_fixture_cleanup("tmp_global_path");
+}
+
+static void cleanup_repository(void *path)
+{
+ git_repository_free(_repo);
+ _repo = NULL;
+
+ cl_fixture_cleanup((const char *)path);
+}
+
+static void assert_hooks_match(
+ const char *template_dir,
+ const char *repo_dir,
+ const char *hook_path,
+ bool core_filemode)
+{
+ git_buf expected = GIT_BUF_INIT;
+ git_buf actual = GIT_BUF_INIT;
+ struct stat expected_st, st;
+
+ cl_git_pass(git_buf_joinpath(&expected, template_dir, hook_path));
+ cl_git_pass(git_path_lstat(expected.ptr, &expected_st));
+
+ cl_git_pass(git_buf_joinpath(&actual, repo_dir, hook_path));
+ cl_git_pass(git_path_lstat(actual.ptr, &st));
+
+ cl_assert(expected_st.st_size == st.st_size);
+
+ if (GIT_MODE_TYPE(expected_st.st_mode) != GIT_FILEMODE_LINK) {
+ mode_t expected_mode =
+ GIT_MODE_TYPE(expected_st.st_mode) |
+ (GIT_PERMS_FOR_WRITE(expected_st.st_mode) & ~g_umask);
+
+ if (!core_filemode) {
+ CLEAR_FOR_CORE_FILEMODE(expected_mode);
+ CLEAR_FOR_CORE_FILEMODE(st.st_mode);
+ }
+
+ cl_assert_equal_i_fmt(expected_mode, st.st_mode, "%07o");
+ }
+
+ git_buf_dispose(&expected);
+ git_buf_dispose(&actual);
+}
+
+static void assert_mode_seems_okay(
+ const char *base, const char *path,
+ git_filemode_t expect_mode, bool expect_setgid, bool core_filemode)
+{
+ git_buf full = GIT_BUF_INIT;
+ struct stat st;
+
+ cl_git_pass(git_buf_joinpath(&full, base, path));
+ cl_git_pass(git_path_lstat(full.ptr, &st));
+ git_buf_dispose(&full);
+
+ if (!core_filemode) {
+ CLEAR_FOR_CORE_FILEMODE(expect_mode);
+ CLEAR_FOR_CORE_FILEMODE(st.st_mode);
+ expect_setgid = false;
+ }
+
+ if (S_ISGID != 0)
+ cl_assert_equal_b(expect_setgid, (st.st_mode & S_ISGID) != 0);
+
+ cl_assert_equal_b(
+ GIT_PERMS_IS_EXEC(expect_mode), GIT_PERMS_IS_EXEC(st.st_mode));
+
+ cl_assert_equal_i_fmt(
+ GIT_MODE_TYPE(expect_mode), GIT_MODE_TYPE(st.st_mode), "%07o");
+}
+
+static const char *template_sandbox(const char *name)
+{
+ git_buf hooks_path = GIT_BUF_INIT, link_path = GIT_BUF_INIT,
+ dotfile_path = GIT_BUF_INIT;
+ const char *path = cl_fixture(name);
+
+ cl_fixture_sandbox(name);
+
+ /* create a symlink from link.sample to update.sample if the filesystem
+ * supports it.
+ */
+
+ cl_git_pass(git_buf_joinpath(&hooks_path, name, "hooks"));
+ cl_git_pass(git_buf_joinpath(&link_path, hooks_path.ptr, "link.sample"));
+
+#ifdef GIT_WIN32
+ cl_git_mkfile(link_path.ptr, "#!/bin/sh\necho hello, world\n");
+#else
+ cl_must_pass(symlink("update.sample", link_path.ptr));
+#endif
+
+ /* create a file starting with a dot */
+ cl_git_pass(git_buf_joinpath(&dotfile_path, hooks_path.ptr, ".dotfile"));
+ cl_git_mkfile(dotfile_path.ptr, "something\n");
+ git_buf_dispose(&dotfile_path);
+
+ git_buf_dispose(&dotfile_path);
+ git_buf_dispose(&link_path);
+ git_buf_dispose(&hooks_path);
+
+ return path;
+}
+
+static void configure_templatedir(const char *template_path)
+{
+ create_tmp_global_config("tmp_global_path", "init.templatedir", template_path);
+}
+
+static void validate_templates(git_repository *repo, const char *template_path)
+{
+ git_buf template_description = GIT_BUF_INIT;
+ git_buf repo_description = GIT_BUF_INIT;
+ git_buf expected = GIT_BUF_INIT;
+ git_buf actual = GIT_BUF_INIT;
+ int filemode;
+
+ cl_git_pass(git_buf_joinpath(&template_description, template_path,
+ "description"));
+ cl_git_pass(git_buf_joinpath(&repo_description, git_repository_path(repo),
+ "description"));
+
+ cl_git_pass(git_futils_readbuffer(&expected, template_description.ptr));
+ cl_git_pass(git_futils_readbuffer(&actual, repo_description.ptr));
+
+ cl_assert_equal_s(expected.ptr, actual.ptr);
+
+ filemode = cl_repo_get_bool(repo, "core.filemode");
+
+ assert_hooks_match(
+ template_path, git_repository_path(repo),
+ "hooks/update.sample", filemode);
+
+ assert_hooks_match(
+ template_path, git_repository_path(repo),
+ "hooks/link.sample", filemode);
+
+ assert_hooks_match(
+ template_path, git_repository_path(repo),
+ "hooks/.dotfile", filemode);
+
+ git_buf_dispose(&expected);
+ git_buf_dispose(&actual);
+ git_buf_dispose(&repo_description);
+ git_buf_dispose(&template_description);
+}
+
+void test_repo_template__external_templates_specified_in_options(void)
+{
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+
+ cl_set_cleanup(&cleanup_repository, "templated.git");
+ template_sandbox("template");
+
+ opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
+ GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
+ opts.template_path = "template";
+
+ cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));
+
+ cl_assert(git_repository_is_bare(_repo));
+
+ cl_assert(!git__suffixcmp(git_repository_path(_repo), "/templated.git/"));
+
+ validate_templates(_repo, "template");
+ cl_fixture_cleanup("template");
+}
+
+void test_repo_template__external_templates_specified_in_config(void)
+{
+ git_buf template_path = GIT_BUF_INIT;
+
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+
+ cl_set_cleanup(&cleanup_repository, "templated.git");
+ template_sandbox("template");
+
+ cl_git_pass(git_buf_joinpath(&template_path, clar_sandbox_path(),
+ "template"));
+
+ configure_templatedir(template_path.ptr);
+
+ opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
+ GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
+
+ cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));
+
+ validate_templates(_repo, "template");
+ cl_fixture_cleanup("template");
+
+ git_buf_dispose(&template_path);
+}
+
+void test_repo_template__external_templates_with_leading_dot(void)
+{
+ git_buf template_path = GIT_BUF_INIT;
+
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+
+ cl_set_cleanup(&cleanup_repository, "templated.git");
+ template_sandbox("template");
+
+ cl_must_pass(p_rename("template", ".template_with_leading_dot"));
+
+ cl_git_pass(git_buf_joinpath(&template_path, clar_sandbox_path(),
+ ".template_with_leading_dot"));
+
+ configure_templatedir(template_path.ptr);
+
+ opts.flags = GIT_REPOSITORY_INIT_MKPATH | GIT_REPOSITORY_INIT_BARE |
+ GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
+
+ cl_git_pass(git_repository_init_ext(&_repo, "templated.git", &opts));
+
+ validate_templates(_repo, ".template_with_leading_dot");
+ cl_fixture_cleanup(".template_with_leading_dot");
+
+ git_buf_dispose(&template_path);
+}
+
+void test_repo_template__extended_with_template_and_shared_mode(void)
+{
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+ int filemode = true;
+ const char *repo_path = NULL;
+
+ cl_set_cleanup(&cleanup_repository, "init_shared_from_tpl");
+ template_sandbox("template");
+
+ opts.flags = GIT_REPOSITORY_INIT_MKPATH |
+ GIT_REPOSITORY_INIT_EXTERNAL_TEMPLATE;
+ opts.template_path = "template";
+ opts.mode = GIT_REPOSITORY_INIT_SHARED_GROUP;
+
+ cl_git_pass(git_repository_init_ext(&_repo, "init_shared_from_tpl", &opts));
+
+ cl_assert(!git_repository_is_bare(_repo));
+ cl_assert(!git__suffixcmp(git_repository_path(_repo), "/init_shared_from_tpl/.git/"));
+
+ filemode = cl_repo_get_bool(_repo, "core.filemode");
+
+ repo_path = git_repository_path(_repo);
+ assert_mode_seems_okay(repo_path, "hooks",
+ GIT_FILEMODE_TREE | GIT_REPOSITORY_INIT_SHARED_GROUP, true, filemode);
+ assert_mode_seems_okay(repo_path, "info",
+ GIT_FILEMODE_TREE | GIT_REPOSITORY_INIT_SHARED_GROUP, true, filemode);
+ assert_mode_seems_okay(repo_path, "description",
+ GIT_FILEMODE_BLOB, false, filemode);
+
+ validate_templates(_repo, "template");
+
+ cl_fixture_cleanup("template");
+}
+
+void test_repo_template__empty_template_path(void)
+{
+ git_repository_init_options opts = GIT_REPOSITORY_INIT_OPTIONS_INIT;
+ opts.template_path = "";
+
+ cl_git_pass(git_futils_mkdir("foo", 0755, 0));
+ cl_git_pass(git_repository_init_ext(&_repo, "foo", &opts));
+
+ cleanup_repository("foo");
+}