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

Re: [PATCH 3/3] branch: add --unset-upstream option

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 10, 2012, 18:02 UTC
Message-ID
<7v629vijf2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1341939181-8962-4-git-send-email-cmn@elego.de>
Carlos Martín Nieto <cmn@elego.de> writes:
Show 13 quoted lines
> We have ways of setting the upstream information, but if we want to
> unset it, we need to resort to modifying the configuration manually.
>
> Teach branch an --unset-upstream option that unsets this information.
>
> ---
>
> create_branch() uses install_branch_config() which may also set
> branch.foo.rebase, so this version might leave some configuration
> laying around.
>
> I wonder if deleting the whole branch.foo section would be better. Can
> we be sure that nothing else shows up there?

"branch.foo.$unknown" may not be related to upstream at all, so that will not fly. Besides, we already have unknown=description, no?

If you are removing the branch "foo", it would make sense, though.
Show 6 quoted lines
> +	} else if (unset_upstream) {
> +		struct branch *branch = branch_get(argv[0]);
> +		struct strbuf buf = STRBUF_INIT;
> +
> +		strbuf_addf(&buf, "branch.%s.remote", branch->name);
> +		git_config_set_multivar(buf.buf, NULL, NULL, 1);

This part makes sense, as "--set-upstream" is about setting the value of branch.foo.remote to 'origin' or whatever.

> +		strbuf_reset(&buf);
> +		strbuf_addf(&buf, "branch.%s.merge", branch->name);
> +		git_config_set_multivar(buf.buf, NULL, NULL, 1);

This also makes sense because "branch.foo.merge" names a ref in the context of the remote. A branch may have integrated with the "dev" branch at "origin" repository; when it is modified to slurp changes from "central" repository from now on, there is nothing that says that the branch "dev" at this different remote corresponds to the "dev" branch at the original "origin" repository (such a branch may not even exist at the new "central" repository). There is no point leaving the "branch.foo.merge" configuration behind when you unset the upstream information.

> +		strbuf_release(&buf);
>  	} else if (argc > 0 && argc <= 2) {
>  		struct branch *branch = branch_get(argv[0]);
>  		const char *old_upstream = NULL;
Previous: Carlos Martín NietoNext: Carlos Martín Nieto
Message 26 of 29 in “A better way of handling upstream information in git-branch”
  1. 0/3 A better way of handling upstream information in git-branchCarlos Martín Nieto, Jul 10, 2012
  2. 1/3 branch: introduce --set-upstream-toCarlos Martín Nieto, Jul 10, 2012
  3. Matthieu MoyJul 10, 2012
  4. Junio C HamanoJul 10, 2012
  5. Jonathan NiederJul 10, 2012
  6. Junio C HamanoJul 10, 2012
  7. Jonathan NiederJul 10, 2012
  8. Junio C HamanoJul 10, 2012
  9. Jonathan NiederJul 10, 2012
  10. Junio C HamanoJul 10, 2012
  11. Jonathan NiederJul 10, 2012
  12. Junio C HamanoJul 11, 2012
  13. Jonathan NiederJul 11, 2012
  14. Miles BaderJul 12, 2012
  15. Junio C HamanoJul 12, 2012
  16. 2/3 branch: suggest how to undo a --set-upstream when given one branchCarlos Martín Nieto, Jul 10, 2012
  17. Matthieu MoyJul 10, 2012
  18. Carlos Martín NietoJul 11, 2012
  19. Junio C HamanoJul 10, 2012
  20. Carlos Martín NietoJul 11, 2012
  21. Jonathan NiederJul 10, 2012
  22. Junio C HamanoJul 10, 2012
  23. Jonathan NiederJul 10, 2012
  24. Carlos Martín NietoJul 11, 2012
  25. 3/3 branch: add --unset-upstream optionCarlos Martín Nieto, Jul 10, 2012
  26. Junio C HamanoJul 10, 2012
  27. Carlos Martín NietoJul 11, 2012
  28. Junio C HamanoJul 11, 2012
  29. Carlos Martín NietoJul 12, 2012

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.