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

Re: [PATCH v2 1/3] branch: fix die_if_checked_out() when ignore_current_worktree

From
Rubén Justo <rjusto@gmail.com>
Date
Jan 22, 2023, 23:21 UTC
Message-ID
<d61a2393-64c8-da49-fe13-00bc4a52d5e3@gmail.com>
In-Reply-To
<xmqqk01eqr3m.fsf@gitster.g>
On 22-ene-2023 11:58:05, Junio C Hamano wrote:
Show 13 quoted lines
> Rubén Justo <rjusto@gmail.com> writes:
> 
> >> As the proposed log message explained, updating die_if_checked_out()
> >> with this patch would fix a bug---can we demonstrate the existing
> >> breakage and protect the fix from future breakages by adding a test
> >> or two?
> >
> > 2/3 and 3/3, I think makes more sense on its own commit.
> 
> Hmph, how so?  Especially once you split 1/3 into the preliminary
> refactoring and the real fix, the fix becomes fairly small and
> clear.  And the tests to protect the fix would go best in the same
> commit.

My intention is to protect rebase (2/3) and switch (3/3). If any of those tests break, even if die_if_checked_out() is no longer used by them, I try to make the original intent clear with that in there.

die_if_checked_out() was initially fine, the ignore_current_worktree was unfortunately introduced. I haven't checked, but other callers not affected by the change, i.e. ignore_current_worktree = 0, his tests should have protected them by the change.

You are right, in a future reroll, split 1/3 could leave a fairly small commit, maybe not a bad thing. Definitely this need a reroll, because of the style issues, but I will wait some time for other reviewers.

Show 32 quoted lines
> >> The above comment is about find_shared_symref() which iterates over
> >> worktrees and find the one that uses the named symref.  Now the
> >> comment appears to apply to is_shared_symref() which does not
> >> iterate but takes one specific worktree instance.  Do their
> >> differences necessitate some updates to the comment?
> >
> > I think the comment still makes sense as is for the new function, both the
> > description and the recommendation.  I will review it again.
> 
> OK.  Thanks.
> 
> >> > +int is_shared_symref(const struct worktree *wt, const char *symref,
> >> > +		     const char *target)
> >> > +{
> >> 
> >> What this function does sound more like "is target in use in this
> >> particular worktree by being pointed at by the symref?"  IOW, I do
> >> not see where "shared" comes into its name from.
> >> 
> >> "HEAD" that is tentatively detached while bisecting or rebasing the
> >> "target" branch is still considered to point at the "target", so
> >> perhaps symref_points_at_target() or something?
> >
> > I tried to maintain the terms as much as possible.  I'll think about the name
> > you suggest.
> 
> When you did not change a thing in such a way that it does not
> change the relationship between that thing and other things, it
> makes perfect sense to keep the same term to refer to the thing.
> Otherwise, once the thing starts playing different roles in the
> world, there may be a better word to refer to the updated and
> improved thing.

I tried to maintain the relationship and the role, too. Just introduce the helper, as Phillip suggested and I think it is a good idea.

Thank you.
Previous: Junio C HamanoNext: Phillip Wood
Message 11 of 40 in “worktree: teach find_shared_symref to ignore current worktree”
  1. worktree: teach find_shared_symref to ignore current worktreeRubén Justo, Jan 17, 2023
  2. Junio C HamanoJan 17, 2023
  3. Rubén JustoJan 18, 2023
  4. Phillip WoodJan 19, 2023
  5. Rubén JustoJan 19, 2023
  6. 0/3 fix die_if_checked_out() when ignore_current_worktreeRubén Justo, Jan 22, 2023
  7. 1/3 branch: fix die_if_checked_out() when ignore_current_worktreeRubén Justo, Jan 22, 2023
  8. Junio C HamanoJan 22, 2023
  9. Rubén JustoJan 22, 2023
  10. Junio C HamanoJan 22, 2023
  11. Rubén JustoJan 22, 2023
  12. Phillip WoodJan 24, 2023
  13. Rubén JustoJan 26, 2023
  14. 2/3 rebase: refuse to switch to a branch already checked out elsewhere (test)Rubén Justo, Jan 22, 2023
  15. 3/3 switch: reject if the branch is already checked out elsewhere (test)Rubén Justo, Jan 22, 2023
  16. 0/4 fix die_if_checked_out() when ignore_current_worktreeRubén Justo, Feb 4, 2023
  17. 1/4 worktree: introduce is_shared_symref()Rubén Justo, Feb 4, 2023
  18. Phillip WoodFeb 7, 2023
  19. 2/4 branch: fix die_if_checked_out() when ignore_current_worktreeRubén Justo, Feb 4, 2023
  20. Ævar Arnfjörð BjarmasonFeb 6, 2023
  21. Rubén JustoFeb 6, 2023
  22. Phillip WoodFeb 7, 2023
  23. Ævar Arnfjörð BjarmasonFeb 7, 2023
  24. 3/4 rebase: refuse to switch to a branch already checked out elsewhere (test)Rubén Justo, Feb 4, 2023
  25. Ævar Arnfjörð BjarmasonFeb 6, 2023
  26. Rubén JustoFeb 6, 2023
  27. Phillip WoodFeb 7, 2023
  28. Rubén JustoFeb 8, 2023
  29. Junio C HamanoFeb 8, 2023
  30. Rubén JustoFeb 8, 2023
  31. 4/4 switch: reject if the branch is already checked out elsewhere (test)Rubén Justo, Feb 4, 2023
  32. Eric SunshineFeb 15, 2023
  33. Rubén JustoFeb 15, 2023
  34. 0/4 fix die_if_checked_out() when ignore_current_worktreeRubén Justo, Feb 25, 2023
  35. 1/4 worktree: introduce is_shared_symref()Rubén Justo, Feb 25, 2023
  36. 2/4 branch: fix die_if_checked_out() when ignore_current_worktreeRubén Justo, Feb 25, 2023
  37. 3/4 rebase: refuse to switch to a branch already checked out elsewhere (test)Rubén Justo, Feb 25, 2023
  38. 4/4 switch: reject if the branch is already checked out elsewhere (test)Rubén Justo, Feb 25, 2023
  39. Junio C HamanoFeb 25, 2023
  40. Rubén JustoFeb 27, 2023

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.