diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2020-08-31 08:57:58 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-08-31 20:47:45 +0200 |
commit | b214ab5aa597e748c228e657d4eb7c18960e6a67 (patch) | |
tree | 3ddaf52516ed4595071c495d049c8ee5c6a192ea /worktree.h | |
parent | worktree: teach "repair" to fix worktree back-links to main worktree (diff) | |
download | git-b214ab5aa597e748c228e657d4eb7c18960e6a67.tar.xz git-b214ab5aa597e748c228e657d4eb7c18960e6a67.zip |
worktree: teach "repair" to fix outgoing links to worktrees
The .git/worktrees/<id>/gitdir file points at the location of a linked
worktree's .git file. Its content must be of the form
/path/to/worktree/.git (from which the location of the worktree itself
can be derived by stripping the "/.git" suffix). If the gitdir file is
deleted or becomes corrupted or outdated, then Git will be unable to
find the linked worktree. An easy way for the gitdir file to become
outdated is for the user to move the worktree manually (without using
"git worktree move"). Although it is possible to manually update the
gitdir file to reflect the new linked worktree location, doing so
requires a level of knowledge about worktree internals beyond what a
user should be expected to know offhand.
Therefore, teach "git worktree repair" how to repair broken or outdated
.git/worktrees/<id>/gitdir files automatically. (For this to work, the
command must either be invoked from within the worktree whose gitdir
file requires repair, or from within the main or any linked worktree by
providing the path of the broken worktree as an argument to "git
worktree repair".)
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.h')
-rw-r--r-- | worktree.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/worktree.h b/worktree.h index 4fcb01348c..ff7b62e434 100644 --- a/worktree.h +++ b/worktree.h @@ -101,6 +101,18 @@ typedef void (* worktree_repair_fn)(int iserr, const char *path, void repair_worktrees(worktree_repair_fn, void *cb_data); /* + * Repair administrative files corresponding to the worktree at the given path. + * The worktree's .git file pointing at the repository must be intact for the + * repair to succeed. Useful for re-associating an orphaned worktree with the + * repository if the worktree has been moved manually (without using "git + * worktree move"). For each repair made or error encountered while attempting + * a repair, the callback function, if non-NULL, is called with the path of the + * worktree and a description of the repair or error, along with the callback + * user-data. + */ +void repair_worktree_at_path(const char *, worktree_repair_fn, void *cb_data); + +/* * Free up the memory for worktree(s) */ void free_worktrees(struct worktree **); |