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

Re: [PATCH v3 1/2] merge: new autosetupmerge option 'simple' for matching branches

From
Tao Klerks <tao@klerks.biz>
Date
Mar 2, 2022, 09:35 UTC
Message-ID
<CAPMMpoi9gQscSQ5Xn1xTb6WaCXu+qR67DJh9nCbqN0jp7-b_5A@mail.gmail.com>
In-Reply-To
<220228.86k0df5key.gmgdl@evledraar.gmail.com>

On Mon, Feb 28, 2022 at 11:56 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 6 quoted lines
>
> On Mon, Feb 28 2022, Tao Klerks via GitGitGadget wrote:
>
> I think squashing 2/2 inot this would make this much easier to follow,
> i.e. to have tests along with the new feature.
>
OK! Doing.
Show 15 quoted lines
> > +     /*
> > +      * This check does not apply to the BRANCH_TRACK_INHERIT
> > +      * option; you can inherit one or more tracking entries
> > +      * and the tracking.matches counter is not incremented.
> > +      */
> >       if (tracking.matches > 1)
> >               die(_("not tracking: ambiguous information for ref %s"),
> >                   orig_ref);
>
> This function is the only user of find_tracked_branch(). For e.g. "git
> checkout we emit";
>
>     fatal: builtin/checkout.c:1246: 'foo' matched multiple (4) remote tracking branches
>
> Perhaps we can do something similar here

I'm not sure what you're pointing to specifically - the fact that the checkout message provides a count? If so I guess I understand/agree, find_tracked_branch() could be enhanced to keep counting rather than exiting at the first sign of trouble, to support such a slightly-more-explicit message here.

I'm not convinced that this situation is common enough to warrant change: mapping multiple remotes to the same remote-tracking path seems like a strange setup - is this something we recommend or document anywhere? maybe to have 2 "remotes" that correspond to the same server over different protocols appear as one set of tracking branches?

On the other hand I am of course happy to make things better if we think this will do that!

> even with some advise()
> emit information about what other branches conflicted.

I believe the conflict is not about different "branches" exactly, but about *refspecs* that map to the tracking branch.

If I understand correctly this change would entail creating a new advice type (and documenting it), and figuring out what the advice should look like - something like "find and disambiguate your fetch refspecs to enable auto tracking setup! If you want to keep your ambiguous refspecs, set auto tracking setup to false!" - but nicer :)

Show 23 quoted lines
>
> > +     if (track == BRANCH_TRACK_SIMPLE) {
> > +             /*
> > +              * Only track if remote branch name matches.
> > +              * Reaching into items[0].string is safe because
> > +              * we know there is at least one and not more than
> > +              * one entry (because not BRANCH_TRACK_INHERIT).
> > +              */
> > +             const char *tracked_branch;
> > +             if (!skip_prefix(tracking.srcs->items[0].string,
> > +                              "refs/heads/", &tracked_branch) ||
> > +                 strcmp(tracked_branch, new_ref))
> > +                     return;
> > +     }
> > +
>
> I wondered when reading this if there isn't a way to merge this and the
> "branch_get" call made in "inherit_tracking" earlier in this function in
> the "track != BRANCH_TRACK_INHERIT" case.
>
> But maybe not, and that whole API entry point is a bit messy in needing
> to cover both the use-case of an existing branch & nonexisting
> (i.e. initial creation).

Hmm, I had a hard time understanding this comment. I *think* you were saying "why don't you use an existing API to get the full ref name of the new local branch, and compare that to the full name of the remote branch you already have, rather than messing with a "refs/heads/" prefix explicitly/redundantly"... Is that right?

Previous: Ævar Arnfjörð BjarmasonNext: Tao Klerks
Message 20 of 41 in “adding new branch.autosetupmerge option "simple"”
  1. 0/3 adding new branch.autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 24, 2022
  2. 1/3 merge: new autosetupmerge option 'simple' for matching branchesTao Klerks via GitGitGadget, Feb 24, 2022
  3. Junio C HamanoFeb 24, 2022
  4. 2/3 t3200: tests for new branch.autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 24, 2022
  5. 3/3 branch documentation: new autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 24, 2022
  6. Junio C HamanoFeb 24, 2022
  7. 0/2 adding new branch.autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 25, 2022
  8. 1/2 merge: new autosetupmerge option 'simple' for matching branchesTao Klerks via GitGitGadget, Feb 25, 2022
  9. Junio C HamanoFeb 25, 2022
  10. Tao KlerksFeb 27, 2022
  11. 2/2 t3200: tests for new branch.autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 25, 2022
  12. 0/2 adding new branch.autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 28, 2022
  13. 2/2 t3200: tests for new branch.autosetupmerge option "simple"Tao Klerks via GitGitGadget, Feb 28, 2022
  14. Ævar Arnfjörð BjarmasonFeb 28, 2022
  15. Eric SunshineMar 1, 2022
  16. Tao KlerksMar 1, 2022
  17. Tao KlerksMar 1, 2022
  18. 1/2 merge: new autosetupmerge option 'simple' for matching branchesTao Klerks via GitGitGadget, Feb 28, 2022
  19. Ævar Arnfjörð BjarmasonFeb 28, 2022
  20. Tao KlerksMar 2, 2022
  21. Tao KlerksMar 20, 2022
  22. merge: new autosetupmerge option 'simple' for matching branchesTao Klerks via GitGitGadget, Mar 21, 2022
  23. Josh SteadmonApr 18, 2022
  24. Tao KlerksApr 20, 2022
  25. Josh SteadmonApr 20, 2022
  26. Junio C HamanoApr 20, 2022
  27. Tao KlerksApr 20, 2022
  28. Junio C HamanoApr 21, 2022
  29. Tao KlerksApr 21, 2022
  30. Junio C HamanoApr 22, 2022
  31. Tao KlerksApr 22, 2022
  32. Tao KlerksApr 22, 2022
  33. Junio C HamanoApr 23, 2022
  34. Tao KlerksApr 24, 2022
  35. Tao KlerksApr 29, 2022
  36. 0/3 New options to support "simple" centralized workflowTao Klerks via GitGitGadget, Apr 29, 2022
  37. 1/3 branch: new autosetupmerge option 'simple' for matching branchesTao Klerks via GitGitGadget, Apr 29, 2022
  38. 2/3 push: default to single remote even when not named originTao Klerks via GitGitGadget, Apr 29, 2022
  39. 3/3 push: new config option "push.autoSetupRemote" supports "simple" pushTao Klerks via GitGitGadget, Apr 29, 2022
  40. Junio C HamanoApr 29, 2022
  41. Tao KlerksApr 30, 2022

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.