| line |
true |
false |
branch |
|
21
|
0 |
12 |
if (git_buf_sets(&buf, dir) < 0) |
|
25
|
10 |
0 |
&& git_path_contains_file(&buf, "gitdir") |
|
26
|
10 |
2 |
&& git_path_contains_file(&buf, "HEAD"); |
|
|
10 |
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
|
71 |
0 |
assert(base && file); |
|
|
0 |
71 |
assert(base && file); |
|
78
|
0 |
71 |
if (git_buf_joinpath(&path, base, file) < 0) |
|
80
|
58 |
13 |
if (git_futils_readbuffer(&buf, path.ptr) < 0) |
|
86
|
13 |
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 |
4 |
if (!is_worktree_dir(dir)) { |
|
134
|
0 |
4 |
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) { |
|
140
|
4 |
0 |
(wt->commondir_path = git_worktree__read_link(dir, "commondir")) == NULL || |
|
141
|
4 |
0 |
(wt->gitlink_path = git_worktree__read_link(dir, "gitdir")) == NULL || |
|
148
|
0 |
4 |
if ((error = git_path_prettify_dir(&gitdir, dir, NULL)) < 0) |
|
152
|
0 |
4 |
if ((error = git_worktree_is_locked(NULL, wt)) < 0) |
|
160
|
1 |
4 |
if (error) |
|
173
|
5 |
0 |
assert(repo && name); |
|
|
0 |
5 |
assert(repo && name); |
|
177
|
0 |
5 |
if ((error = git_buf_printf(&path, "%s/worktrees/%s", repo->commondir, name)) < 0) |
|
180
|
1 |
4 |
if ((error = (open_worktree_dir(out, git_repository_workdir(repo), path.ptr, name))) < 0) |
|
186
|
1 |
4 |
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
|
20 |
4 |
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, |
|
294
|
0 |
2 |
GIT_ERROR_CHECK_VERSION( |
|
297
|
0 |
2 |
if (opts) |
|
300
|
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); |
|
304
|
0 |
2 |
if (wtopts.ref) { |
|
305
|
0 |
0 |
if (!git_reference_is_branch(wtopts.ref)) { |
|
311
|
0 |
0 |
if (git_branch_is_checked_out(wtopts.ref)) { |
|
319
|
0 |
2 |
if ((err = git_buf_joinpath(&gitdir, repo->commondir, "worktrees")) < 0) |
|
321
|
1 |
1 |
if (!git_path_exists(gitdir.ptr)) |
|
322
|
0 |
1 |
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0) |
|
324
|
0 |
2 |
if ((err = git_buf_joinpath(&gitdir, gitdir.ptr, name)) < 0) |
|
326
|
0 |
2 |
if ((err = git_futils_mkdir(gitdir.ptr, 0755, GIT_MKDIR_EXCL)) < 0) |
|
328
|
0 |
2 |
if ((err = git_path_prettify_dir(&gitdir, gitdir.ptr, NULL)) < 0) |
|
332
|
0 |
2 |
if ((err = git_futils_mkdir(worktree, 0755, GIT_MKDIR_EXCL)) < 0) |
|
334
|
0 |
2 |
if ((err = git_path_prettify_dir(&wddir, worktree, NULL)) < 0) |
|
337
|
0 |
2 |
if (wtopts.lock) { |
|
340
|
0 |
0 |
if ((err = git_buf_joinpath(&buf, gitdir.ptr, "locked")) < 0) |
|
343
|
0 |
0 |
if ((fd = p_creat(buf.ptr, 0644)) < 0) { |
|
353
|
0 |
2 |
if ((err = git_buf_printf(&buf, "gitdir: %s\n", gitdir.ptr)) < 0) |
|
355
|
0 |
2 |
if ((err = write_wtfile(wddir.ptr, ".git", &buf)) < 0) |
|
359
|
2 |
0 |
if ((err = git_path_prettify_dir(&buf, repo->commondir, NULL) < 0) |
|
360
|
2 |
0 |
|| (err = git_buf_putc(&buf, '\n')) < 0 |
|
361
|
2 |
0 |
|| (err = write_wtfile(gitdir.ptr, "commondir", &buf)) < 0) |
|
363
|
2 |
0 |
if ((err = git_buf_joinpath(&buf, wddir.ptr, ".git")) < 0 |
|
364
|
2 |
0 |
|| (err = git_buf_putc(&buf, '\n')) < 0 |
|
365
|
2 |
0 |
|| (err = write_wtfile(gitdir.ptr, "gitdir", &buf)) < 0) |
|
369
|
0 |
2 |
if (wtopts.ref) { |
|
370
|
0 |
0 |
if ((err = git_reference_dup(&ref, wtopts.ref)) < 0) |
|
373
|
0 |
2 |
if ((err = git_repository_head(&head, repo)) < 0) |
|
375
|
0 |
2 |
if ((err = git_commit_lookup(&commit, repo, &head->target.oid)) < 0) |
|
377
|
0 |
2 |
if ((err = git_branch_create(&ref, repo, name, commit, false)) < 0) |
|
382
|
0 |
2 |
if ((err = git_repository_create_head(gitdir.ptr, git_reference_name(ref))) < 0) |
|
384
|
0 |
2 |
if ((err = git_repository_open(&wt, wddir.ptr)) < 0) |
|
389
|
0 |
2 |
if ((err = git_checkout_head(wt, &coopts)) < 0) |
|
393
|
0 |
2 |
if ((err = git_worktree_lookup(out, repo, name)) < 0) |
|
413
|
0 |
3 |
assert(wt); |
|
415
|
0 |
3 |
if ((error = git_worktree_is_locked(NULL, wt)) < 0) |
|
417
|
1 |
2 |
if (error) { |
|
422
|
0 |
2 |
if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0) |
|
425
|
2 |
0 |
if (reason) |
|
428
|
0 |
2 |
if ((error = git_futils_writebuffer(&buf, path.ptr, O_CREAT|O_EXCL|O_WRONLY, 0644)) < 0) |
|
444
|
0 |
1 |
assert(wt); |
|
446
|
0 |
1 |
if ((error = git_worktree_is_locked(NULL, wt)) < 0) |
|
448
|
0 |
1 |
if (!error) |
|
451
|
0 |
1 |
if (git_buf_joinpath(&path, wt->gitdir_path, "locked") < 0) |
|
454
|
0 |
1 |
if (p_unlink(path.ptr) != 0) { |
|
471
|
0 |
14 |
assert(wt); |
|
473
|
6 |
8 |
if (reason) |
|
476
|
0 |
14 |
if ((error = git_buf_joinpath(&path, wt->gitdir_path, "locked")) < 0) |
|
479
|
4 |
10 |
if (locked && reason && |
|
|
2 |
2 |
if (locked && reason && |
|
|
0 |
2 |
if (locked && reason && |
|
492
|
0 |
2 |
assert(wt); |
|
498
|
0 |
2 |
assert(wt); |
|
506
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE(opts, version, |
|
524
|
0 |
6 |
GIT_ERROR_CHECK_VERSION( |
|
528
|
6 |
0 |
if (opts) |
|
531
|
3 |
3 |
if ((popts.flags & GIT_WORKTREE_PRUNE_LOCKED) == 0) { |
|
535
|
0 |
3 |
if ((error = git_worktree_is_locked(&reason, wt)) < 0) |
|
538
|
1 |
2 |
if (error) { |
|
539
|
0 |
1 |
if (!reason.size) |
|
564
|
0 |
2 |
GIT_ERROR_CHECK_VERSION( |
|
568
|
2 |
0 |
if (opts) |
|
571
|
0 |
2 |
if (!git_worktree_is_prunable(wt, &popts)) { |
|
577
|
0 |
2 |
if ((err = git_buf_printf(&path, "%s/worktrees/%s", wt->commondir_path, wt->name)) < 0) |
|
579
|
0 |
2 |
if (!git_path_exists(path.ptr)) |
|
585
|
0 |
2 |
if ((err = git_futils_rmdir_r(path.ptr, NULL, GIT_RMDIR_REMOVE_FILES)) < 0) |
|
596
|
0 |
2 |
if ((wtpath = git_path_dirname(wt->gitlink_path)) == NULL) |
|
599
|
0 |
2 |
if (!git_path_exists(path.ptr)) |
|
605
|
0 |
2 |
if ((err = git_futils_rmdir_r(path.ptr, NULL, GIT_RMDIR_REMOVE_FILES)) < 0) |