{"thread":{"id":"31390","subject":"[PATCHv2 0/3] Improve branch UI for setting upstream information","startedAt":"2012-08-30T17:23:10Z","lastAt":"2012-09-01T15:13:10Z","messageCount":12,"participants":["Carlos Martín Nieto","Junio C Hamano","Ralf Thielow"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"198112","messageId":"1346347393-8425-1-git-send-email-cmn@elego.de","threadId":"31390","inReplyTo":null,"subject":"[PATCHv2 0/3] Improve branch UI for setting upstream information","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-08-30T17:23:10Z","receivedAt":"2012-08-30T17:23:10Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"Hi all,\n\nAs a result of making --unset-upstream fail if the given branch\ndoesn't exist, I discovered a copy-paste error in on the the tests in\nthe patch after it, so I'm resending the whole thing.\n\nThe changes from the last reroll are the tightening of the situations\nwhere git will show an error message (not it's just if the branch is\nnew and exists as remote-tracking) which I already sent as a reply in\nthe other thread; and making --unset-upstream error out on bad input,\nwhich I already mentioned above.\n\n   cmn\n\nCarlos Martín Nieto (3):\n  branch: introduce --set-upstream-to\n  branch: add --unset-upstream option\n  branch: deprecate --set-upstream and show help if we detect possible\n    mistaken use\n\n Documentation/git-branch.txt | 14 ++++++++-\n builtin/branch.c             | 60 +++++++++++++++++++++++++++++++++++++--\n t/t3200-branch.sh            | 67 ++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 137 insertions(+), 4 deletions(-)\n\n-- \n1.7.12.3.g0dd8ef6\n"},{"id":"198114","messageId":"1346347393-8425-2-git-send-email-cmn@elego.de","threadId":"31390","inReplyTo":"1346347393-8425-1-git-send-email-cmn@elego.de","subject":"[PATCH 1/3] branch: introduce --set-upstream-to","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-08-30T17:23:11Z","receivedAt":"2012-08-30T17:23:11Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"The existing --set-uptream option can cause confusion, as it uses the\nusual branch convention of assuming a starting point of HEAD if none\nis specified, causing\n\n    git branch --set-upstream origin/master\n\nto create a new local branch 'origin/master' that tracks the current\nbranch. As --set-upstream already exists, we can't simply change its\nbehaviour. To work around this, introduce --set-upstream-to which\naccepts a compulsory argument indicating what the new upstream branch\nshould be and one optinal argument indicating which branch to change,\ndefaulting to HEAD.\n\nThe new options allows us to type\n\n    git branch --set-upstream-to origin/master\n\nto set the current branch's upstream to be origin's master.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n Documentation/git-branch.txt |  9 ++++++++-\n builtin/branch.c             | 17 +++++++++++++++--\n t/t3200-branch.sh            | 14 ++++++++++++++\n 3 files changed, 37 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex 47235be..e41c4b5 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -13,6 +13,7 @@ SYNOPSIS\n \t[--column[=<options>] | --no-column]\n \t[(--merged | --no-merged | --contains) [<commit>]] [<pattern>...]\n 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]\n+'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\n 'git branch' (-m | -M) [<oldbranch>] <newbranch>\n 'git branch' (-d | -D) [-r] <branchname>...\n 'git branch' --edit-description [<branchname>]\n@@ -48,7 +49,7 @@ branch so that 'git pull' will appropriately merge from\n the remote-tracking branch. This behavior may be changed via the global\n `branch.autosetupmerge` configuration flag. That setting can be\n overridden by using the `--track` and `--no-track` options, and\n-changed later using `git branch --set-upstream`.\n+changed later using `git branch --set-upstream-to`.\n \n With a `-m` or `-M` option, <oldbranch> will be renamed to <newbranch>.\n If <oldbranch> had a corresponding reflog, it is renamed to match\n@@ -173,6 +174,12 @@ start-point is either a local or remote-tracking branch.\n \tlike `--track` would when creating the branch, except that where\n \tbranch points to is not changed.\n \n+-u <upstream>::\n+--set-upstream-to=<upstream>::\n+\tSet up <branchname>'s tracking information so <upstream> is\n+\tconsidered <branchname>'s upstream branch. If no <branchname>\n+\tis specified, then it defaults to the current branch.\n+\n --edit-description::\n \tOpen an editor and edit the text to explain what the branch is\n \tfor, to be used by various other commands (e.g. `request-pull`).\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0e060f2..3c978eb 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -713,6 +713,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tint verbose = 0, abbrev = -1, detached = 0;\n \tint reflog = 0, edit_description = 0;\n \tint quiet = 0;\n+\tconst char *new_upstream = NULL;\n \tenum branch_track track;\n \tint kinds = REF_LOCAL_BRANCH;\n \tstruct commit_list *with_commit = NULL;\n@@ -726,6 +727,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t\tBRANCH_TRACK_EXPLICIT),\n \t\tOPT_SET_INT( 0, \"set-upstream\",  &track, \"change upstream info\",\n \t\t\tBRANCH_TRACK_OVERRIDE),\n+\t\tOPT_STRING('u', \"set-upstream-to\", &new_upstream, \"upstream\", \"change the upstream info\"),\n \t\tOPT__COLOR(&branch_use_color, \"use colored output\"),\n \t\tOPT_SET_INT('r', \"remotes\",     &kinds, \"act on remote-tracking branches\",\n \t\t\tREF_REMOTE_BRANCH),\n@@ -794,10 +796,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, options, builtin_branch_usage,\n \t\t\t     0);\n \n-\tif (!delete && !rename && !edit_description && argc == 0)\n+\tif (!delete && !rename && !edit_description && !new_upstream && argc == 0)\n \t\tlist = 1;\n \n-\tif (!!delete + !!rename + !!force_create + !!list > 1)\n+\tif (!!delete + !!rename + !!force_create + !!list + !!new_upstream > 1)\n \t\tusage_with_options(builtin_branch_usage, options);\n \n \tif (abbrev == -1)\n@@ -852,6 +854,17 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t\trename_branch(argv[0], argv[1], rename > 1);\n \t\telse\n \t\t\tusage_with_options(builtin_branch_usage, options);\n+\t} else if (new_upstream) {\n+\t\tstruct branch *branch = branch_get(argv[0]);\n+\n+\t\tif (!ref_exists(branch->refname))\n+\t\t\tdie(_(\"branch '%s' does not exist\"), branch->name);\n+\n+\t\t/*\n+\t\t * create_branch takes care of setting up the tracking\n+\t\t * info and making sure new_upstream is correct\n+\t\t */\n+\t\tcreate_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);\n \t} else if (argc > 0 && argc <= 2) {\n \t\tif (kinds != REF_LOCAL_BRANCH)\n \t\t\tdie(_(\"-a and -r options to 'git branch' do not make sense with a branch name\"));\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex a17f8b2..e9019ac 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -369,6 +369,20 @@ test_expect_success \\\n     'git tag foobar &&\n      test_must_fail git branch --track my11 foobar'\n \n+test_expect_success 'use --set-upstream-to modify HEAD' \\\n+    'test_config branch.master.remote foo &&\n+     test_config branch.master.merge foo &&\n+     git branch my12\n+     git branch --set-upstream-to my12 &&\n+     test \"$(git config branch.master.remote)\" = \".\" &&\n+     test \"$(git config branch.master.merge)\" = \"refs/heads/my12\"'\n+\n+test_expect_success 'use --set-upstream-to modify a particular branch' \\\n+    'git branch my13\n+     git branch --set-upstream-to master my13 &&\n+     test \"$(git config branch.my13.remote)\" = \".\" &&\n+     test \"$(git config branch.my13.merge)\" = \"refs/heads/master\"'\n+\n # Keep this test last, as it changes the current branch\n cat >expect <<EOF\n $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-- \n1.7.12.3.g0dd8ef6\n"},{"id":"198113","messageId":"1346347393-8425-3-git-send-email-cmn@elego.de","threadId":"31390","inReplyTo":"1346347393-8425-1-git-send-email-cmn@elego.de","subject":"[PATCH 2/3] branch: add --unset-upstream option","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-08-30T17:23:12Z","receivedAt":"2012-08-30T17:23:12Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"We have ways of setting the upstream information, but if we want to\nunset it, we need to resort to modifying the configuration manually.\n\nTeach branch an --unset-upstream option that unsets this information.\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n Documentation/git-branch.txt |  5 +++++\n builtin/branch.c             | 21 ++++++++++++++++++---\n t/t3200-branch.sh            | 19 +++++++++++++++++++\n 3 files changed, 42 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt\nindex e41c4b5..9c1d2f1 100644\n--- a/Documentation/git-branch.txt\n+++ b/Documentation/git-branch.txt\n@@ -14,6 +14,7 @@ SYNOPSIS\n \t[(--merged | --no-merged | --contains) [<commit>]] [<pattern>...]\n 'git branch' [--set-upstream | --track | --no-track] [-l] [-f] <branchname> [<start-point>]\n 'git branch' (--set-upstream-to=<upstream> | -u <upstream>) [<branchname>]\n+'git branch' --unset-upstream [<branchname>]\n 'git branch' (-m | -M) [<oldbranch>] <newbranch>\n 'git branch' (-d | -D) [-r] <branchname>...\n 'git branch' --edit-description [<branchname>]\n@@ -180,6 +181,10 @@ start-point is either a local or remote-tracking branch.\n \tconsidered <branchname>'s upstream branch. If no <branchname>\n \tis specified, then it defaults to the current branch.\n \n+--unset-upstream::\n+\tRemove the upstream information for <branchname>. If no branch\n+\tis specified it defaults to the current branch.\n+\n --edit-description::\n \tOpen an editor and edit the text to explain what the branch is\n \tfor, to be used by various other commands (e.g. `request-pull`).\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 3c978eb..557995d 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -712,7 +712,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \tint delete = 0, rename = 0, force_create = 0, list = 0;\n \tint verbose = 0, abbrev = -1, detached = 0;\n \tint reflog = 0, edit_description = 0;\n-\tint quiet = 0;\n+\tint quiet = 0, unset_upstream = 0;\n \tconst char *new_upstream = NULL;\n \tenum branch_track track;\n \tint kinds = REF_LOCAL_BRANCH;\n@@ -728,6 +728,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_SET_INT( 0, \"set-upstream\",  &track, \"change upstream info\",\n \t\t\tBRANCH_TRACK_OVERRIDE),\n \t\tOPT_STRING('u', \"set-upstream-to\", &new_upstream, \"upstream\", \"change the upstream info\"),\n+\t\tOPT_BOOLEAN(0, \"unset-upstream\", &unset_upstream, \"Unset the upstream info\"),\n \t\tOPT__COLOR(&branch_use_color, \"use colored output\"),\n \t\tOPT_SET_INT('r', \"remotes\",     &kinds, \"act on remote-tracking branches\",\n \t\t\tREF_REMOTE_BRANCH),\n@@ -796,10 +797,10 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \targc = parse_options(argc, argv, prefix, options, builtin_branch_usage,\n \t\t\t     0);\n \n-\tif (!delete && !rename && !edit_description && !new_upstream && argc == 0)\n+\tif (!delete && !rename && !edit_description && !new_upstream && !unset_upstream && argc == 0)\n \t\tlist = 1;\n \n-\tif (!!delete + !!rename + !!force_create + !!list + !!new_upstream > 1)\n+\tif (!!delete + !!rename + !!force_create + !!list + !!new_upstream + !!unset_upstream > 1)\n \t\tusage_with_options(builtin_branch_usage, options);\n \n \tif (abbrev == -1)\n@@ -865,6 +866,20 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\t * info and making sure new_upstream is correct\n \t\t */\n \t\tcreate_branch(head, branch->name, new_upstream, 0, 0, 0, quiet, BRANCH_TRACK_OVERRIDE);\n+\t} else if (unset_upstream) {\n+\t\tstruct branch *branch = branch_get(argv[0]);\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n+\t\tif (!branch_has_merge_config(branch)) {\n+\t\t\tdie(_(\"Branch '%s' has no upstream information\"), branch->name);\n+\t\t}\n+\n+\t\tstrbuf_addf(&buf, \"branch.%s.remote\", branch->name);\n+\t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n+\t\tstrbuf_reset(&buf);\n+\t\tstrbuf_addf(&buf, \"branch.%s.merge\", branch->name);\n+\t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n+\t\tstrbuf_release(&buf);\n \t} else if (argc > 0 && argc <= 2) {\n \t\tif (kinds != REF_LOCAL_BRANCH)\n \t\t\tdie(_(\"-a and -r options to 'git branch' do not make sense with a branch name\"));\ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex e9019ac..1018e8b 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -383,6 +383,25 @@ test_expect_success 'use --set-upstream-to modify a particular branch' \\\n      test \"$(git config branch.my13.remote)\" = \".\" &&\n      test \"$(git config branch.my13.merge)\" = \"refs/heads/master\"'\n \n+test_expect_success '--unset-upstream should fail if given a non-existent branch' \\\n+    'test_must_fail git branch --unset-upstream i-dont-exist'\n+\n+test_expect_success 'test --unset-upstream on HEAD' \\\n+    'git branch my14\n+     test_config branch.master.remote foo &&\n+     test_config branch.master.merge foo &&\n+     git branch --set-upstream-to my14 &&\n+     git branch --unset-upstream &&\n+     test_must_fail git config branch.master.remote &&\n+     test_must_fail git config branch.master.merge'\n+\n+test_expect_success 'test --unset-upstream on a particular branch' \\\n+    'git branch my15\n+     git branch --set-upstream-to master my14 &&\n+     git branch --unset-upstream my14 &&\n+     test_must_fail git config branch.my14.remote &&\n+     test_must_fail git config branch.my14.merge'\n+\n # Keep this test last, as it changes the current branch\n cat >expect <<EOF\n $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-- \n1.7.12.3.g0dd8ef6\n"},{"id":"198115","messageId":"1346347393-8425-4-git-send-email-cmn@elego.de","threadId":"31390","inReplyTo":"1346347393-8425-1-git-send-email-cmn@elego.de","subject":"[PATCH 3/3] branch: deprecate --set-upstream and show help if we detect possible mistaken use","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-08-30T17:23:13Z","receivedAt":"2012-08-30T17:23:13Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"This interface is error prone, and a better one (--set-upstream-to)\nexists. Add a message listing the alternatives and suggest how to fix\na --set-upstream invocation in case the user only gives one argument\nwhich causes a local branch with the same name as a remote-tracking\none to be created. The typical case is\n\n    git branch --set-upstream origin/master\n\nwhen the user meant\n\n    git branch --set-upstream master origin/master\n\nassuming that the current branch is master. Show a message telling the\nuser how to undo their action and get what they wanted. For the\ncommand above, the message would be\n\nThe --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\nBranch origin/master set up to track local branch master.\n\nIf you wanted to make 'master' track 'origin/master', do this:\n\n    git branch -d origin/master\n    git branch --set-upstream-to origin/master\n\nSigned-off-by: Carlos Martín Nieto <cmn@elego.de>\n---\n builtin/branch.c  | 26 ++++++++++++++++++++++++++\n t/t3200-branch.sh | 34 ++++++++++++++++++++++++++++++++++\n 2 files changed, 60 insertions(+)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 557995d..5e95e35 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -881,10 +881,36 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tgit_config_set_multivar(buf.buf, NULL, NULL, 1);\n \t\tstrbuf_release(&buf);\n \t} else if (argc > 0 && argc <= 2) {\n+\t\tstruct branch *branch = branch_get(argv[0]);\n+\t\tint branch_existed = 0, remote_tracking = 0;\n+\t\tstruct strbuf buf = STRBUF_INIT;\n+\n \t\tif (kinds != REF_LOCAL_BRANCH)\n \t\t\tdie(_(\"-a and -r options to 'git branch' do not make sense with a branch name\"));\n+\n+\t\tif (track == BRANCH_TRACK_OVERRIDE)\n+\t\t\tfprintf(stderr, _(\"The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\\n\"));\n+\n+\t\tstrbuf_addf(&buf, \"refs/remotes/%s\", branch->name);\n+\t\tremote_tracking = ref_exists(buf.buf);\n+\t\tstrbuf_release(&buf);\n+\n+\t\tbranch_existed = ref_exists(branch->refname);\n \t\tcreate_branch(head, argv[0], (argc == 2) ? argv[1] : head,\n \t\t\t      force_create, reflog, 0, quiet, track);\n+\n+\t\t/*\n+\t\t * We only show the instructions if the user gave us\n+\t\t * one branch which doesn't exist locally, but is the\n+\t\t * name of a remote-tracking branch.\n+\t\t */\n+\t\tif (argc == 1 && track == BRANCH_TRACK_OVERRIDE &&\n+\t\t    !branch_existed && remote_tracking) {\n+\t\t\tfprintf(stderr, _(\"\\nIf you wanted to make '%s' track '%s', do this:\\n\\n\"), head, branch->name);\n+\t\t\tfprintf(stderr, _(\"    git branch -d %s\\n\"), branch->name);\n+\t\t\tfprintf(stderr, _(\"    git branch --set-upstream-to %s\\n\"), branch->name);\n+\t\t}\n+\n \t} else\n \t\tusage_with_options(builtin_branch_usage, options);\n \ndiff --git a/t/t3200-branch.sh b/t/t3200-branch.sh\nindex 1018e8b..f2a076c 100755\n--- a/t/t3200-branch.sh\n+++ b/t/t3200-branch.sh\n@@ -402,6 +402,40 @@ test_expect_success 'test --unset-upstream on a particular branch' \\\n      test_must_fail git config branch.my14.remote &&\n      test_must_fail git config branch.my14.merge'\n \n+test_expect_success '--set-upstream shows message when creating a new branch that exists as remote-tracking' \\\n+    'git update-ref refs/remotes/origin/master HEAD &&\n+     git branch --set-upstream origin/master 2>actual &&\n+     test_when_finished git update-ref -d refs/remotes/origin/master &&\n+     test_when_finished git branch -d origin/master &&\n+     cat >expected <<EOF &&\n+The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n+\n+If you wanted to make '\"'master'\"' track '\"'origin/master'\"', do this:\n+\n+    git branch -d origin/master\n+    git branch --set-upstream-to origin/master\n+EOF\n+     test_cmp expected actual\n+'\n+\n+test_expect_success '--set-upstream with two args only shows the deprecation message' \\\n+    'git branch --set-upstream master my13 2>actual &&\n+     test_when_finished git branch --unset-upstream master &&\n+     cat >expected <<EOF &&\n+The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n+EOF\n+     test_cmp expected actual\n+'\n+\n+test_expect_success '--set-upstream with one arg only shows the deprecation message if the branch existed' \\\n+    'git branch --set-upstream my13 2>actual &&\n+     test_when_finished git branch --unset-upstream my13 &&\n+     cat >expected <<EOF &&\n+The --set-upstream flag is deprecated and will be removed. Consider using --track or --set-upstream-to\n+EOF\n+     test_cmp expected actual\n+'\n+\n # Keep this test last, as it changes the current branch\n cat >expect <<EOF\n $_z40 $HEAD $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000\tbranch: Created from master\n-- \n1.7.12.3.g0dd8ef6\n"},{"id":"198119","messageId":"7v1uios2ma.fsf@alter.siamese.dyndns.org","threadId":"31390","inReplyTo":"1346347393-8425-1-git-send-email-cmn@elego.de","subject":"Re: [PATCHv2 0/3] Improve branch UI for setting upstream information","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-30T17:37:01Z","receivedAt":"2012-08-30T17:37:01Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Carlos Martín Nieto <cmn@elego.de> writes:\n\n> As a result of making --unset-upstream fail if the given branch\n> doesn't exist, I discovered a copy-paste error in on the the tests in\n> the patch after it, so I'm resending the whole thing.\n>\n> The changes from the last reroll are the tightening of the situations\n> where git will show an error message (not it's just if the branch is\n> new and exists as remote-tracking) which I already sent as a reply in\n> the other thread; and making --unset-upstream error out on bad input,\n> which I already mentioned above.\n\nThanks.\n\nIn addition to \"--unset-upstream must fail on i-dont-exist branch\"\nin [2/3], I am wondering if we would want to also make sure the\ncommand fails when the upstream information is not set for the\nbranch, i.e. something like the following on top.\n\nWhat do you think?\n\n t/t3200-branch.sh | 4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git i/t/t3200-branch.sh w/t/t3200-branch.sh\nindex 1018e8b..a0aaedd 100755\n--- i/t/t3200-branch.sh\n+++ w/t/t3200-branch.sh\n@@ -393,7 +393,9 @@ test_expect_success 'test --unset-upstream on HEAD' \\\n      git branch --set-upstream-to my14 &&\n      git branch --unset-upstream &&\n      test_must_fail git config branch.master.remote &&\n-     test_must_fail git config branch.master.merge'\n+     test_must_fail git config branch.master.merge &&\n+     test_must_fail git branch --unset-upstream\n+'\n \n test_expect_success 'test --unset-upstream on a particular branch' \\\n     'git branch my15\n"},{"id":"198120","messageId":"CAN0XMOKar3jdDMfY=rRkcmNy0i0zKMuhBQ=Z4bi=eus_xAFWyA@mail.gmail.com","threadId":"31390","inReplyTo":"1346347393-8425-2-git-send-email-cmn@elego.de","subject":"Re: [PATCH 1/3] branch: introduce --set-upstream-to","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@gmail.com","sentAt":"2012-08-30T17:51:02Z","receivedAt":"2012-08-30T17:51:02Z","isPatch":true,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":"On Thu, Aug 30, 2012 at 7:23 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n> behaviour. To work around this, introduce --set-upstream-to which\n> accepts a compulsory argument indicating what the new upstream branch\n> should be and one optinal argument indicating which branch to change,\n> defaulting to HEAD.\n>\n\nCould you please also add this new option to the\n\"contrib/completion/git-completion.bash\"\nscript?\n\nThanks!\n"},{"id":"198122","messageId":"87fw745hsb.fsf@centaur.cmartin.tk","threadId":"31390","inReplyTo":"7v1uios2ma.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv2 0/3] Improve branch UI for setting upstream information","fromName":"Carlos Martín Nieto","fromEmail":"carlos@cmartin.tk","sentAt":"2012-08-30T18:57:56Z","receivedAt":"2012-08-30T18:57:56Z","isPatch":false,"sender":{"key":"carlos@cmartin.tk","avatar":"https://gravatar.com/avatar/956bfe8371004f2960febf266a6af789f60cdc01fbae48bb151ad4c9b532c3a2?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Carlos Martín Nieto <cmn@elego.de> writes:\n>\n>> As a result of making --unset-upstream fail if the given branch\n>> doesn't exist, I discovered a copy-paste error in on the the tests in\n>> the patch after it, so I'm resending the whole thing.\n>>\n>> The changes from the last reroll are the tightening of the situations\n>> where git will show an error message (not it's just if the branch is\n>> new and exists as remote-tracking) which I already sent as a reply in\n>> the other thread; and making --unset-upstream error out on bad input,\n>> which I already mentioned above.\n>\n> Thanks.\n>\n> In addition to \"--unset-upstream must fail on i-dont-exist branch\"\n> in [2/3], I am wondering if we would want to also make sure the\n> command fails when the upstream information is not set for the\n> branch, i.e. something like the following on top.\n>\n> What do you think?\n>\n>  t/t3200-branch.sh | 4 +++-\n>  1 file changed, 3 insertions(+), 1 deletion(-)\n>\n> diff --git i/t/t3200-branch.sh w/t/t3200-branch.sh\n> index 1018e8b..a0aaedd 100755\n> --- i/t/t3200-branch.sh\n> +++ w/t/t3200-branch.sh\n> @@ -393,7 +393,9 @@ test_expect_success 'test --unset-upstream on HEAD' \\\n>       git branch --set-upstream-to my14 &&\n>       git branch --unset-upstream &&\n>       test_must_fail git config branch.master.remote &&\n> -     test_must_fail git config branch.master.merge'\n> +     test_must_fail git config branch.master.merge &&\n> +     test_must_fail git branch --unset-upstream\n> +'\n\nYeah, this looks good, makes sure that it will still behave correctly\neven if the code path for these two situations diverges.\n\n   cmn\n"},{"id":"198124","messageId":"7vipc0qgu7.fsf@alter.siamese.dyndns.org","threadId":"31390","inReplyTo":"87fw745hsb.fsf@centaur.cmartin.tk","subject":"Re: [PATCHv2 0/3] Improve branch UI for setting upstream information","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-30T20:12:48Z","receivedAt":"2012-08-30T20:12:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"carlos@cmartin.tk (Carlos Martín Nieto) writes:\n\n> Junio C Hamano <gitster@pobox.com> writes:\n>\n>> Carlos Martín Nieto <cmn@elego.de> writes:\n>>\n>>> As a result of making --unset-upstream fail if the given branch\n>>> doesn't exist, I discovered a copy-paste error in on the the tests in\n>>> the patch after it, so I'm resending the whole thing.\n>>>\n>>> The changes from the last reroll are the tightening of the situations\n>>> where git will show an error message (not it's just if the branch is\n>>> new and exists as remote-tracking) which I already sent as a reply in\n>>> the other thread; and making --unset-upstream error out on bad input,\n>>> which I already mentioned above.\n>>\n>> Thanks.\n>>\n>> In addition to \"--unset-upstream must fail on i-dont-exist branch\"\n>> in [2/3], I am wondering if we would want to also make sure the\n>> command fails when the upstream information is not set for the\n>> branch, i.e. something like the following on top.\n>>\n>> What do you think?\n>>\n>>  t/t3200-branch.sh | 4 +++-\n>>  1 file changed, 3 insertions(+), 1 deletion(-)\n>>\n>> diff --git i/t/t3200-branch.sh w/t/t3200-branch.sh\n>> index 1018e8b..a0aaedd 100755\n>> --- i/t/t3200-branch.sh\n>> +++ w/t/t3200-branch.sh\n>> @@ -393,7 +393,9 @@ test_expect_success 'test --unset-upstream on HEAD' \\\n>>       git branch --set-upstream-to my14 &&\n>>       git branch --unset-upstream &&\n>>       test_must_fail git config branch.master.remote &&\n>> -     test_must_fail git config branch.master.merge'\n>> +     test_must_fail git config branch.master.merge &&\n>> +     test_must_fail git branch --unset-upstream\n>> +'\n>\n> Yeah, this looks good, makes sure that it will still behave correctly\n> even if the code path for these two situations diverges.\n\nAlright; will squash.\n\nThanks.\n"},{"id":"198147","messageId":"87mx1b3x3m.fsf@centaur.cmartin.tk","threadId":"31390","inReplyTo":"CAN0XMOKar3jdDMfY=rRkcmNy0i0zKMuhBQ=Z4bi=eus_xAFWyA@mail.gmail.com","subject":"Re: [PATCH 1/3] branch: introduce --set-upstream-to","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-08-31T15:22:21Z","receivedAt":"2012-08-31T15:22:21Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"Ralf Thielow <ralf.thielow@gmail.com> writes:\n\n> On Thu, Aug 30, 2012 at 7:23 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n>> behaviour. To work around this, introduce --set-upstream-to which\n>> accepts a compulsory argument indicating what the new upstream branch\n>> should be and one optinal argument indicating which branch to change,\n>> defaulting to HEAD.\n>>\n>\n> Could you please also add this new option to the\n> \"contrib/completion/git-completion.bash\"\n> script?\n\nIf I knew how those things work... Is this enough?\n\n   cmn\n\n--8<--\nSubject: [PATCH] completion: add --set-upstream-to and --unset-upstream\n\n---\n contrib/completion/git-completion.bash | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ffedce7..4f46357 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -880,6 +880,7 @@ _git_branch ()\n \t\t\t--color --no-color --verbose --abbrev= --no-abbrev\n \t\t\t--track --no-track --contains --merged --no-merged\n \t\t\t--set-upstream --edit-description --list\n+\t\t\t--unset-upstream --set-upstream-to=\n \t\t\t\"\n \t\t;;\n \t*)\n-- \n1.7.12.3.g0dd8ef6\n"},{"id":"198148","messageId":"CAN0XMOK1_JqMuAkW-XzGfkn8pkTUqt879-+E0cGBn79GzEXWkQ@mail.gmail.com","threadId":"31390","inReplyTo":"87mx1b3x3m.fsf@centaur.cmartin.tk","subject":"Re: [PATCH 1/3] branch: introduce --set-upstream-to","fromName":"Ralf Thielow","fromEmail":"ralf.thielow@gmail.com","sentAt":"2012-08-31T15:30:53Z","receivedAt":"2012-08-31T15:30:53Z","isPatch":true,"sender":{"key":"ralf.thielow@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1275832?v=4"},"body":"On Fri, Aug 31, 2012 at 5:22 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n> Ralf Thielow <ralf.thielow@gmail.com> writes:\n>\n>> On Thu, Aug 30, 2012 at 7:23 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n>>> behaviour. To work around this, introduce --set-upstream-to which\n>>> accepts a compulsory argument indicating what the new upstream branch\n>>> should be and one optinal argument indicating which branch to change,\n>>> defaulting to HEAD.\n>>>\n>>\n>> Could you please also add this new option to the\n>> \"contrib/completion/git-completion.bash\"\n>> script?\n>\n> If I knew how those things work... Is this enough?\n>\n\nYes, Thanks.\n\n>    cmn\n>\n> --8<--\n> Subject: [PATCH] completion: add --set-upstream-to and --unset-upstream\n>\n> ---\n>  contrib/completion/git-completion.bash | 1 +\n>  1 file changed, 1 insertion(+)\n>\n> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n> index ffedce7..4f46357 100644\n> --- a/contrib/completion/git-completion.bash\n> +++ b/contrib/completion/git-completion.bash\n> @@ -880,6 +880,7 @@ _git_branch ()\n>                         --color --no-color --verbose --abbrev= --no-abbrev\n>                         --track --no-track --contains --merged --no-merged\n>                         --set-upstream --edit-description --list\n> +                       --unset-upstream --set-upstream-to=\n>                         \"\n>                 ;;\n>         *)\n> --\n> 1.7.12.3.g0dd8ef6\n"},{"id":"198154","messageId":"7vy5kvng2t.fsf@alter.siamese.dyndns.org","threadId":"31390","inReplyTo":"CAN0XMOK1_JqMuAkW-XzGfkn8pkTUqt879-+E0cGBn79GzEXWkQ@mail.gmail.com","subject":"Re: [PATCH 1/3] branch: introduce --set-upstream-to","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-31T17:09:46Z","receivedAt":"2012-08-31T17:09:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ralf Thielow <ralf.thielow@gmail.com> writes:\n\n> On Fri, Aug 31, 2012 at 5:22 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n>> Ralf Thielow <ralf.thielow@gmail.com> writes:\n>>\n>>> On Thu, Aug 30, 2012 at 7:23 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n>>>> behaviour. To work around this, introduce --set-upstream-to which\n>>>> accepts a compulsory argument indicating what the new upstream branch\n>>>> should be and one optinal argument indicating which branch to change,\n>>>> defaulting to HEAD.\n>>>>\n>>>\n>>> Could you please also add this new option to the\n>>> \"contrib/completion/git-completion.bash\"\n>>> script?\n>>\n>> If I knew how those things work... Is this enough?\n>>\n>\n> Yes, Thanks.\n\nWhile you are at it, perhaps you may want to unadvertise --set-upstream?\n\n>\n>>    cmn\n>>\n>> --8<--\n>> Subject: [PATCH] completion: add --set-upstream-to and --unset-upstream\n>>\n>> ---\n>>  contrib/completion/git-completion.bash | 1 +\n>>  1 file changed, 1 insertion(+)\n>>\n>> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\n>> index ffedce7..4f46357 100644\n>> --- a/contrib/completion/git-completion.bash\n>> +++ b/contrib/completion/git-completion.bash\n>> @@ -880,6 +880,7 @@ _git_branch ()\n>>                         --color --no-color --verbose --abbrev= --no-abbrev\n>>                         --track --no-track --contains --merged --no-merged\n>>                         --set-upstream --edit-description --list\n>> +                       --unset-upstream --set-upstream-to=\n>>                         \"\n>>                 ;;\n>>         *)\n>> --\n>> 1.7.12.3.g0dd8ef6\n"},{"id":"198191","messageId":"87pq65hj3t.fsf@centaur.cmartin.tk","threadId":"31390","inReplyTo":"7vy5kvng2t.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 1/3] branch: introduce --set-upstream-to","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2012-09-01T15:13:10Z","receivedAt":"2012-09-01T15:13:10Z","isPatch":true,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Ralf Thielow <ralf.thielow@gmail.com> writes:\n>\n>> On Fri, Aug 31, 2012 at 5:22 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n>>> Ralf Thielow <ralf.thielow@gmail.com> writes:\n>>>\n>>>> On Thu, Aug 30, 2012 at 7:23 PM, Carlos Martín Nieto <cmn@elego.de> wrote:\n>>>>> behaviour. To work around this, introduce --set-upstream-to which\n>>>>> accepts a compulsory argument indicating what the new upstream branch\n>>>>> should be and one optinal argument indicating which branch to change,\n>>>>> defaulting to HEAD.\n>>>>>\n>>>>\n>>>> Could you please also add this new option to the\n>>>> \"contrib/completion/git-completion.bash\"\n>>>> script?\n>>>\n>>> If I knew how those things work... Is this enough?\n>>>\n>>\n>> Yes, Thanks.\n>\n> While you are at it, perhaps you may want to unadvertise --set-upstream?\n>\n\nYeah, that'd be good.\n\n   cmn\n\n--8<--\nSubject: [PATCH] completion: add --set-upstream-to and --unset-upstream\n\nRemove --set-upstream as it's deprecated now.\n---\n contrib/completion/git-completion.bash | 3 ++-\n 1 file changed, 2 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex ffedce7..4a4d30a 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -879,7 +879,8 @@ _git_branch ()\n \t\t__gitcomp \"\n \t\t\t--color --no-color --verbose --abbrev= --no-abbrev\n \t\t\t--track --no-track --contains --merged --no-merged\n-\t\t\t--set-upstream --edit-description --list\n+\t\t\t--set-upstream-to= --edit-description --list\n+\t\t\t--unset-upstream\n \t\t\t\"\n \t\t;;\n \t*)\n-- \n1.7.12.3.g0dd8ef6\n"}]}