Carlos Martín Nieto <> writes:

> 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
>, so this version might leave some configuration
> laying around.
> I wonder if deleting the whole section would be better. Can
> we be sure that nothing else shows up there?

"$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.

> +     } 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 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 "" 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 "" 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;
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to