revision.c: --all adds HEAD from all worktrees
Unless single_worktree is set, --all now adds HEAD from all worktrees.
Since reachable.c code does not use setup_revisions(), we need to call
other_head_refs_submodule() explicitly there to have the same effect on
"git prune", so that we won't accidentally delete objects needed by some
other HEADs.
A new FIXME is added because we would need something like
int refs_other_head_refs(struct ref_store *, each_ref_fn, cb_data);
in addition to other_head_refs() to handle it, which might require
int get_submodule_worktrees(const char *submodule, int flags);
It could be a separate topic to reduce the scope of this one.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
419221c106
commit
d0c39a49cc
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