| 718 | } |
| 719 | |
| 720 | void repair_worktree_after_gitdir_move(struct worktree *wt, const char *old_path) |
| 721 | { |
| 722 | struct strbuf gitdir = STRBUF_INIT; |
| 723 | struct strbuf dotgit = STRBUF_INIT; |
| 724 | int is_relative_path; |
| 725 | char *path = NULL; |
| 726 | |
| 727 | if (is_main_worktree(wt)) |
| 728 | goto done; |
| 729 | |
| 730 | path = repo_common_path(the_repository, "worktrees/%s/gitdir", wt->id); |
| 731 | strbuf_realpath(&gitdir, path, 1); |
| 732 | |
| 733 | if (strbuf_read_file(&dotgit, gitdir.buf, 0) < 0) |
| 734 | goto done; |
| 735 | |
| 736 | strbuf_rtrim(&dotgit); |
| 737 | is_relative_path = ! is_absolute_path(dotgit.buf); |
| 738 | if (is_relative_path) { |
| 739 | strbuf_insertf(&dotgit, 0, "%s/worktrees/%s/", old_path, wt->id); |
| 740 | strbuf_realpath_forgiving(&dotgit, dotgit.buf, 0); |
| 741 | } |
| 742 | |
| 743 | if (!file_exists(dotgit.buf)) |
| 744 | goto done; |
| 745 | |
| 746 | write_worktree_linking_files(dotgit.buf, gitdir.buf, is_relative_path); |
| 747 | done: |
| 748 | strbuf_release(&gitdir); |
| 749 | strbuf_release(&dotgit); |
| 750 | free(path); |
| 751 | } |
| 752 | |
| 753 | void repair_worktrees_after_gitdir_move(const char *old_path) |
| 754 | { |
no test coverage detected