Re: [PATCH 3/3] branch: add --unset-upstream option
On Wed, 2012-07-11 at 09:53 -0700, Junio C Hamano wrote: > Carlos Martín Nieto writes: > > > I've added a bit of code to also remove branch.foo.rebase, which > > I'd also consider to be part of the upstream information. > > If "git branch -t" or "git branch --set-upstream" took another > option "--integrate-with=[rebase|merge]" to set the variable, I > would agree that removing branch.$name.rebase would be the right > thing to do, but because it is not, I do not know if it is sensible > to remove it upon --unset-upstream. I'll drop it then. cmn -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] branch: add --unset-upstream option
Carlos Martín Nieto writes: > I've added a bit of code to also remove branch.foo.rebase, which > I'd also consider to be part of the upstream information. If "git branch -t" or "git branch --set-upstream" took another option "--integrate-with=[rebase|merge]" to set the variable, I would agree that removing branch.$name.rebase would be the right thing to do, but because it is not, I do not know if it is sensible to remove it upon --unset-upstream. I actually thought about commenting on that exact variable in my review, saying that the patch was correct that it didn't touch it. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] branch: add --unset-upstream option
On Tue, 2012-07-10 at 11:02 -0700, Junio C Hamano wrote: > 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 > > 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? Ah yes, that exists. I've added a bit of code to also remove branch.foo.rebase, which I'd also consider to be part of the upstream information. cmn -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/3] branch: add --unset-upstream option
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 > 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. > + } 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; -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/3] branch: add --unset-upstream option
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? Documentation/git-branch.txt |5 + builtin/branch.c | 17 ++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt index 0f33fc7..c7cab08 100644 --- a/Documentation/git-branch.txt +++ b/Documentation/git-branch.txt @@ -14,6 +14,7 @@ SYNOPSIS [(--merged | --no-merged | --contains) []] [...] 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] [] 'git branch' (--set-upstream-to= | -u ) [] +'git branch' --unset-upstream [] 'git branch' (-m | -M) [] 'git branch' (-d | -D) [-r] ... 'git branch' --edit-description [] @@ -180,6 +181,10 @@ start-point is either a local or remote-tracking branch. considered 's upstream branch. If no branch is specified it defaults to the current branch. +--unset-upstream:: + Remove the upstream information for . If no branch + is specified it defaults to the current branch. + --edit-description:: Open an editor and edit the text to explain what the branch is for, to be used by various other commands (e.g. `request-pull`). diff --git a/builtin/branch.c b/builtin/branch.c index 5551227..1d1bf8e 100644 --- a/builtin/branch.c +++ b/builtin/branch.c @@ -712,7 +712,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) int delete = 0, rename = 0, force_create = 0, list = 0; int verbose = 0, abbrev = -1, detached = 0; int reflog = 0, edit_description = 0; - int quiet = 0; + int quiet = 0, unset_upstream = 0; const char *new_upstream = NULL; enum branch_track track; int kinds = REF_LOCAL_BRANCH; @@ -728,6 +728,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix) OPT_SET_INT( 0, "set-upstream", &track, "change upstream info", BRANCH_TRACK_OVERRIDE), OPT_STRING('u', "set-upstream-to", &new_upstream, "upstream", "change the upstream info"), + OPT_BOOLEAN(0, "unset-upstream", &unset_upstream, "Unset the upstream info"), OPT__COLOR(&branch_use_color, "use colored output"), OPT_SET_INT('r', "remotes", &kinds, "act on remote-tracking branches", REF_REMOTE_BRANCH), @@ -796,10 +797,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix) argc = parse_options(argc, argv, prefix, options, builtin_branch_usage, 0); - if (!delete && !rename && !edit_description && !new_upstream && argc == 0) + if (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0) list = 1; - if (!!delete + !!rename + !!force_create + !!list + !!new_upstream > 1) + if (!!delete + !!rename + !!force_create + !!list + !!new_upstream + !!unset_upstream > 1) usage_with_options(builtin_branch_usage, options); if (abbrev == -1) @@ -863,6 +864,16 @@ int cmd_branch(int argc, const char **argv, const char *prefix) /* create_branch takes care of setting up the tracking info and making sure new_upstream is correct */ create_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE); + } 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); + strbuf_reset(&buf); + strbuf_addf(&buf, "branch.%s.merge", branch->name); + git_config_set_multivar(buf.buf, NULL, NULL, 1); + strbuf_release(&buf); } else if (argc > 0 && argc <= 2) { struct branch *branch = branch_get(argv[0]); const char *old_upstream = NULL; -- 1.7.10.2.1.g8c77c3c -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html