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

Re: [PATCH v2 1/2] branch: suggest <remote>/<branch> on upstream slip

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 25, 2026, 21:16 UTC
Message-ID
<xmqqfr2ae2wp.fsf@gitster.g>
In-Reply-To
<CAHwyqnXZ_eGUPOhq1hXs==uYuYbRBWw120fXRQa=apWKekxVAQ@mail.gmail.com>
Harald Nordgren <haraldnordgren@gmail.com> writes:
Show 22 quoted lines
>> Do we still need the _if_enabled() thing here?  Isn't the caller
>> gated with the same condition in this version?
>>
>> > +     strbuf_release(&remote_ref);
>> > +     exit(code);
>> > +}
>> > +
>> >  int cmd_branch(int argc,
>> >              const char **argv,
>> >              const char *prefix,
>> > @@ -957,6 +980,9 @@ int cmd_branch(int argc,
>> >               if (!refs_ref_exists(get_main_ref_store(the_repository), branch->refname)) {
>> >                       if (!argc || branch_checked_out(branch->refname))
>> >                               die(_("no commit on branch '%s' yet"), branch->name);
>> > +                     if (argc == 1 &&
>> > +                         advice_enabled(ADVICE_SET_UPSTREAM_FAILURE))
>> > +                             die_if_upstream_looks_like_remote(new_upstream, argv[0]);
>> >                       die(_("branch '%s' does not exist"), branch->name);
>> >               }
>
> I think we do, so it will give the advice and tell the user that it
> can be disabled in the standard format.

I was hoping that unconditional advise() should be sufficient, but the caller there needs to say if_enabled, even though it _knows_ that it is enabled, only to give the turn-off instructions.

I wonder if future readers would be confused just like I was, without a comment on the callsite of _if_enabled() added by this patch?

Thanks.
Previous: Harald NordgrenNext: Harald Nordgren via GitGitGadget
Message 16 of 26 in “branch/push: suggest intended form when remote/branch slip given”
  1. 0/2 branch/push: suggest intended form when remote/branch slip givenHarald Nordgren via GitGitGadget, Jun 12, 2026
  2. 1/2 branch: suggest <remote>/<branch> on upstream slipHarald Nordgren via GitGitGadget, Jun 12, 2026
  3. Junio C HamanoJun 22, 2026
  4. Junio C HamanoJun 22, 2026
  5. Ben KnobleJun 24, 2026
  6. 2/2 push: suggest <remote> <branch> for a slash slipHarald Nordgren via GitGitGadget, Jun 12, 2026
  7. Junio C HamanoJun 22, 2026
  8. Harald NordgrenJun 22, 2026
  9. Weijie YuanJun 22, 2026
  10. Junio C HamanoJun 22, 2026
  11. Harald NordgrenJun 23, 2026
  12. 0/2 branch/push: suggest intended form when remote/branch slip givenHarald Nordgren via GitGitGadget, Jun 24, 2026
  13. 1/2 branch: suggest <remote>/<branch> on upstream slipHarald Nordgren via GitGitGadget, Jun 24, 2026
  14. Junio C HamanoJun 24, 2026
  15. Harald NordgrenJun 25, 2026
  16. Junio C HamanoJun 25, 2026
  17. 2/2 push: suggest <remote> <branch> for a slash slipHarald Nordgren via GitGitGadget, Jun 24, 2026
  18. Junio C HamanoJun 24, 2026
  19. Junio C HamanoJun 25, 2026
  20. Harald NordgrenJun 25, 2026
  21. Junio C HamanoJun 25, 2026
  22. 0/2 branch/push: suggest intended form when remote/branch slip givenHarald Nordgren via GitGitGadget, Jun 27, 2026
  23. 1/2 branch: suggest <remote>/<branch> on upstream slipHarald Nordgren via GitGitGadget, Jun 27, 2026
  24. Junio C HamanoJun 28, 2026
  25. Harald NordgrenJun 28, 2026
  26. 2/2 push: suggest <remote> <branch> for a slash slipHarald Nordgren via GitGitGadget, Jun 27, 2026

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.