line |
true |
false |
branch |
91
|
2 |
44 |
if (odb) { |
96
|
35 |
11 |
if ((odb = git__swap(repo->_odb, odb)) != NULL) { |
104
|
0 |
44 |
if (refdb) { |
109
|
35 |
9 |
if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) { |
117
|
0 |
44 |
if (config) { |
122
|
44 |
0 |
if ((config = git__swap(repo->_config, config)) != NULL) { |
132
|
1 |
45 |
if (index) { |
137
|
17 |
29 |
if ((index = git__swap(repo->_index, index)) != NULL) { |
145
|
0 |
44 |
assert(repo); |
163
|
0 |
44 |
if (repo == NULL) |
173
|
0 |
44 |
for (i = 0; i < repo->reserved_names.size; i++) |
174
|
0 |
0 |
git_buf_dispose(git_array_get(repo->reserved_names, i)); |
202
|
4 |
47 |
if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) { |
205
|
4 |
0 |
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 || |
|
0 |
4 |
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 || |
210
|
0 |
4 |
if (git_path_is_relative(common_link.ptr)) { |
211
|
0 |
0 |
if ((error = git_buf_joinpath(common_path, repository_path->ptr, common_link.ptr)) < 0) |
220
|
0 |
47 |
if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0) |
225
|
42 |
9 |
if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1) |
226
|
0 |
42 |
if ((error = git_buf_putc(common_path, '/')) < 0) |
230
|
6 |
45 |
if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false) |
233
|
0 |
45 |
if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false) |
235
|
0 |
45 |
if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false) |
251
|
0 |
44 |
if (!repo->reserved_names.ptr) |
260
|
0 |
0 |
if (repo) |
272
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(repo); |
285
|
0 |
44 |
if (err < 0 && err != GIT_ENOTFOUND) |
|
0 |
0 |
if (err < 0 && err != GIT_ENOTFOUND) |
289
|
44 |
0 |
if (err != GIT_ENOTFOUND) |
290
|
8 |
36 |
repo->is_bare = is_bare && !repo->is_worktree; |
|
8 |
0 |
repo->is_bare = is_bare && !repo->is_worktree; |
304
|
8 |
36 |
if (repo->is_bare) |
307
|
0 |
36 |
if ((error = git_config__lookup_entry( |
311
|
4 |
32 |
if (repo->is_worktree) { |
313
|
0 |
4 |
if (!gitlink) { |
328
|
0 |
32 |
else if (ce && ce->value) { |
|
0 |
0 |
else if (ce && ce->value) { |
329
|
0 |
0 |
if ((error = git_path_prettify_dir( |
335
|
32 |
0 |
else if (parent_path && git_path_isdir(parent_path->ptr)) |
|
32 |
0 |
else if (parent_path && git_path_isdir(parent_path->ptr)) |
347
|
0 |
36 |
GIT_ERROR_CHECK_ALLOC(repo->workdir); |
371
|
0 |
1 |
assert(path); |
375
|
0 |
1 |
if (ceiling_directories == NULL || min_len == 0) |
|
0 |
0 |
if (ceiling_directories == NULL || min_len == 0) |
378
|
0 |
0 |
for (sep = ceil = ceiling_directories; *sep; ceil = sep + 1) { |
379
|
0 |
0 |
for (sep = ceil; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++); |
|
0 |
0 |
for (sep = ceil; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++); |
382
|
0 |
0 |
if (len == 0 || len >= sizeof(buf) || git_path_root(ceil) == -1) |
|
0 |
0 |
if (len == 0 || len >= sizeof(buf) || git_path_root(ceil) == -1) |
|
0 |
0 |
if (len == 0 || len >= sizeof(buf) || git_path_root(ceil) == -1) |
388
|
0 |
0 |
if (p_realpath(buf, buf2) == NULL) |
392
|
0 |
0 |
if (len > 0 && buf2[len-1] == '/') |
|
0 |
0 |
if (len > 0 && buf2[len-1] == '/') |
395
|
0 |
0 |
if (!strncmp(path, buf2, len) && |
|
0 |
0 |
if (!strncmp(path, buf2, len) && |
396
|
0 |
0 |
(path[len] == '/' || !path[len]) && |
|
0 |
0 |
(path[len] == '/' || !path[len]) && |
417
|
4 |
0 |
assert(path_out && file_path); |
|
0 |
4 |
assert(path_out && file_path); |
419
|
0 |
4 |
if (git_futils_readbuffer(&file, file_path) < 0) |
433
|
4 |
0 |
else if ((error = git_path_dirname_r(path_out, file_path)) >= 0) { |
435
|
8 |
0 |
while (*gitlink && git__isspace(*gitlink)) gitlink++; |
|
4 |
4 |
while (*gitlink && git__isspace(*gitlink)) gitlink++; |
467
|
0 |
45 |
if (error < 0) |
477
|
0 |
45 |
if (flags & (GIT_REPOSITORY_OPEN_BARE | GIT_REPOSITORY_OPEN_NO_DOTGIT)) { |
486
|
59 |
0 |
if (!(flags & GIT_REPOSITORY_OPEN_NO_DOTGIT)) { |
487
|
46 |
13 |
if (!in_dot_git) { |
488
|
0 |
46 |
if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0) |
494
|
46 |
13 |
if (p_stat(path.ptr, &st) == 0) { |
496
|
45 |
1 |
if (initial_device == 0) |
498
|
0 |
1 |
else if (st.st_dev != initial_device && |
|
0 |
0 |
else if (st.st_dev != initial_device && |
502
|
42 |
4 |
if (S_ISDIR(st.st_mode)) { |
503
|
0 |
42 |
if ((error = is_valid_repository_path(&is_valid, &path, &common_link)) < 0) |
506
|
41 |
1 |
if (is_valid) { |
507
|
41 |
0 |
if ((error = git_path_to_dir(&path)) < 0 || |
|
41 |
0 |
if ((error = git_path_to_dir(&path)) < 0 || |
511
|
40 |
1 |
if (gitlink_path) |
512
|
0 |
40 |
if ((error = git_buf_attach(gitlink_path, git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0)) < 0) |
514
|
40 |
1 |
if (commondir_path) |
519
|
4 |
0 |
} else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) { |
|
4 |
0 |
} else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) { |
520
|
4 |
0 |
if ((error = read_gitfile(&repo_link, path.ptr)) < 0 || |
|
4 |
0 |
if ((error = read_gitfile(&repo_link, path.ptr)) < 0 || |
524
|
4 |
0 |
if (is_valid) { |
527
|
4 |
0 |
if (gitlink_path) |
528
|
0 |
4 |
if ((error = git_buf_put(gitlink_path, path.ptr, path.size)) < 0) |
530
|
4 |
0 |
if (commondir_path) |
540
|
0 |
14 |
if ((error = git_path_dirname_r(&path, path.ptr)) < 0) |
545
|
14 |
0 |
if (min_iterations && (--min_iterations == 0)) |
|
1 |
13 |
if (min_iterations && (--min_iterations == 0)) |
549
|
1 |
13 |
if (min_iterations == 0 && |
|
1 |
0 |
if (min_iterations == 0 && |
550
|
1 |
0 |
(path.ptr[ceiling_offset] == 0 || (flags & GIT_REPOSITORY_OPEN_NO_SEARCH))) |
554
|
44 |
1 |
if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) { |
|
44 |
0 |
if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) { |
555
|
0 |
44 |
if (!git_buf_len(gitdir_path)) |
557
|
44 |
0 |
else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 || |
|
44 |
0 |
else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 || |
564
|
0 |
45 |
if (!git_buf_len(gitdir_path)) { |
586
|
0 |
0 |
if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0 || |
|
0 |
0 |
if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0 || |
590
|
0 |
0 |
if (!is_valid) { |
598
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(repo); |
601
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(repo->gitdir); |
603
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(repo->commondir); |
634
|
0 |
0 |
if (!start_path) { |
636
|
0 |
0 |
if (error == GIT_ENOTFOUND) { |
639
|
0 |
0 |
} else if (error < 0) |
649
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
651
|
0 |
0 |
else if (error < 0) |
657
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
659
|
0 |
0 |
else if (error < 0) |
664
|
0 |
0 |
if (error < 0) |
666
|
0 |
0 |
if (across_fs) |
671
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
673
|
0 |
0 |
else if (error < 0) |
677
|
0 |
0 |
if (error < 0) |
682
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
684
|
0 |
0 |
else if (error < 0) |
688
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
690
|
0 |
0 |
else if (error < 0) |
694
|
0 |
0 |
if (error < 0) |
699
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
701
|
0 |
0 |
else if (error < 0) |
710
|
0 |
0 |
if (error == GIT_ENOTFOUND) |
712
|
0 |
0 |
else if (error < 0) |
721
|
0 |
0 |
if (error < 0) |
724
|
0 |
0 |
if (odb) |
728
|
0 |
0 |
if (error == GIT_ENOTFOUND) { |
731
|
0 |
0 |
} else if (error < 0) |
736
|
0 |
0 |
if (!odb) { |
738
|
0 |
0 |
if (error < 0) |
743
|
0 |
0 |
for (sep = alt = alts_buf.ptr; sep != end; alt = sep+1) { |
744
|
0 |
0 |
for (sep = alt; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++) |
|
0 |
0 |
for (sep = alt; *sep && *sep != GIT_PATH_LIST_SEPARATOR; sep++) |
746
|
0 |
0 |
if (*sep) |
749
|
0 |
0 |
if (error < 0) |
754
|
0 |
0 |
if (git_buf_len(&namespace_buf)) { |
756
|
0 |
0 |
if (error < 0) |
762
|
0 |
0 |
if (out) { |
789
|
44 |
0 |
if (repo->commondir && repo->gitdir |
|
44 |
0 |
if (repo->commondir && repo->gitdir |
790
|
40 |
4 |
&& !strcmp(repo->commondir, repo->gitdir)) { |
795
|
0 |
4 |
if ((error = git_buf_joinpath(&gitdir_link, repo->gitdir, "gitdir")) < 0) |
820
|
0 |
44 |
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV) |
823
|
44 |
0 |
if (repo_ptr) |
829
|
44 |
0 |
if (error < 0 || !repo_ptr) |
|
44 |
0 |
if (error < 0 || !repo_ptr) |
833
|
0 |
44 |
GIT_ERROR_CHECK_ALLOC(repo); |
836
|
0 |
44 |
GIT_ERROR_CHECK_ALLOC(repo->gitdir); |
838
|
4 |
40 |
if (gitlink.size) { |
840
|
0 |
4 |
GIT_ERROR_CHECK_ALLOC(repo->gitlink); |
842
|
44 |
0 |
if (commondir.size) { |
844
|
0 |
44 |
GIT_ERROR_CHECK_ALLOC(repo->commondir); |
847
|
0 |
44 |
if ((error = repo_is_worktree(&is_worktree, repo)) < 0) |
857
|
0 |
44 |
if (error < 0 && error != GIT_ENOTFOUND) |
|
0 |
0 |
if (error < 0 && error != GIT_ENOTFOUND) |
860
|
44 |
0 |
if (config && (error = check_repositoryformatversion(&version, config)) < 0) |
|
0 |
44 |
if (config && (error = check_repositoryformatversion(&version, config)) < 0) |
863
|
0 |
44 |
if ((error = check_extensions(config, version) < 0)) |
866
|
0 |
44 |
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) |
870
|
44 |
0 |
if (config && |
|
44 |
0 |
if (config && |
883
|
0 |
44 |
if (error < 0) |
885
|
44 |
0 |
else if (repo_ptr) |
904
|
1 |
0 |
assert(repo_out && wt); |
|
0 |
1 |
assert(repo_out && wt); |
909
|
1 |
0 |
if (len <= 4 || strcasecmp(wt->gitlink_path + len - 4, ".git")) { |
|
0 |
1 |
if (len <= 4 || strcasecmp(wt->gitlink_path + len - 4, ".git")) { |
914
|
0 |
1 |
if ((err = git_buf_set(&path, wt->gitlink_path, len - 4)) < 0) |
917
|
0 |
1 |
if ((err = git_repository_open(&repo, path.ptr)) < 0) |
933
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(repo); |
947
|
1 |
0 |
uint32_t flags = across_fs ? GIT_REPOSITORY_OPEN_CROSS_FS : 0; |
949
|
0 |
1 |
assert(start_path); |
968
|
0 |
44 |
assert(out); |
970
|
0 |
44 |
if ((error = git_config_new(&cfg)) < 0) |
973
|
44 |
0 |
if (repo) { |
974
|
44 |
0 |
if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0) |
977
|
0 |
44 |
if (error && error != GIT_ENOTFOUND) |
|
0 |
0 |
if (error && error != GIT_ENOTFOUND) |
983
|
44 |
0 |
if (global_config_path != NULL && |
|
0 |
44 |
if (global_config_path != NULL && |
985
|
0 |
0 |
cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, repo, 0)) < 0 && |
989
|
0 |
44 |
if (xdg_config_path != NULL && |
|
0 |
0 |
if (xdg_config_path != NULL && |
991
|
0 |
0 |
cfg, xdg_config_path, GIT_CONFIG_LEVEL_XDG, repo, 0)) < 0 && |
995
|
0 |
44 |
if (system_config_path != NULL && |
|
0 |
0 |
if (system_config_path != NULL && |
997
|
0 |
0 |
cfg, system_config_path, GIT_CONFIG_LEVEL_SYSTEM, repo, 0)) < 0 && |
1001
|
0 |
44 |
if (programdata_path != NULL && |
|
0 |
0 |
if (programdata_path != NULL && |
1003
|
0 |
0 |
cfg, programdata_path, GIT_CONFIG_LEVEL_PROGRAMDATA, repo, 0)) < 0 && |
1021
|
44 |
132 |
return git_buf_len(buf) > 0 ? git_buf_cstr(buf) : NULL; |
1028
|
44 |
872 |
if (repo->_config == NULL) { |
1041
|
44 |
0 |
if (git_buf_len(&global_buf) == 0) |
1050
|
44 |
0 |
if (!error) { |
1054
|
0 |
44 |
if (config != NULL) { |
1072
|
0 |
15 |
if (git_repository_config__weakptr(out, repo) < 0) |
1084
|
0 |
483 |
if ((error = git_repository_config__weakptr(&weak, repo)) < 0) |
1092
|
0 |
0 |
assert(repo && config); |
|
0 |
0 |
assert(repo && config); |
1101
|
2345 |
0 |
assert(repo && out); |
|
0 |
2345 |
assert(repo && out); |
1103
|
33 |
2312 |
if (repo->_odb == NULL) { |
1107
|
33 |
0 |
if ((error = git_repository_item_path(&odb_path, repo, |
1108
|
0 |
33 |
GIT_REPOSITORY_ITEM_OBJECTS)) < 0 || |
1114
|
33 |
0 |
if ((error = git_odb__set_caps(odb, GIT_ODB_CAP_FROM_OWNER)) < 0 || |
|
0 |
33 |
if ((error = git_odb__set_caps(odb, GIT_ODB_CAP_FROM_OWNER)) < 0 || |
1121
|
0 |
33 |
if (odb != NULL) { |
1135
|
0 |
163 |
if (git_repository_odb__weakptr(out, repo) < 0) |
1144
|
2 |
0 |
assert(repo && odb); |
|
0 |
2 |
assert(repo && odb); |
1153
|
1318 |
0 |
assert(out && repo); |
|
0 |
1318 |
assert(out && repo); |
1155
|
35 |
1283 |
if (repo->_refdb == NULL) { |
1159
|
35 |
0 |
if (!error) { |
1163
|
0 |
35 |
if (refdb != NULL) { |
1176
|
0 |
3 |
if (git_repository_refdb__weakptr(out, repo) < 0) |
1185
|
0 |
0 |
assert(repo && refdb); |
|
0 |
0 |
assert(repo && refdb); |
1194
|
2760 |
0 |
assert(out && repo); |
|
0 |
2760 |
assert(out && repo); |
1196
|
16 |
2744 |
if (repo->_index == NULL) { |
1200
|
0 |
16 |
if ((error = git_buf_joinpath(&index_path, repo->gitdir, GIT_INDEX_FILE)) < 0) |
1204
|
16 |
0 |
if (!error) { |
1208
|
0 |
16 |
if (index != NULL) { |
1226
|
0 |
219 |
if (git_repository_index__weakptr(out, repo) < 0) |
1235
|
0 |
2 |
assert(repo); |
1244
|
0 |
0 |
if (namespace == NULL) { |
1249
|
0 |
0 |
return (repo->namespace = git__strdup(namespace)) ? 0 : -1; |
1347
|
370 |
0 |
if (include_ntfs) { |
1365
|
0 |
44 |
if (error == GIT_ENOTFOUND) |
1368
|
0 |
44 |
if (error < 0) |
1371
|
0 |
44 |
if (GIT_REPO_MAX_VERSION < *version) { |
1385
|
0 |
0 |
if (!strcmp(entry->name, "extensions.noop")) |
1394
|
49 |
0 |
if (version < 1) |
1407
|
7 |
0 |
if ((error = git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE)) < 0 || |
|
7 |
0 |
if ((error = git_buf_joinpath(&ref_path, git_dir, GIT_HEAD_FILE)) < 0 || |
1411
|
5 |
2 |
if (!ref_name) |
1414
|
2 |
5 |
if (git__prefixcmp(ref_name, GIT_REFS_DIR) == 0) |
1419
|
7 |
0 |
if ((error = git_filebuf_printf(&ref, fmt, ref_name)) < 0 || |
1433
|
0 |
5 |
if (p_stat(file_path, &st1) < 0) |
1436
|
0 |
5 |
if (p_chmod(file_path, st1.st_mode ^ S_IXUSR) < 0) |
1439
|
0 |
5 |
if (p_stat(file_path, &st2) < 0) |
1450
|
5 |
0 |
if (!git_buf_joinpath(&path, gitdir_path, "CoNfIg")) |
1490
|
0 |
5 |
if (!(symlinks = git_path_supports_symlinks(wd_path))) |
1506
|
0 |
5 |
if ((fd = p_creat(path, mode)) < 0) { |
1511
|
0 |
5 |
if (p_close(fd) < 0) { |
1529
|
0 |
5 |
if (git_buf_joinpath(config_dir, repo_dir, GIT_CONFIG_FILENAME_INREPO) < 0) |
1534
|
5 |
0 |
if (!git_path_isfile(cfg_path) && |
|
0 |
5 |
if (!git_path_isfile(cfg_path) && |
1539
|
5 |
0 |
if (!repo) |
1543
|
0 |
0 |
if ((error = git_repository_config__weakptr(&parent, repo)) < 0) |
1546
|
0 |
0 |
if (git_config_open_level(out, parent, GIT_CONFIG_LEVEL_LOCAL) < 0) { |
1549
|
0 |
0 |
if (!(error = git_config_add_file_ondisk( |
1568
|
2 |
3 |
if (!work_dir) |
1571
|
0 |
5 |
if ((error = git_config_set_bool( |
1575
|
0 |
5 |
if (!are_symlinks_supported(work_dir)) { |
1576
|
0 |
0 |
if ((error = git_config_set_bool(cfg, "core.symlinks", false)) < 0) |
1578
|
5 |
0 |
} else if (git_config_delete_entry(cfg, "core.symlinks") < 0) |
1581
|
5 |
0 |
if (update_ignorecase) { |
1582
|
0 |
5 |
if (is_filesystem_case_insensitive(repo_dir)) { |
1583
|
0 |
0 |
if ((error = git_config_set_bool(cfg, "core.ignorecase", true)) < 0) |
1585
|
5 |
0 |
} else if (git_config_delete_entry(cfg, "core.ignorecase") < 0) |
1613
|
0 |
5 |
if ((error = repo_local_config(&config, &cfg_path, NULL, repo_dir)) < 0) |
1616
|
0 |
5 |
if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0) |
|
0 |
0 |
if (is_reinit && (error = check_repositoryformatversion(&version, config)) < 0) |
1619
|
0 |
5 |
if ((error = check_extensions(config, version) < 0)) |
1626
|
0 |
5 |
SET_REPO_CONFIG(bool, "core.bare", is_bare); |
1627
|
0 |
5 |
SET_REPO_CONFIG(int32, "core.repositoryformatversion", GIT_REPO_VERSION); |
1629
|
0 |
5 |
if ((error = repo_init_fs_configs( |
1633
|
3 |
2 |
if (!is_bare) { |
1634
|
0 |
3 |
SET_REPO_CONFIG(bool, "core.logallrefupdates", true); |
1636
|
0 |
3 |
if (!(flags & GIT_REPOSITORY_INIT__NATURAL_WD)) { |
1637
|
0 |
0 |
if ((error = git_buf_sets(&worktree_path, work_dir)) < 0) |
1640
|
0 |
0 |
if ((flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK)) |
1641
|
0 |
0 |
if ((error = git_path_make_relative(&worktree_path, repo_dir)) < 0) |
1644
|
0 |
0 |
SET_REPO_CONFIG(string, "core.worktree", worktree_path.ptr); |
1645
|
0 |
3 |
} else if (is_reinit) { |
1646
|
0 |
0 |
if (git_config_delete_entry(config, "core.worktree") < 0) |
1651
|
0 |
5 |
if (mode == GIT_REPOSITORY_INIT_SHARED_GROUP) { |
1652
|
0 |
0 |
SET_REPO_CONFIG(int32, "core.sharedrepository", 1); |
1653
|
0 |
0 |
SET_REPO_CONFIG(bool, "receive.denyNonFastforwards", true); |
1655
|
0 |
5 |
else if (mode == GIT_REPOSITORY_INIT_SHARED_ALL) { |
1656
|
0 |
0 |
SET_REPO_CONFIG(int32, "core.sharedrepository", 2); |
1657
|
0 |
0 |
SET_REPO_CONFIG(bool, "receive.denyNonFastforwards", true); |
1688
|
0 |
0 |
if (!(error = repo_local_config(&config, &path, repo, repo_dir))) |
1697
|
0 |
0 |
if (!repo->is_bare && recurse) |
|
0 |
0 |
if (!repo->is_bare && recurse) |
1714
|
0 |
15 |
if (git_buf_joinpath(&path, git_dir, file) < 0) |
1717
|
0 |
15 |
if (allow_overwrite) |
1724
|
15 |
0 |
if (fd >= 0) { |
1729
|
0 |
0 |
else if (errno != EEXIST) |
1743
|
0 |
15 |
if (error) |
1760
|
0 |
0 |
if (git_buf_oom(&buf)) |
1764
|
0 |
0 |
if (git__suffixcmp(to_repo, "/" DOT_GIT "/") == 0 && |
|
0 |
0 |
if (git__suffixcmp(to_repo, "/" DOT_GIT "/") == 0 && |
1771
|
0 |
0 |
if ((error = git_buf_joinpath(&buf, in_dir, DOT_GIT)) < 0) |
1774
|
0 |
0 |
if (!p_stat(buf.ptr, &st) && !S_ISREG(st.st_mode)) { |
|
0 |
0 |
if (!p_stat(buf.ptr, &st) && !S_ISREG(st.st_mode)) { |
1785
|
0 |
0 |
if (!error && use_relative_path) |
|
0 |
0 |
if (!error && use_relative_path) |
1788
|
0 |
0 |
if (!error) |
1791
|
0 |
0 |
if (!error) |
1802
|
10 |
0 |
if (opts->mode == GIT_REPOSITORY_INIT_SHARED_UMASK) |
1804
|
0 |
0 |
if (opts->mode == GIT_REPOSITORY_INIT_SHARED_GROUP) |
1806
|
0 |
0 |
if (opts->mode == GIT_REPOSITORY_INIT_SHARED_ALL) |
1837
|
3 |
2 |
if ((opts->flags & GIT_REPOSITORY_INIT_BARE) == 0 && |
|
0 |
3 |
if ((opts->flags & GIT_REPOSITORY_INIT_BARE) == 0 && |
1840
|
0 |
0 |
if (repo_write_gitlink(work_dir, repo_dir, opts->flags & GIT_REPOSITORY_INIT_RELATIVE_GITLINK) < 0) |
1845
|
0 |
5 |
if (external_tpl) { |
1851
|
0 |
0 |
if (opts->template_path) |
1853
|
0 |
0 |
else if ((error = git_config_open_default(&cfg)) >= 0) { |
1854
|
0 |
0 |
if (!git_config_get_path(&template_buf, cfg, "init.templatedir")) |
1859
|
0 |
0 |
if (!tdir) { |
1860
|
0 |
0 |
if (!(error = git_sysdir_find_template_dir(&template_buf))) |
1871
|
0 |
0 |
if (tdir && git__strcmp(tdir, "") != 0) { |
|
0 |
0 |
if (tdir && git__strcmp(tdir, "") != 0) { |
1875
|
0 |
0 |
if (opts->mode != GIT_REPOSITORY_INIT_SHARED_UMASK) |
1883
|
0 |
0 |
if (error < 0) { |
1884
|
0 |
0 |
if (!default_template) |
1898
|
50 |
0 |
for (tpl = repo_template; !error && tpl->path; ++tpl) { |
|
45 |
5 |
for (tpl = repo_template; !error && tpl->path; ++tpl) { |
1899
|
30 |
15 |
if (!tpl->content) { |
1901
|
0 |
30 |
if (chmod) |
1907
|
15 |
0 |
else if (!external_tpl) { |
1910
|
0 |
15 |
if (opts->description && strcmp(tpl->path, GIT_DESC_FILE) == 0) |
|
0 |
0 |
if (opts->description && strcmp(tpl->path, GIT_DESC_FILE) == 0) |
1926
|
0 |
5 |
return git_futils_mkdir( |
1967
|
3 |
2 |
(opts->flags & GIT_REPOSITORY_INIT_NO_DOTGIT_DIR) == 0 && |
1968
|
3 |
0 |
!is_bare && |
1969
|
5 |
0 |
git__suffixcmp(given_repo, "/" DOT_GIT) != 0 && |
|
3 |
0 |
git__suffixcmp(given_repo, "/" DOT_GIT) != 0 && |
1972
|
3 |
2 |
if (git_buf_joinpath(repo_path, given_repo, add_dotgit ? GIT_DIR : "") < 0) |
|
0 |
5 |
if (git_buf_joinpath(repo_path, given_repo, add_dotgit ? GIT_DIR : "") < 0) |
1976
|
3 |
2 |
if (has_dotgit) |
1981
|
3 |
2 |
if (!is_bare) { |
1982
|
0 |
3 |
if (opts->workdir_path) { |
1983
|
0 |
0 |
if (git_path_join_unrooted( |
1986
|
3 |
0 |
} else if (has_dotgit) { |
1987
|
0 |
3 |
if (git_path_dirname_r(wd_path, repo_path->ptr) < 0) |
1995
|
0 |
3 |
if (git_path_to_dir(wd_path) < 0) |
2002
|
3 |
0 |
has_dotgit && |
2003
|
3 |
0 |
wd_path->size > 0 && |
2004
|
3 |
2 |
wd_path->size + strlen(GIT_DIR) == repo_path->size && |
|
3 |
0 |
wd_path->size + strlen(GIT_DIR) == repo_path->size && |
2006
|
3 |
2 |
if (natural_wd) |
2013
|
5 |
0 |
if ((opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0) { |
2015
|
3 |
2 |
if (wd_path->size > 0 && |
|
0 |
3 |
if (wd_path->size > 0 && |
2020
|
2 |
3 |
if (!natural_wd && |
|
0 |
2 |
if (!natural_wd && |
2025
|
5 |
0 |
if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || |
|
5 |
0 |
if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || |
2029
|
3 |
2 |
if (wd_path->size > 0 && |
|
0 |
3 |
if (wd_path->size > 0 && |
2036
|
2 |
3 |
if (!natural_wd && |
|
0 |
2 |
if (!natural_wd && |
2043
|
5 |
0 |
if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || |
|
0 |
5 |
if ((opts->flags & GIT_REPOSITORY_INIT_MKDIR) != 0 || |
2044
|
0 |
0 |
(opts->flags & GIT_REPOSITORY_INIT_MKPATH) != 0 || |
2048
|
0 |
5 |
error = git_futils_mkdir(repo_path->ptr, dirmode, |
2054
|
5 |
0 |
if (!error) { |
2057
|
5 |
0 |
if (!error && wd_path->size > 0) |
|
3 |
2 |
if (!error && wd_path->size > 0) |
2069
|
0 |
0 |
if (!(error = git_remote_create(&remote, repo, GIT_REMOTE_ORIGIN, url))) { |
2082
|
2 |
3 |
if (is_bare) |
2099
|
5 |
0 |
assert(out && given_repo && opts); |
|
5 |
0 |
assert(out && given_repo && opts); |
|
0 |
5 |
assert(out && given_repo && opts); |
2101
|
0 |
5 |
GIT_ERROR_CHECK_VERSION(opts, GIT_REPOSITORY_INIT_OPTIONS_VERSION, "git_repository_init_options"); |
2103
|
0 |
5 |
if ((error = repo_init_directories(&repo_path, &wd_path, given_repo, opts)) < 0) |
2106
|
3 |
2 |
wd = (opts->flags & GIT_REPOSITORY_INIT_BARE) ? NULL : git_buf_cstr(&wd_path); |
2108
|
0 |
5 |
if ((error = is_valid_repository_path(&is_valid, &repo_path, &common_path)) < 0) |
2111
|
0 |
5 |
if (is_valid) { |
2112
|
0 |
0 |
if ((opts->flags & GIT_REPOSITORY_INIT_NO_REINIT) != 0) { |
2121
|
0 |
0 |
if ((error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0) |
2126
|
5 |
0 |
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 || |
|
5 |
0 |
if ((error = repo_init_structure(repo_path.ptr, wd, opts)) < 0 || |
2127
|
5 |
0 |
(error = repo_init_config(repo_path.ptr, wd, opts->flags, opts->mode)) < 0 || |
2136
|
0 |
5 |
if ((!git_path_exists(head_path.ptr) || opts->initial_head) && |
|
0 |
0 |
if ((!git_path_exists(head_path.ptr) || opts->initial_head) && |
|
0 |
5 |
if ((!git_path_exists(head_path.ptr) || opts->initial_head) && |
2141
|
0 |
5 |
if ((error = git_repository_open(out, repo_path.ptr)) < 0) |
2144
|
0 |
5 |
if (opts->origin_url && |
|
0 |
0 |
if (opts->origin_url && |
2163
|
0 |
6 |
if (git_repository_odb__weakptr(&odb, repo) < 0) |
2166
|
0 |
6 |
if (git_reference_lookup(&ref, repo, GIT_HEAD_FILE) < 0) |
2169
|
2 |
4 |
if (git_reference_type(ref) == GIT_REFERENCE_SYMBOLIC) { |
2191
|
0 |
0 |
assert(repo && name); |
|
0 |
0 |
assert(repo && name); |
2193
|
0 |
0 |
if ((error = git_repository_head_for_worktree(&ref, repo, name)) < 0) |
2208
|
0 |
266 |
assert(head_out); |
2210
|
0 |
266 |
if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0) |
2213
|
21 |
245 |
if (git_reference_type(head) == GIT_REFERENCE_DIRECT) { |
2221
|
230 |
15 |
return error == GIT_ENOTFOUND ? GIT_EUNBORNBRANCH : error; |
2230
|
1 |
0 |
assert(out && repo && name); |
|
1 |
0 |
assert(out && repo && name); |
|
0 |
1 |
assert(out && repo && name); |
2234
|
1 |
0 |
if ((error = get_worktree_file_path(&path, repo, name, GIT_HEAD_FILE)) < 0 || |
|
1 |
0 |
if ((error = get_worktree_file_path(&path, repo, name, GIT_HEAD_FILE)) < 0 || |
2238
|
1 |
0 |
if (git_reference_type(head) != GIT_REFERENCE_DIRECT) { |
2249
|
0 |
1 |
if (error) |
2267
|
18 |
0 |
if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_REPO)) { |
2274
|
18 |
0 |
if (!(flags & GIT_REPOSITORY_FOREACH_HEAD_SKIP_WORKTREES)) { |
2275
|
0 |
18 |
if ((error = git_worktree_list(&worktrees, repo)) < 0) { |
2281
|
0 |
18 |
for (i = 0; i < worktrees.count; i++) { |
2282
|
0 |
0 |
if (get_worktree_file_path(&path, repo, worktrees.strings[i], GIT_HEAD_FILE) < 0) |
2285
|
0 |
0 |
if ((error = cb(repo, path.ptr, payload)) != 0) |
2304
|
0 |
0 |
if (error == GIT_EUNBORNBRANCH) { |
2309
|
0 |
0 |
if (error < 0) |
2326
|
0 |
2 |
if (error == GIT_PASSTHROUGH) |
2329
|
2 |
0 |
if (!error) |
2340
|
0 |
2 |
if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) |
2343
|
2 |
0 |
if (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC) |
2372
|
0 |
1281 |
if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST) |
|
0 |
0 |
if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST) |
2381
|
0 |
1281 |
if (parent == NULL) { |
2386
|
0 |
1281 |
if (git_buf_sets(out, parent) < 0) |
2389
|
1281 |
0 |
if (items[item].name) { |
2390
|
0 |
1281 |
if (git_buf_joinpath(out, parent, items[item].name) < 0) |
2394
|
1237 |
44 |
if (items[item].directory) { |
2395
|
0 |
1237 |
if (git_path_to_dir(out) < 0) |
2404
|
0 |
30 |
assert(repo); |
2410
|
0 |
7203 |
assert(repo); |
2412
|
0 |
7203 |
if (repo->is_bare) |
2420
|
0 |
1284 |
assert(repo); |
2430
|
2 |
0 |
assert(repo && workdir); |
|
0 |
2 |
assert(repo && workdir); |
2432
|
0 |
2 |
if (git_path_prettify_dir(&path, workdir, NULL) < 0) |
2435
|
2 |
0 |
if (repo->workdir && strcmp(repo->workdir, path.ptr) == 0) |
|
2 |
0 |
if (repo->workdir && strcmp(repo->workdir, path.ptr) == 0) |
2438
|
0 |
0 |
if (update_gitlink) { |
2441
|
0 |
0 |
if (git_repository_config__weakptr(&config, repo) < 0) |
2447
|
0 |
0 |
if (error == GIT_PASSTHROUGH) |
2449
|
0 |
0 |
else if (!error) |
2452
|
0 |
0 |
if (!error) |
2456
|
0 |
0 |
if (!error) { |
2470
|
0 |
999 |
assert(repo); |
2476
|
0 |
2 |
assert(repo); |
2485
|
0 |
0 |
assert(repo); |
2487
|
0 |
0 |
if (repo->is_bare) |
2490
|
0 |
0 |
if ((error = git_repository_config__weakptr(&config, repo)) < 0) |
2493
|
0 |
0 |
if ((error = git_config_set_bool(config, "core.bare", true)) < 0) |
2496
|
0 |
0 |
if ((error = git_config__update_entry(config, "core.worktree", NULL, true, true)) < 0) |
2512
|
14 |
86 |
if ((error = git_repository_head(&head, repo)) < 0) |
2515
|
0 |
86 |
if ((error = git_reference_peel(&obj, head, GIT_OBJECT_TREE)) < 0) |
2534
|
7 |
0 |
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_ORIG_HEAD_FILE)) == 0 && |
|
7 |
0 |
if ((error = git_buf_joinpath(&file_path, repo->gitdir, GIT_ORIG_HEAD_FILE)) == 0 && |
2535
|
7 |
0 |
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) == 0 && |
2539
|
0 |
7 |
if (error < 0) |
2555
|
0 |
1 |
if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0) |
2558
|
0 |
1 |
if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) { |
2559
|
0 |
0 |
if (errno == ENOENT) |
2576
|
0 |
0 |
if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0) |
2598
|
0 |
0 |
assert(out && path && repo); /* as_path can be NULL */ |
|
0 |
0 |
assert(out && path && repo); /* as_path can be NULL */ |
|
0 |
0 |
assert(out && path && repo); /* as_path can be NULL */ |
2607
|
0 |
0 |
if (error < 0) |
2610
|
0 |
0 |
if (!as_path) |
2614
|
0 |
0 |
if (strlen(as_path) > 0) { |
2618
|
0 |
0 |
if (error < 0) |
2627
|
0 |
0 |
if (fd < 0) { |
2632
|
0 |
0 |
if ((error = git_futils_filesize(&len, fd)) < 0) |
2635
|
0 |
0 |
if (!git__is_sizet(len)) { |
2644
|
0 |
0 |
if (fd >= 0) |
2656
|
19 |
1 |
if (git_reference_type(old) == GIT_REFERENCE_SYMBOLIC) |
2664
|
0 |
1 |
git_reference__is_tag(new) || |
2670
|
0 |
20 |
if (git_buf_oom(out)) |
2683
|
1 |
0 |
assert(repo && id); |
|
0 |
1 |
assert(repo && id); |
2685
|
0 |
1 |
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) |
2688
|
0 |
1 |
if ((error = git_object_lookup(&object, repo, id, GIT_OBJECT_ANY)) < 0) |
2691
|
0 |
1 |
if ((error = git_object_peel(&peeled, object, GIT_OBJECT_COMMIT)) < 0) |
2694
|
1 |
0 |
if (new == NULL) |
2697
|
0 |
1 |
if ((error = checkout_message(&log_message, current, new)) < 0) |
2719
|
19 |
0 |
assert(repo && refname); |
|
0 |
19 |
assert(repo && refname); |
2721
|
0 |
19 |
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) |
2724
|
0 |
19 |
if ((error = checkout_message(&log_message, current, refname)) < 0) |
2728
|
0 |
19 |
if (error < 0 && error != GIT_ENOTFOUND) |
|
0 |
0 |
if (error < 0 && error != GIT_ENOTFOUND) |
2731
|
19 |
0 |
if (ref && current->type == GIT_REFERENCE_SYMBOLIC && git__strcmp(current->target.symbolic, ref->name) && |
|
18 |
1 |
if (ref && current->type == GIT_REFERENCE_SYMBOLIC && git__strcmp(current->target.symbolic, ref->name) && |
2732
|
0 |
17 |
git_reference_is_branch(ref) && git_branch_is_checked_out(ref)) { |
2739
|
19 |
0 |
if (!error) { |
2740
|
19 |
0 |
if (git_reference_is_branch(ref)) { |
2744
|
0 |
0 |
error = detach(repo, git_reference_target(ref), |
2745
|
0 |
0 |
git_reference_is_tag(ref) || git_reference_is_remote(ref) ? refname : NULL); |
2747
|
0 |
0 |
} else if (git_reference__is_branch(refname)) { |
2771
|
0 |
0 |
assert(repo && commitish); |
|
0 |
0 |
assert(repo && commitish); |
2783
|
0 |
0 |
assert(repo); |
2785
|
0 |
0 |
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) |
2788
|
0 |
0 |
if ((error = git_repository_head(&old_head, repo)) < 0) |
2791
|
0 |
0 |
if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJECT_COMMIT)) < 0) |
2794
|
0 |
0 |
if ((error = checkout_message(&log_message, current, git_oid_tostr_s(git_object_id(object)))) < 0) |
2818
|
0 |
37 |
assert(repo); |
2820
|
0 |
37 |
if (git_buf_puts(&repo_path, repo->gitdir) < 0) |
2823
|
1 |
36 |
if (git_path_contains_file(&repo_path, GIT_REBASE_MERGE_INTERACTIVE_FILE)) |
2825
|
3 |
33 |
else if (git_path_contains_dir(&repo_path, GIT_REBASE_MERGE_DIR)) |
2827
|
1 |
32 |
else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_REBASING_FILE)) |
2829
|
1 |
31 |
else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_APPLYING_FILE)) |
2831
|
1 |
30 |
else if (git_path_contains_dir(&repo_path, GIT_REBASE_APPLY_DIR)) |
2833
|
4 |
26 |
else if (git_path_contains_file(&repo_path, GIT_MERGE_HEAD_FILE)) |
2835
|
2 |
24 |
else if (git_path_contains_file(&repo_path, GIT_REVERT_HEAD_FILE)) { |
2837
|
0 |
2 |
if (git_path_contains_file(&repo_path, GIT_SEQUENCER_TODO_FILE)) { |
2840
|
3 |
21 |
} else if (git_path_contains_file(&repo_path, GIT_CHERRYPICK_HEAD_FILE)) { |
2842
|
0 |
3 |
if (git_path_contains_file(&repo_path, GIT_SEQUENCER_TODO_FILE)) { |
2845
|
1 |
20 |
} else if (git_path_contains_file(&repo_path, GIT_BISECT_LOG_FILE)) |
2859
|
193 |
0 |
for (error = 0, i = 0; !error && i < files_len; ++i) { |
|
173 |
20 |
for (error = 0, i = 0; !error && i < files_len; ++i) { |
2862
|
0 |
173 |
if (git_buf_joinpath(&buf, repo->gitdir, files[i]) < 0) |
2867
|
25 |
148 |
if (git_path_isfile(path)) { |
2869
|
6 |
142 |
} else if (git_path_isdir(path)) { |
2895
|
0 |
19 |
assert(repo); |
2906
|
0 |
0 |
if ((error = git_buf_joinpath(&path, repo->gitdir, "shallow")) < 0) |
2912
|
0 |
0 |
if (error == GIT_ENOTFOUND) { |
2917
|
0 |
0 |
if (error < 0) |
2925
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE( |
2949
|
0 |
0 |
if (name) { |
2951
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(tmp_name); |
2954
|
0 |
0 |
if (email) { |
2956
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(tmp_email); |
2972
|
0 |
0 |
assert(repo); |
2974
|
0 |
0 |
if ((error = git_strmap_new(&repo->submodule_cache))) |
2984
|
0 |
44 |
assert(repo); |
2985
|
44 |
0 |
if (repo->submodule_cache == NULL) { |
2988
|
0 |
0 |
git_strmap_foreach_value(repo->submodule_cache, sm, { |