line |
true |
false |
branch |
21
|
0 |
11 |
if (git_buf_sets(&buf, dir) < 0) |
25
|
9 |
0 |
&& git_path_contains_file(&buf, "gitdir") |
26
|
9 |
2 |
&& git_path_contains_file(&buf, "HEAD"); |
|
9 |
0 |
&& git_path_contains_file(&buf, "HEAD"); |
40
|
20 |
0 |
assert(wts && repo); |
|
0 |
20 |
assert(wts && repo); |
45
|
0 |
20 |
if ((error = git_buf_printf(&path, "%s/worktrees/", repo->commondir)) < 0) |
47
|
2 |
18 |
if (!git_path_exists(path.ptr) || git_path_is_empty_dir(path.ptr)) |
|
2 |
0 |
if (!git_path_exists(path.ptr) || git_path_is_empty_dir(path.ptr)) |
49
|
0 |
2 |
if ((error = git_path_dirload(&worktrees, path.ptr, path.size, 0x0)) < 0) |
54
|
4 |
2 |
git_vector_foreach(&worktrees, i, worktree) { |
58
|
0 |
4 |
if (!is_worktree_dir(path.ptr)) { |
76
|
50 |
0 |
assert(base && file); |
|
0 |
50 |
assert(base && file); |
78
|
0 |
50 |
if (git_buf_joinpath(&path, base, file) < 0) |
80
|
40 |
10 |
if (git_futils_readbuffer(&buf, path.ptr) < 0) |
86
|
10 |
0 |
if (!git_path_is_relative(buf.ptr)) |
89
|
0 |
0 |
if (git_buf_sets(&path, base) < 0) |
91
|
0 |
0 |
if (git_path_apply_relative(&path, buf.ptr) < 0) |
109
|
6 |
0 |
assert(base && file && buf); |
|
6 |
0 |
assert(base && file && buf); |
|
0 |
6 |
assert(base && file && buf); |
111
|
0 |
6 |
if ((err = git_buf_joinpath(&path, base, file)) < 0) |
114
|
0 |
6 |
if ((err = git_futils_writebuffer(buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0) |
129
|
1 |
3 |
if (!is_worktree_dir(dir)) { |
134
|
0 |
3 |
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) { |
140
|
3 |
0 |
(wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL || |
141
|
3 |
0 |
(wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL || |
148
|
0 |
3 |
if ((error = git_path_prettify_dir(&gitdir, dir, NULL)) < 0) |
152
|
0 |
3 |
if ((error = git_worktree_is_locked(NULL, wt)) < 0) |
160
|
1 |
3 |
if (error) |
173
|
4 |
0 |
assert(repo && name); |
|
0 |
4 |
assert(repo && name); |
177
|
0 |
4 |
if ((error = git_buf_printf(&path, "%s/worktrees/%s", repo->commondir, name)) < 0) |
180
|
1 |
3 |
if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0) |
186
|
1 |
3 |
if (error) |
199
|
0 |
0 |
if (!git_repository_is_worktree(repo)) { |
208
|
0 |
0 |
if ((error = git_path_prettify_dir(&parent, "..", commondir)) < 0) |
214
|
0 |
0 |
if ((error = open_worktree_dir(out, parent.ptr, gitdir, name)) < 0) |
226
|
2 |
3 |
if (!wt) |
240
|
0 |
3 |
assert(wt); |
242
|
1 |
2 |
if (!is_worktree_dir(wt->gitdir_path)) { |
249
|
2 |
0 |
if (wt->parent_path && !git_path_exists(wt->parent_path)) { |
|
0 |
2 |
if (wt->parent_path && !git_path_exists(wt->parent_path)) { |
256
|
0 |
2 |
if (!git_path_exists(wt->commondir_path)) { |
269
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version, |
292
|
0 |
2 |
GIT_ERROR_CHECK_VERSION( |
295
|
0 |
2 |
if (opts) |
298
|
2 |
0 |
assert(out && repo && name && worktree); |
|
2 |
0 |
assert(out && repo && name && worktree); |
|
2 |
0 |
assert(out && repo && name && worktree); |
|
0 |
2 |
assert(out && repo && name && worktree); |
302
|
0 |
2 |
if (wtopts.ref) { |
303
|
0 |
0 |
if (!git_reference_is_branch(wtopts.ref)) { |
309
|
0 |
0 |
if (git_branch_is_checked_out(wtopts.ref)) { |
317
|
0 |
2 |
if ((err = git_buf_joinpath(&gitdir, repo->commondir, "worktrees")) < 0) |
319
|
1 |
1 |
if (!git_path_exists(gitdir.ptr)) |
320
|
0 |
1 |
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0) |
322
|
0 |
2 |
if ((err = git_buf_joinpath(&gitdir, gitdir.ptr, name)) < 0) |
324
|
0 |
2 |
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0) |
326
|
0 |
2 |
if ((err = git_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0) |
330
|
0 |
2 |
if ((err = git_futils_mkdir(worktree, 0755, GIT_MKDIR_EXCL)) < 0) |
332
|
0 |
2 |
if ((err = git_path_prettify_dir(&wddir, worktree, NULL)) < 0) |
335
|
0 |
2 |
if (wtopts.lock) { |
338
|
0 |
0 |
if ((err = git_buf_joinpath(&buf, gitdir.ptr, "locked")) < 0) |
341
|
0 |
0 |
if ((fd = p_creat(buf.ptr, 0644)) < 0) { |
351
|
0 |
2 |
if ((err = git_buf_printf(&buf, "gitdir: %s\n", gitdir.ptr)) < 0) |
353
|
0 |
2 |
if ((err = write_wtfile(wddir.ptr, ".git", &buf)) < 0) |
357
|
2 |
0 |
if ((err = git_path_prettify_dir(&buf, repo->commondir, NULL) < 0) |
358
|
2 |
0 |
|| (err = git_buf_putc(&buf, '\n')) < 0 |
359
|
2 |
0 |
|| (err = write_wtfile(gitdir.ptr, "commondir", &buf)) < 0) |
361
|
2 |
0 |
if ((err = git_buf_joinpath(&buf, wddir.ptr, ".git")) < 0 |
362
|
2 |
0 |
|| (err = git_buf_putc(&buf, '\n')) < 0 |
363
|
2 |
0 |
|| (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0) |
367
|
0 |
2 |
if (wtopts.ref) { |
368
|
0 |
0 |
if ((err = git_reference_dup(&ref, wtopts.ref)) < 0) |
371
|
0 |
2 |
if ((err = git_repository_head(&head, repo)) < 0) |
373
|
0 |
2 |
if ((err = git_commit_lookup(&commit, repo, &head->target.oid)) < 0) |
375
|
0 |
2 |
if ((err = git_branch_create(&ref, repo, name, commit, false)) < 0) |
380
|
0 |
2 |
if ((err = git_repository_create_head(gitdir.ptr, git_reference_name(ref))) < 0) |
382
|
0 |
2 |
if ((err = git_repository_open(&wt, wddir.ptr)) < 0) |
387
|
0 |
2 |
if ((err = git_checkout_head(wt, &coopts)) < 0) |
391
|
0 |
2 |
if ((err = git_worktree_lookup(out, repo, name)) < 0) |
411
|
0 |
3 |
assert(wt); |
413
|
0 |
3 |
if ((error = git_worktree_is_locked(NULL, wt)) < 0) |
415
|
1 |
2 |
if (error) { |
420
|
0 |
2 |
if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0) |
423
|
2 |
0 |
if (reason) |
426
|
0 |
2 |
if ((error = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0) |
442
|
0 |
1 |
assert(wt); |
444
|
0 |
1 |
if ((error = git_worktree_is_locked(NULL, wt)) < 0) |
446
|
0 |
1 |
if (!error) |
449
|
0 |
1 |
if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0) |
452
|
0 |
1 |
if (p_unlink(path.ptr) != 0) { |
469
|
0 |
13 |
assert(wt); |
471
|
6 |
7 |
if (reason) |
474
|
0 |
13 |
if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0) |
477
|
4 |
9 |
if (locked && reason && |
|
2 |
2 |
if (locked && reason && |
|
0 |
2 |
if (locked && reason && |
490
|
0 |
2 |
assert(wt); |
496
|
0 |
2 |
assert(wt); |
504
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version, |
520
|
0 |
6 |
GIT_ERROR_CHECK_VERSION( |
524
|
6 |
0 |
if (opts) |
527
|
3 |
3 |
if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) { |
531
|
0 |
3 |
if ((error = git_worktree_is_locked(&reason, wt)) < 0) |
534
|
1 |
2 |
if (error) { |
535
|
0 |
1 |
if (!reason.size) |
560
|
0 |
2 |
GIT_ERROR_CHECK_VERSION( |
564
|
2 |
0 |
if (opts) |
567
|
0 |
2 |
if (!git_worktree_is_prunable(wt, &popts)) { |
573
|
0 |
2 |
if ((err = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name)) < 0) |
575
|
0 |
2 |
if (!git_path_exists(path.ptr)) |
581
|
0 |
2 |
if ((err = git_futils_rmdir_r(path.ptr, NULL, GIT_RMDIR_REMOVE_FILES)) < 0) |
592
|
0 |
2 |
if ((wtpath = git_path_dirname(wt->gitlink_path)) == NULL) |
595
|
0 |
2 |
if (!git_path_exists(path.ptr)) |
601
|
0 |
2 |
if ((err = git_futils_rmdir_r(path.ptr, NULL, GIT_RMDIR_REMOVE_FILES)) < 0) |