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

Re: [PATCH v2 1/2] refs: Add for_each_worktree_ref for iterating over all worktree HEADs

From
Manish Goregaokar <manishearth@gmail.com>
Date
May 20, 2017, 17:33 UTC
Message-ID
<CACpkpxmGzz0hUsypX5ORX7FLB3rh_xbyPOKz4SUt-zrjSjCq_g@mail.gmail.com>
In-Reply-To
<xmqqy3trstup.fsf@gitster.mtv.corp.google.com>
Yes, you are right (on both counts).

One thing which I think hasn't been covered yet is the rebase ORIG_HEAD. I'll see if that's still a problem on `pu` and make a patch for it if so.

(I recall `git prune` during a rebase messing up repo state, though it's really my fault for trying that in the first place. Would be nice if it worked, though) -Manish Goregaokar

On Sat, May 20, 2017 at 3:30 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 32 quoted lines
> manishearth@gmail.com writes:
>
>> +int for_each_worktree_ref(each_ref_fn fn, void *cb_data)
>> +{
>> +     int i, flag, retval = 0;
>> +     struct object_id oid;
>> +     struct worktree **worktrees = get_worktrees(GWT_SORT_LINKED);
>> +     struct commit* commit;
>> +     for (i = 0; worktrees[i]; i++) {
>> +             if ((commit = lookup_commit_reference(worktrees[i]->head_sha1))) {
>> +                     oid = commit->object.oid;
>> +                     if (!read_ref_full("HEAD", RESOLVE_REF_READING, oid.hash, &flag)) {
>> +                             if ((retval = fn("HEAD", &oid, flag, cb_data)))
>> +                                     return retval;
>> +                     }
>> +             }
>> +     }
>> +     return retval;
>> +}
>
> I would have expected for-each-worktree-ref to iterate over all the
> refs in a given worktree, but that is not what this does.  This
> instead iterates over worktrees and shows only their HEAD ref, no
> other refs.  This helper is somewhat misnamed.
>
> By the way, doesn't nd/prune-in-worktree topic that has been cooking
> in 'pu' supersede this change?  It not just protects the commit at
> the tip of HEAD in each worktree, it also makes sure the ones in
> HEAD's reflog are not prematurely pruned.
>
> Thanks.
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 17 of 21 in “refs: Add for_each_worktree_ref for iterating over all worktree HEADs”
  1. 1/2 refs: Add for_each_worktree_ref for iterating over all worktree HEADsManish Goregaokar, May 17, 2017
  2. Manish GoregaokarMay 17, 2017
  3. Jonathan NiederMay 17, 2017
  4. 1/2 refs: Add for_each_worktree_ref for iterating over all worktree HEADsmanish.earth@gmail.com, May 17, 2017
  5. 2/2 reachable: Add HEADs of all worktrees to reachability analysismanish.earth@gmail.com, May 17, 2017
  6. Manish GoregaokarMay 17, 2017
  7. Manish GoregaokarMay 17, 2017
  8. Brandon WilliamsMay 18, 2017
  9. Manish GoregaokarMay 18, 2017
  10. 1/2 refs: Add for_each_worktree_ref for iterating over all worktree HEADsmanishearth@gmail.com, May 18, 2017
  11. 2/2 reachable: Add HEADs of all worktrees to reachability analysismanishearth@gmail.com, May 18, 2017
  12. Manish GoregaokarMay 18, 2017
  13. Simon RuderichMay 18, 2017
  14. Samuel LijinMay 18, 2017
  15. Brandon WilliamsMay 18, 2017
  16. Junio C HamanoMay 20, 2017
  17. Manish GoregaokarMay 20, 2017
  18. Junio C HamanoMay 20, 2017
  19. Duy NguyenMay 22, 2017
  20. Manish GoregaokarMay 22, 2017
  21. Duy NguyenMay 25, 2017

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.