| line |
true |
false |
branch |
|
91
|
2 |
61 |
if (odb) { |
|
96
|
35 |
28 |
if ((odb = git__swap(repo->_odb, odb)) != NULL) { |
|
104
|
0 |
61 |
if (refdb) { |
|
109
|
52 |
9 |
if ((refdb = git__swap(repo->_refdb, refdb)) != NULL) { |
|
117
|
0 |
61 |
if (config) { |
|
122
|
61 |
0 |
if ((config = git__swap(repo->_config, config)) != NULL) { |
|
132
|
1 |
62 |
if (index) { |
|
137
|
17 |
46 |
if ((index = git__swap(repo->_index, index)) != NULL) { |
|
145
|
0 |
61 |
assert(repo); |
|
163
|
18 |
61 |
if (repo == NULL) |
|
173
|
0 |
61 |
for (i = 0; i < repo->reserved_names.size; i++) |
|
174
|
0 |
0 |
git_buf_dispose(git_array_get(repo->reserved_names, i)); |
|
202
|
5 |
65 |
if (git_path_contains_file(repository_path, GIT_COMMONDIR_FILE)) { |
|
205
|
5 |
0 |
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 || |
|
|
0 |
5 |
if ((error = git_buf_joinpath(&common_link, repository_path->ptr, GIT_COMMONDIR_FILE)) < 0 || |
|
210
|
0 |
5 |
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 |
65 |
if ((error = git_buf_set(common_path, repository_path->ptr, repository_path->size)) < 0) |
|
225
|
60 |
10 |
if (git_buf_rfind(common_path, '/') != (ssize_t)common_path->size - 1) |
|
226
|
0 |
60 |
if ((error = git_buf_putc(common_path, '/')) < 0) |
|
230
|
6 |
64 |
if (git_path_contains_file(repository_path, GIT_HEAD_FILE) == false) |
|
233
|
0 |
64 |
if (git_path_contains_dir(common_path, GIT_OBJECTS_DIR) == false) |
|
235
|
0 |
64 |
if (git_path_contains_dir(common_path, GIT_REFS_DIR) == false) |
|
251
|
0 |
63 |
if (!repo->reserved_names.ptr) |
|
260
|
0 |
0 |
if (repo) |
|
272
|
0 |
0 |
GIT_ERROR_CHECK_ALLOC(repo); |
|
285
|
0 |
63 |
if (err < 0 && err != GIT_ENOTFOUND) |
|
|
0 |
0 |
if (err < 0 && err != GIT_ENOTFOUND) |
|
289
|
63 |
0 |
if (err != GIT_ENOTFOUND) |
|
290
|
8 |
55 |
repo->is_bare = is_bare && !repo->is_worktree; |
|
|
8 |
0 |
repo->is_bare = is_bare && !repo->is_worktree; |
|
304
|
8 |
55 |
if (repo->is_bare) |
|
307
|
0 |
55 |
if ((error = git_config__lookup_entry( |
|
311
|
5 |
50 |
if (repo->is_worktree) { |
|
313
|
0 |
5 |
if (!gitlink) { |
|
328
|
0 |
50 |
else if (ce && ce->value) { |
|
|
0 |
0 |
else if (ce && ce->value) { |
|
329
|
0 |
0 |
if ((error = git_path_prettify_dir( |
|
335
|
50 |
0 |
else if (parent_path && git_path_isdir(parent_path->ptr)) |
|
|
50 |
0 |
else if (parent_path && git_path_isdir(parent_path->ptr)) |
|
347
|
0 |
55 |
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
|
5 |
0 |
assert(path_out && file_path); |
|
|
0 |
5 |
assert(path_out && file_path); |
|
419
|
0 |
5 |
if (git_futils_readbuffer(&file, file_path) < 0) |
|
433
|
5 |
0 |
else if ((error = git_path_dirname_r(path_out, file_path)) >= 0) { |
|
435
|
10 |
0 |
while (*gitlink && git__isspace(*gitlink)) gitlink++; |
|
|
5 |
5 |
while (*gitlink && git__isspace(*gitlink)) gitlink++; |
|
467
|
0 |
64 |
if (error < 0) |
|
477
|
0 |
64 |
if (flags & (GIT_REPOSITORY_OPEN_BARE | GIT_REPOSITORY_OPEN_NO_DOTGIT)) { |
|
486
|
96 |
0 |
if (!(flags & GIT_REPOSITORY_OPEN_NO_DOTGIT)) { |
|
487
|
65 |
31 |
if (!in_dot_git) { |
|
488
|
0 |
65 |
if ((error = git_buf_joinpath(&path, path.ptr, DOT_GIT)) < 0) |
|
494
|
65 |
31 |
if (p_stat(path.ptr, &st) == 0) { |
|
496
|
64 |
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
|
60 |
5 |
if (S_ISDIR(st.st_mode)) { |
|
503
|
0 |
60 |
if ((error = is_valid_repository_path(&is_valid, &path, &common_link)) < 0) |
|
506
|
59 |
1 |
if (is_valid) { |
|
507
|
59 |
0 |
if ((error = git_path_to_dir(&path)) < 0 || |
|
|
59 |
0 |
if ((error = git_path_to_dir(&path)) < 0 || |
|
511
|
58 |
1 |
if (gitlink_path) |
|
512
|
0 |
58 |
if ((error = git_buf_attach(gitlink_path, git_worktree__read_link(path.ptr, GIT_GITDIR_FILE), 0)) < 0) |
|
514
|
58 |
1 |
if (commondir_path) |
|
519
|
5 |
0 |
} else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) { |
|
|
5 |
0 |
} else if (S_ISREG(st.st_mode) && git__suffixcmp(path.ptr, "/" DOT_GIT) == 0) { |
|
520
|
5 |
0 |
if ((error = read_gitfile(&repo_link, path.ptr)) < 0 || |
|
|
5 |
0 |
if ((error = read_gitfile(&repo_link, path.ptr)) < 0 || |
|
524
|
5 |
0 |
if (is_valid) { |
|
527
|
5 |
0 |
if (gitlink_path) |
|
528
|
0 |
5 |
if ((error = git_buf_put(gitlink_path, path.ptr, path.size)) < 0) |
|
530
|
5 |
0 |
if (commondir_path) |
|
540
|
0 |
32 |
if ((error = git_path_dirname_r(&path, path.ptr)) < 0) |
|
545
|
32 |
0 |
if (min_iterations && (--min_iterations == 0)) |
|
|
1 |
31 |
if (min_iterations && (--min_iterations == 0)) |
|
549
|
1 |
31 |
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
|
63 |
1 |
if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) { |
|
|
63 |
0 |
if (workdir_path && !(flags & GIT_REPOSITORY_OPEN_BARE)) { |
|
555
|
0 |
63 |
if (!git_buf_len(gitdir_path)) |
|
557
|
63 |
0 |
else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 || |
|
|
63 |
0 |
else if ((error = git_path_dirname_r(workdir_path, path.ptr)) < 0 || |
|
564
|
0 |
64 |
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
|
63 |
0 |
if (repo->commondir && repo->gitdir |
|
|
63 |
0 |
if (repo->commondir && repo->gitdir |
|
790
|
58 |
5 |
&& !strcmp(repo->commondir, repo->gitdir)) { |
|
795
|
0 |
5 |
if ((error = git_buf_joinpath(&gitdir_link, repo->gitdir, "gitdir")) < 0) |
|
820
|
0 |
63 |
if (flags & GIT_REPOSITORY_OPEN_FROM_ENV) |
|
823
|
63 |
0 |
if (repo_ptr) |
|
829
|
63 |
0 |
if (error < 0 || !repo_ptr) |
|
|
63 |
0 |
if (error < 0 || !repo_ptr) |
|
833
|
0 |
63 |
GIT_ERROR_CHECK_ALLOC(repo); |
|
836
|
0 |
63 |
GIT_ERROR_CHECK_ALLOC(repo->gitdir); |
|
838
|
5 |
58 |
if (gitlink.size) { |
|
840
|
0 |
5 |
GIT_ERROR_CHECK_ALLOC(repo->gitlink); |
|
842
|
63 |
0 |
if (commondir.size) { |
|
844
|
0 |
63 |
GIT_ERROR_CHECK_ALLOC(repo->commondir); |
|
847
|
0 |
63 |
if ((error = repo_is_worktree(&is_worktree, repo)) < 0) |
|
857
|
0 |
63 |
if (error < 0 && error != GIT_ENOTFOUND) |
|
|
0 |
0 |
if (error < 0 && error != GIT_ENOTFOUND) |
|
860
|
63 |
0 |
if (config && (error = check_repositoryformatversion(&version, config)) < 0) |
|
|
0 |
63 |
if (config && (error = check_repositoryformatversion(&version, config)) < 0) |
|
863
|
0 |
63 |
if ((error = check_extensions(config, version) < 0)) |
|
866
|
0 |
63 |
if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) |
|
870
|
63 |
0 |
if (config && |
|
|
63 |
0 |
if (config && |
|
883
|
0 |
63 |
if (error < 0) |
|
885
|
63 |
0 |
else if (repo_ptr) |
|
904
|
2 |
0 |
assert(repo_out && wt); |
|
|
0 |
2 |
assert(repo_out && wt); |
|
909
|
2 |
0 |
if (len <= 4 || strcasecmp(wt->gitlink_path + len - 4, ".git")) { |
|
|
0 |
2 |
if (len <= 4 || strcasecmp(wt->gitlink_path + len - 4, ".git")) { |
|
914
|
0 |
2 |
if ((err = git_buf_set(&path, wt->gitlink_path, len - 4)) < 0) |
|
917
|
0 |
2 |
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 |
63 |
assert(out); |
|
970
|
0 |
63 |
if ((error = git_config_new(&cfg)) < 0) |
|
973
|
63 |
0 |
if (repo) { |
|
974
|
63 |
0 |
if ((error = git_repository_item_path(&config_path, repo, GIT_REPOSITORY_ITEM_CONFIG)) == 0) |
|
977
|
0 |
63 |
if (error && error != GIT_ENOTFOUND) |
|
|
0 |
0 |
if (error && error != GIT_ENOTFOUND) |
|
983
|
63 |
0 |
if (global_config_path != NULL && |
|
|
0 |
63 |
if (global_config_path != NULL && |
|
985
|
0 |
0 |
cfg, global_config_path, GIT_CONFIG_LEVEL_GLOBAL, repo, 0)) < 0 && |
|
989
|
0 |
63 |
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 |
63 |
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 |
63 |
if (programdata_path != NULL && |
|
|
0 |
0 |
if (programdata_path != NULL && |
|
1003
|
0 |
0 |
cfg, programdata_path, GIT_CONFIG_LEVEL_PROGRAMDATA, repo, 0)) < 0 && |
|
1021
|
63 |
189 |
return git_buf_len(buf) > 0 ? git_buf_cstr(buf) : NULL; |
|
1028
|
63 |
929 |
if (repo->_config == NULL) { |
|
1041
|
63 |
0 |
if (git_buf_len(&global_buf) == 0) |
|
1050
|
63 |
0 |
if (!error) { |
|
1054
|
0 |
63 |
if (config != NULL) { |
|
1072
|
0 |
15 |
if (git_repository_config__weakptr(out, repo) < 0) |
|
1084
|
0 |
502 |
if ((error = git_repository_config__weakptr(&weak, repo)) < 0) |
|
1092
|
0 |
0 |
assert(repo && config); |
|
|
0 |
0 |
assert(repo && config); |
|
1101
|
2358 |
0 |
assert(repo && out); |
|
|
0 |
2358 |
assert(repo && out); |
|
1103
|
33 |
2325 |
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 |
164 |
if (git_repository_odb__weakptr(out, repo) < 0) |
|
1144
|
2 |
0 |
assert(repo && odb); |
|
|
0 |
2 |
assert(repo && odb); |
|
1153
|
1321 |
0 |
assert(out && repo); |
|
|
0 |
1321 |
assert(out && repo); |
|
1155
|
54 |
1267 |
if (repo->_refdb == NULL) { |
|
1159
|
54 |
0 |
if (!error) { |
|
1163
|
0 |
54 |
if (refdb != NULL) { |
|
1176
|
0 |
83 |
if (git_repository_refdb__weakptr(out, repo) < 0) |
|
1185
|
0 |
0 |
assert(repo && refdb); |
|
|
0 |
0 |
assert(repo && refdb); |
|
1194
|
3116 |
0 |
assert(out && repo); |
|
|
0 |
3116 |
assert(out && repo); |
|
1196
|
16 |
3100 |
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 |
63 |
if (error == GIT_ENOTFOUND) |
|
1368
|
0 |
63 |
if (error < 0) |
|
1371
|
0 |
63 |
if (GIT_REPO_MAX_VERSION < *version) { |
|
1385
|
0 |
0 |
if (!strcmp(entry->name, "extensions.noop")) |
|
1394
|
68 |
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) { |
|
2185
|
0 |
0 |
assert(repo && name); |
|
|
0 |
0 |
assert(repo && name); |
|
2187
|
0 |
0 |
if ((error = git_repository_head_for_worktree(&ref, repo, name)) < 0) |
|
2202
|
0 |
265 |
assert(head_out); |
|
2204
|
0 |
265 |
if ((error = git_reference_lookup(&head, repo, GIT_HEAD_FILE)) < 0) |
|
2207
|
21 |
244 |
if (git_reference_type(head) == GIT_REFERENCE_DIRECT) { |
|
2215
|
229 |
15 |
return error == GIT_ENOTFOUND ? GIT_EUNBORNBRANCH : error; |
|
2225
|
1 |
0 |
assert(out && repo && name); |
|
|
1 |
0 |
assert(out && repo && name); |
|
|
0 |
1 |
assert(out && repo && name); |
|
2229
|
1 |
0 |
if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 || |
|
|
1 |
0 |
if ((error = git_worktree_lookup(&worktree, repo, name)) < 0 || |
|
2230
|
1 |
0 |
(error = git_repository_open_from_worktree(&worktree_repo, worktree)) < 0 || |
|
2234
|
1 |
0 |
if (git_reference_type(head) != GIT_REFERENCE_DIRECT) { |
|
2235
|
0 |
1 |
if ((error = git_reference_lookup_resolved(out, worktree_repo, git_reference_symbolic_target(head), -1)) < 0) |
|
2266
|
0 |
18 |
if ((error = git_worktree_list(&worktrees, repo)) < 0) |
|
2269
|
0 |
18 |
for (i = 0; i < worktrees.count; i++) { |
|
2275
|
0 |
0 |
if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) || |
|
|
0 |
0 |
if ((error = git_worktree_lookup(&worktree, repo, worktrees.strings[i]) < 0) || |
|
2277
|
0 |
0 |
if (error != GIT_ENOTFOUND) |
|
2283
|
0 |
0 |
if ((error = cb(worktree_repo, payload)) != 0) |
|
2302
|
0 |
0 |
if (error == GIT_EUNBORNBRANCH) { |
|
2307
|
0 |
0 |
if (error < 0) |
|
2324
|
0 |
2 |
if (error == GIT_PASSTHROUGH) |
|
2327
|
2 |
0 |
if (!error) |
|
2338
|
0 |
2 |
if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) |
|
2341
|
2 |
0 |
if (git_reference_type(head) == GIT_REFERENCE_SYMBOLIC) |
|
2370
|
0 |
1468 |
if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST) |
|
|
0 |
0 |
if (!parent && fallback != GIT_REPOSITORY_ITEM__LAST) |
|
2379
|
0 |
1468 |
if (parent == NULL) { |
|
2384
|
0 |
1468 |
if (git_buf_sets(out, parent) < 0) |
|
2387
|
1468 |
0 |
if (items[item].name) { |
|
2388
|
0 |
1468 |
if (git_buf_joinpath(out, parent, items[item].name) < 0) |
|
2392
|
1405 |
63 |
if (items[item].directory) { |
|
2393
|
0 |
1405 |
if (git_path_to_dir(out) < 0) |
|
2402
|
0 |
30 |
assert(repo); |
|
2408
|
0 |
8017 |
assert(repo); |
|
2410
|
0 |
8017 |
if (repo->is_bare) |
|
2418
|
0 |
1471 |
assert(repo); |
|
2428
|
2 |
0 |
assert(repo && workdir); |
|
|
0 |
2 |
assert(repo && workdir); |
|
2430
|
0 |
2 |
if (git_path_prettify_dir(&path, workdir, NULL) < 0) |
|
2433
|
2 |
0 |
if (repo->workdir && strcmp(repo->workdir, path.ptr) == 0) |
|
|
2 |
0 |
if (repo->workdir && strcmp(repo->workdir, path.ptr) == 0) |
|
2436
|
0 |
0 |
if (update_gitlink) { |
|
2439
|
0 |
0 |
if (git_repository_config__weakptr(&config, repo) < 0) |
|
2445
|
0 |
0 |
if (error == GIT_PASSTHROUGH) |
|
2447
|
0 |
0 |
else if (!error) |
|
2450
|
0 |
0 |
if (!error) |
|
2454
|
0 |
0 |
if (!error) { |
|
2468
|
0 |
1083 |
assert(repo); |
|
2474
|
0 |
2 |
assert(repo); |
|
2483
|
0 |
0 |
assert(repo); |
|
2485
|
0 |
0 |
if (repo->is_bare) |
|
2488
|
0 |
0 |
if ((error = git_repository_config__weakptr(&config, repo)) < 0) |
|
2491
|
0 |
0 |
if ((error = git_config_set_bool(config, "core.bare", true)) < 0) |
|
2494
|
0 |
0 |
if ((error = git_config__update_entry(config, "core.worktree", NULL, true, true)) < 0) |
|
2510
|
14 |
86 |
if ((error = git_repository_head(&head, repo)) < 0) |
|
2513
|
0 |
86 |
if ((error = git_reference_peel(&obj, head, GIT_OBJECT_TREE)) < 0) |
|
2532
|
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 && |
|
2533
|
7 |
0 |
(error = git_filebuf_open(&file, file_path.ptr, GIT_FILEBUF_CREATE_LEADING_DIRS, GIT_MERGE_FILE_MODE)) == 0 && |
|
2537
|
0 |
7 |
if (error < 0) |
|
2553
|
0 |
1 |
if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0) |
|
2556
|
0 |
1 |
if ((error = p_stat(git_buf_cstr(&path), &st)) < 0) { |
|
2557
|
0 |
0 |
if (errno == ENOENT) |
|
2574
|
0 |
0 |
if (git_buf_joinpath(&path, repo->gitdir, GIT_MERGE_MSG_FILE) < 0) |
|
2596
|
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 */ |
|
2605
|
0 |
0 |
if (error < 0) |
|
2608
|
0 |
0 |
if (!as_path) |
|
2612
|
0 |
0 |
if (strlen(as_path) > 0) { |
|
2616
|
0 |
0 |
if (error < 0) |
|
2625
|
0 |
0 |
if (fd < 0) { |
|
2630
|
0 |
0 |
if ((error = git_futils_filesize(&len, fd)) < 0) |
|
2633
|
0 |
0 |
if (!git__is_sizet(len)) { |
|
2642
|
0 |
0 |
if (fd >= 0) |
|
2654
|
19 |
1 |
if (git_reference_type(old) == GIT_REFERENCE_SYMBOLIC) |
|
2662
|
0 |
1 |
git_reference__is_tag(new) || |
|
2668
|
0 |
20 |
if (git_buf_oom(out)) |
|
2681
|
1 |
0 |
assert(repo && id); |
|
|
0 |
1 |
assert(repo && id); |
|
2683
|
0 |
1 |
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) |
|
2686
|
0 |
1 |
if ((error = git_object_lookup(&object, repo, id, GIT_OBJECT_ANY)) < 0) |
|
2689
|
0 |
1 |
if ((error = git_object_peel(&peeled, object, GIT_OBJECT_COMMIT)) < 0) |
|
2692
|
1 |
0 |
if (new == NULL) |
|
2695
|
0 |
1 |
if ((error = checkout_message(&log_message, current, new)) < 0) |
|
2717
|
19 |
0 |
assert(repo && refname); |
|
|
0 |
19 |
assert(repo && refname); |
|
2719
|
0 |
19 |
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) |
|
2722
|
0 |
19 |
if ((error = checkout_message(&log_message, current, refname)) < 0) |
|
2726
|
0 |
19 |
if (error < 0 && error != GIT_ENOTFOUND) |
|
|
0 |
0 |
if (error < 0 && error != GIT_ENOTFOUND) |
|
2729
|
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) && |
|
2730
|
0 |
17 |
git_reference_is_branch(ref) && git_branch_is_checked_out(ref)) { |
|
2737
|
19 |
0 |
if (!error) { |
|
2738
|
19 |
0 |
if (git_reference_is_branch(ref)) { |
|
2742
|
0 |
0 |
error = detach(repo, git_reference_target(ref), |
|
2743
|
0 |
0 |
git_reference_is_tag(ref) || git_reference_is_remote(ref) ? refname : NULL); |
|
2745
|
0 |
0 |
} else if (git_reference__is_branch(refname)) { |
|
2769
|
0 |
0 |
assert(repo && commitish); |
|
|
0 |
0 |
assert(repo && commitish); |
|
2781
|
0 |
0 |
assert(repo); |
|
2783
|
0 |
0 |
if ((error = git_reference_lookup(¤t, repo, GIT_HEAD_FILE)) < 0) |
|
2786
|
0 |
0 |
if ((error = git_repository_head(&old_head, repo)) < 0) |
|
2789
|
0 |
0 |
if ((error = git_object_lookup(&object, repo, git_reference_target(old_head), GIT_OBJECT_COMMIT)) < 0) |
|
2792
|
0 |
0 |
if ((error = checkout_message(&log_message, current, git_oid_tostr_s(git_object_id(object)))) < 0) |
|
2816
|
0 |
37 |
assert(repo); |
|
2818
|
0 |
37 |
if (git_buf_puts(&repo_path, repo->gitdir) < 0) |
|
2821
|
1 |
36 |
if (git_path_contains_file(&repo_path, GIT_REBASE_MERGE_INTERACTIVE_FILE)) |
|
2823
|
3 |
33 |
else if (git_path_contains_dir(&repo_path, GIT_REBASE_MERGE_DIR)) |
|
2825
|
1 |
32 |
else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_REBASING_FILE)) |
|
2827
|
1 |
31 |
else if (git_path_contains_file(&repo_path, GIT_REBASE_APPLY_APPLYING_FILE)) |
|
2829
|
1 |
30 |
else if (git_path_contains_dir(&repo_path, GIT_REBASE_APPLY_DIR)) |
|
2831
|
4 |
26 |
else if (git_path_contains_file(&repo_path, GIT_MERGE_HEAD_FILE)) |
|
2833
|
2 |
24 |
else if (git_path_contains_file(&repo_path, GIT_REVERT_HEAD_FILE)) { |
|
2835
|
0 |
2 |
if (git_path_contains_file(&repo_path, GIT_SEQUENCER_TODO_FILE)) { |
|
2838
|
3 |
21 |
} else if (git_path_contains_file(&repo_path, GIT_CHERRYPICK_HEAD_FILE)) { |
|
2840
|
0 |
3 |
if (git_path_contains_file(&repo_path, GIT_SEQUENCER_TODO_FILE)) { |
|
2843
|
1 |
20 |
} else if (git_path_contains_file(&repo_path, GIT_BISECT_LOG_FILE)) |
|
2857
|
193 |
0 |
for (error = 0, i = 0; !error && i < files_len; ++i) { |
|
|
173 |
20 |
for (error = 0, i = 0; !error && i < files_len; ++i) { |
|
2860
|
0 |
173 |
if (git_buf_joinpath(&buf, repo->gitdir, files[i]) < 0) |
|
2865
|
25 |
148 |
if (git_path_isfile(path)) { |
|
2867
|
6 |
142 |
} else if (git_path_isdir(path)) { |
|
2893
|
0 |
19 |
assert(repo); |
|
2904
|
0 |
0 |
if ((error = git_buf_joinpath(&path, repo->gitdir, "shallow")) < 0) |
|
2910
|
0 |
0 |
if (error == GIT_ENOTFOUND) { |
|
2915
|
0 |
0 |
if (error < 0) |
|
2923
|
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 |
61 |
assert(repo); |
|
2985
|
61 |
0 |
if (repo->submodule_cache == NULL) { |
|
2988
|
0 |
0 |
git_strmap_foreach_value(repo->submodule_cache, sm, { |