git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH/RFD 3/6] rev-list: list all heads with --all

From
Duy Nguyen <pclouds@gmail.com>
Date
Feb 27, 2016, 02:15 UTC
Message-ID
<CACsJy8CrYYjiyeKZuHW=erJ-JZyaWdJKCAzO=zLs2HwSb5ifKA@mail.gmail.com>
In-Reply-To
<61d93b0aba1d4cb7348066db0b48f1ce2d5b35c5.1456504190.git.git@drmicha.warpmail.net>

On Fri, Feb 26, 2016 at 11:39 PM, Michael J Gruber <git@drmicha.warpmail.net> wrote:

Show 27 quoted lines
> HEAD is a worktree specific sysmref, so that a repository with multiple
> worktrees can have multiple HEADs, or HEADs in a worktree different from
> the current worktree.
>
> So far, "rev-parse --all" adds only the HEAD from the current worktree
> to the list of refs (besides branches etc.). So, a detached HEAD from a
> different checkout would be missed unless a shared ref (or current HEAD)
> points to it (or descents from it). As a consequence, "git prune" can
> prune detached HEADs from worktrees and leave the repo in an
> inconsistent state.
>
> Make "rev-parse --all" add the HEADs from all worktrees. This results in
> a non-worktree-specific ref list and solves the pruning problem.
>
> Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
> ---
>
> Notes:
>     This patch solves the pruning problem with worktrees, but I feel quite
>     uneasy about substituting the ref solving at the very heart of refs.c. So
>     please consider this a mere poc and a request for discussion/input
>     about how to do this the right way.
>
>     In essence, I feel the worktree interface still has to evolve a bit: I'd
>     rather for_each_worktree than loop myself, and if many call sites need to
>     be aware of multiple heads or worktrees than get_worktrees() should be
>     part of our init stuff, not here. [I may be out of sync of newer progress.]

How about adding for_each_head_ref_submodule() and make handle_revision_pseudo_opt() use it with a new option, .e.g --all-work-trees?

I looked over head_ref and head_ref_submodule call sites. I think we're ok. Most of them only concern about "our head". for-each-ref may need some improvement though.

-- 
Duy
Previous: Michael J GruberNext: Michael J Gruber
Message 7 of 11 in “Detached HEADs in new worktrees considered harmful”
  1. 0/6 Detached HEADs in new worktrees considered harmfulMichael J Gruber, Feb 26, 2016
  2. 1/6 Documentation/git-worktree: spell --detach correctlyMichael J Gruber, Feb 26, 2016
  3. Junio C HamanoFeb 26, 2016
  4. 2/6 t6014: test prune with detached HEADs in separate worktreesMichael J Gruber, Feb 26, 2016
  5. Junio C HamanoFeb 26, 2016
  6. 3/6 rev-list: list all heads with --allMichael J Gruber, Feb 26, 2016
  7. Duy NguyenFeb 27, 2016
  8. 4/6 WIP: mess only with mark_reachableMichael J Gruber, Feb 26, 2016
  9. 5/6 WIP: fix unborn branch caseMichael J Gruber, Feb 26, 2016
  10. 6/6 revisions: list all worktree HEADs with --allMichael J Gruber, Feb 26, 2016
  11. Junio C HamanoFeb 26, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.