Merge branch 'nd/prune-in-worktree'
"git gc" and friends when multiple worktrees are used off of a single repository did not consider the index and per-worktree refs of other worktrees as the root for reachability traversal, making objects that are in use only in other worktrees to be subject to garbage collection. * nd/prune-in-worktree: refs.c: reindent get_submodule_ref_store() refs.c: remove fallback-to-main-store code get_submodule_ref_store() rev-list: expose and document --single-worktree revision.c: --reflog add HEAD reflog from all worktrees files-backend: make reflog iterator go through per-worktree reflog revision.c: --all adds HEAD from all worktrees refs: remove dead for_each_*_submodule() refs.c: move for_each_remote_ref_submodule() to submodule.c revision.c: use refs_for_each*() instead of for_each_*_submodule() refs: add refs_head_ref() refs: move submodule slash stripping code to get_submodule_ref_store refs.c: refactor get_submodule_ref_store(), share common free block revision.c: --indexed-objects add objects from all worktrees revision.c: refactor add_index_objects_to_pending() refs.c: use is_dir_sep() in resolve_gitlink_ref() revision.h: new flag in struct rev_info wrt. worktree-related refs
This commit is contained in:
22
worktree.c
22
worktree.c
@ -386,3 +386,25 @@ int submodule_uses_worktrees(const char *path)
|
||||
closedir(dir);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int other_head_refs(each_ref_fn fn, void *cb_data)
|
||||
{
|
||||
struct worktree **worktrees, **p;
|
||||
int ret = 0;
|
||||
|
||||
worktrees = get_worktrees(0);
|
||||
for (p = worktrees; *p; p++) {
|
||||
struct worktree *wt = *p;
|
||||
struct ref_store *refs;
|
||||
|
||||
if (wt->is_current)
|
||||
continue;
|
||||
|
||||
refs = get_worktree_ref_store(wt);
|
||||
ret = refs_head_ref(refs, fn, cb_data);
|
||||
if (ret)
|
||||
break;
|
||||
}
|
||||
free_worktrees(worktrees);
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user