{"thread":{"id":"38060","subject":"'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","startedAt":"2014-11-26T22:29:28Z","lastAt":"2014-12-01T02:21:20Z","messageCount":7,"participants":["Adam Williamson","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"252613","messageId":"1417040968.12457.78.camel@redhat.com","threadId":"38060","inReplyTo":null,"subject":"'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Adam Williamson","fromEmail":"awilliam@redhat.com","sentAt":"2014-11-26T22:29:28Z","receivedAt":"2014-11-26T22:29:28Z","isPatch":false,"sender":{"key":"awilliam@redhat.com","avatar":"https://avatars.githubusercontent.com/u/916551?v=4"},"body":"Hi, folks. Ran into an unfortunate issue with git which helped me mess\nup a Fedora package repo today :/\n\nThe problem can be reproduced thus:\n\n1. Create an empty repo, clone it\n2. Push its master branch with something in it (just to get started)\n3. git branch --track moo origin/master\n4. git checkout moo\n5. echo moo >> moo && git commit -a -m \"create moo\"\n6. git push\n** BUG HAPPENS - CHANGES ARE PUSHED TO origin/master **\n7. git config --local push.default simple\n8. echo moo2 >> moo && git commit -a -m \"update moo\"\n9. git push\n** PUSH IS CORRECTLY REJECTED **\n\nIn both those cases, the push behaviour is supposed to be 'simple' - at\nstep 6 it's *implicitly* set to 'simple' (according to the\ndocumentation), while at step 9 it's *explicitly* set to 'simple'. At\nstep 6, a warning is printed to the console:\n\n=============\n\nwarning: push.default is unset; its implicit value has changed in\nGit 2.0 from 'matching' to 'simple'. To squelch this message\nand maintain the traditional behavior, use:\n\n  git config --global push.default matching\n\nTo squelch this message and adopt the new behavior now, use:\n\n  git config --global push.default simple\n\nWhen push.default is set to 'matching', git will push local branches\nto the remote branches that already exist with the same name.\n\nSince Git 2.0, Git defaults to the more conservative 'simple'\nbehavior, which only pushes the current branch to the corresponding\nremote branch that 'git pull' uses to update the current branch.\n\nSee 'git help config' and search for 'push.default' for further information.\n(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode\n'current' instead of 'simple' if you sometimes use older versions of Git)\n\n==============\n\nIf you follow the trail there and look at 'git help config', you find\nthis:\n\n============\n\n           ·   simple - in centralized workflow, work like upstream with an\n               added safety to refuse to push if the upstream branch’s name is\n               different from the local one.\n\n===========\n\nHowever, at step 6, the changes from branch 'moo' are pushed to 'master'\n- even though that text clearly says they shouldn't be, as the names\ndon't match.\n\nAfter step 7 - *explicitly* setting push.default to simple, rather than\nrelying on it being set to simple *implicitly* - another git push is\ncorrectly rejected, with this message:\n\n============\n\nfatal: The upstream branch of your current branch does not match\nthe name of your current branch.  To push to the upstream branch\non the remote, use\n\n    git push origin HEAD:master\n\nTo push to the branch of the same name on the remote, use\n\n    git push origin moo\n\n=============\n\nI believe the 'implicit' case was broken by the commit \"push: change\n`simple` to accommodate triangular workflows\":\n\nhttps://github.com/git/git/commit/ed2b18292bfeedc98c9e2b6bd8a35d8001dab2fc\n\nIt changes the condition for running the 'does the branch name match'\ntest from \"if (simple)\" to \"if (push_default == PUSH_DEFAULT_SIMPLE)\".\nAFAICS, in the 'implicit' case, push_default ==\nPUSH_DEFAULT_UNSPECIFIED, not PUSH_DEFAULT_SIMPLE, so the 'does the\nbranch name match' check is not run, even though the behaviour is\nsupposed (according to the documentation) to be the same as if the\ndefault were explicitly set to 'simple'.\n\nThanks to this, when I accidentally did 'git push' on a branch of the\nFedora kernel package git repo which only exists in my downstream\ncheckout, all my changes got pushed to the upstream master branch :( So\nit's a bit dangerous.\n-- \nAdam Williamson\nFedora QA Community Monkey\nIRC: adamw | Twitter: AdamW_Fedora | XMPP: adamw AT happyassassin . net\nhttp://www.happyassassin.net\n"},{"id":"252615","messageId":"1417041500.12457.79.camel@redhat.com","threadId":"38060","inReplyTo":"1417040968.12457.78.camel@redhat.com","subject":"Re: 'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Adam Williamson","fromEmail":"awilliam@redhat.com","sentAt":"2014-11-26T22:38:20Z","receivedAt":"2014-11-26T22:38:20Z","isPatch":false,"sender":{"key":"awilliam@redhat.com","avatar":"https://avatars.githubusercontent.com/u/916551?v=4"},"body":"On Wed, 2014-11-26 at 14:29 -0800, Adam Williamson wrote:\n> Hi, folks. Ran into an unfortunate issue with git which helped me mess\n> up a Fedora package repo today :/\n> \n> The problem can be reproduced thus:\n\nWhoops, I missed step 0:\n\n0. Ensure push.default is not configured globally\n\n> 1. Create an empty repo, clone it\n> 2. Push its master branch with something in it (just to get started)\n> 3. git branch --track moo origin/master\n> 4. git checkout moo\n> 5. echo moo >> moo && git commit -a -m \"create moo\"\n> 6. git push\n> ** BUG HAPPENS - CHANGES ARE PUSHED TO origin/master **\n> 7. git config --local push.default simple\n> 8. echo moo2 >> moo && git commit -a -m \"update moo\"\n> 9. git push\n> ** PUSH IS CORRECTLY REJECTED **\n-- \nAdam Williamson\nFedora QA Community Monkey\nIRC: adamw | Twitter: AdamW_Fedora | XMPP: adamw AT happyassassin . net\nhttp://www.happyassassin.net\n"},{"id":"252628","messageId":"20141127034306.GA5341@peff.net","threadId":"38060","inReplyTo":"1417040968.12457.78.camel@redhat.com","subject":"Re: 'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-11-27T03:43:06Z","receivedAt":"2014-11-27T03:43:06Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Nov 26, 2014 at 02:29:28PM -0800, Adam Williamson wrote:\n\n> Hi, folks. Ran into an unfortunate issue with git which helped me mess\n> up a Fedora package repo today :/\n> \n> The problem can be reproduced thus:\n> \n> 1. Create an empty repo, clone it\n> 2. Push its master branch with something in it (just to get started)\n> 3. git branch --track moo origin/master\n> 4. git checkout moo\n> 5. echo moo >> moo && git commit -a -m \"create moo\"\n> 6. git push\n> ** BUG HAPPENS - CHANGES ARE PUSHED TO origin/master **\n> 7. git config --local push.default simple\n> 8. echo moo2 >> moo && git commit -a -m \"update moo\"\n> 9. git push\n> ** PUSH IS CORRECTLY REJECTED **\n> \n> In both those cases, the push behaviour is supposed to be 'simple' - at\n> step 6 it's *implicitly* set to 'simple' (according to the\n> documentation), while at step 9 it's *explicitly* set to 'simple'. At\n> step 6, a warning is printed to the console:\n\nUgh. Yeah, this never worked properly, even in the original v2.0.0\nrelease. Worse, our tests did not notice it at all.  Patch is below.\n\n\n-- >8 --\nSubject: push: truly use \"simple\" as default, not \"upstream\"\n\nThe plan for the push.default transition had all along been\nto use the \"simple\" method rather than \"upstream\" as a\ndefault if the user did not specify their own push.default\nvalue. Commit 11037ee (push: switch default from \"matching\"\nto \"simple\", 2013-01-04) tried to implement that by moving\nPUSH_DEFAULT_UNSPECIFIED in our switch statement to\nfall-through to the PUSH_DEFAULT_SIMPLE case.\n\nWhen the commit that became 11037ee was originally written,\nthat would have been enough. We would fall through to\ncalling setup_push_upstream() with the \"simple\" parameter\nset to 1. However, it was delayed for a while until we were\nready to make the transition in Git 2.0.\n\nAnd in the meantime, commit ed2b182 (push: change `simple`\nto accommodate triangular workflows, 2013-06-19) threw a\nmonkey wrench into the works. That commit drops the \"simple\"\nparameter to setup_push_upstream, and instead checks whether\nthe global \"push_default\" is PUSH_DEFAULT_SIMPLE. This is\nright when the user has explicitly configured push.default\nto simple, but wrong when we are a fall-through for the\n\"unspecified\" case.\n\nWe never noticed because our push.default tests do not cover\nthe case of the variable being totally unset; they only\ncheck the \"simple\" behavior itself.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\ned2b182 comes from Ram, but the suggestion for this bit of code actually\ncomes from Junio in:\n\n  http://thread.gmane.org/gmane.comp.version-control.git/228383/focus=228436\n\nI am not sure I understand the reason for dropping the \"simple\"\nparameter in that commit in the first place. If we are in triangular\nmode, then we would not get to setup_push_upstream from \"simple\" (or the\ndefault) in the first place (we would use \"current\" instead). The only\ntime \"triangular\" matters to setup_push_upstream is when push.default\nreally has been set to \"upstream\", but in that case, \"simple\" would\nalways be 0 (and likewise, the equality check that replaces it would\nalso be false).\n\nSo I have a vague concern that I'm missing something. Maybe one of you\nwho worked on it can recall more.\n\n builtin/push.c          |  8 ++++----\n t/t5528-push-default.sh | 32 ++++++++++++++++++++++++++++++--\n 2 files changed, 34 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin/push.c b/builtin/push.c\nindex a076b19..7aedf6f 100644\n--- a/builtin/push.c\n+++ b/builtin/push.c\n@@ -161,7 +161,7 @@ static const char message_detached_head_die[] =\n \t   \"    git push %s HEAD:<name-of-remote-branch>\\n\");\n \n static void setup_push_upstream(struct remote *remote, struct branch *branch,\n-\t\t\t\tint triangular)\n+\t\t\t\tint triangular, int simple)\n {\n \tstruct strbuf refspec = STRBUF_INIT;\n \n@@ -184,7 +184,7 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,\n \t\t      \"to update which remote branch.\"),\n \t\t    remote->name, branch->name);\n \n-\tif (push_default == PUSH_DEFAULT_SIMPLE) {\n+\tif (simple) {\n \t\t/* Additional safety */\n \t\tif (strcmp(branch->refname, branch->merge[0]->src))\n \t\t\tdie_push_simple(branch, remote);\n@@ -257,11 +257,11 @@ static void setup_default_push_refspecs(struct remote *remote)\n \t\tif (triangular)\n \t\t\tsetup_push_current(remote, branch);\n \t\telse\n-\t\t\tsetup_push_upstream(remote, branch, triangular);\n+\t\t\tsetup_push_upstream(remote, branch, triangular, 1);\n \t\tbreak;\n \n \tcase PUSH_DEFAULT_UPSTREAM:\n-\t\tsetup_push_upstream(remote, branch, triangular);\n+\t\tsetup_push_upstream(remote, branch, triangular, 0);\n \t\tbreak;\n \n \tcase PUSH_DEFAULT_CURRENT:\ndiff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh\nindex 6a5ac3a..cc74519 100755\n--- a/t/t5528-push-default.sh\n+++ b/t/t5528-push-default.sh\n@@ -26,7 +26,7 @@ check_pushed_commit () {\n # $2 = expected target branch for the push\n # $3 = [optional] repo to check for actual output (repo1 by default)\n test_push_success () {\n-\tgit -c push.default=\"$1\" push &&\n+\tgit ${1:+-c push.default=\"$1\"} push &&\n \tcheck_pushed_commit HEAD \"$2\" \"$3\"\n }\n \n@@ -34,7 +34,7 @@ test_push_success () {\n # check that push fails and does not modify any remote branch\n test_push_failure () {\n \tgit --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&\n-\ttest_must_fail git -c push.default=\"$1\" push &&\n+\ttest_must_fail git ${1:+-c push.default=\"$1\"} push &&\n \tgit --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&\n \ttest_cmp expect actual\n }\n@@ -172,4 +172,32 @@ test_pushdefault_workflow success simple master triangular\n # master is updated (parent2 does not have foo)\n test_pushdefault_workflow success matching master triangular\n \n+# default tests, when no push-default is specified. This\n+# should behave the same as \"simple\" in non-triangular\n+# settings, and as \"current\" otherwise.\n+\n+test_expect_success 'default behavior allows \"simple\" push' '\n+\ttest_config branch.master.remote parent1 &&\n+\ttest_config branch.master.merge refs/heads/master &&\n+\ttest_config remote.pushdefault parent1 &&\n+\ttest_commit default-master-master &&\n+\ttest_push_success \"\" master\n+'\n+\n+test_expect_success 'default behavior rejects non-simple push' '\n+\ttest_config branch.master.remote parent1 &&\n+\ttest_config branch.master.merge refs/heads/foo &&\n+\ttest_config remote.pushdefault parent1 &&\n+\ttest_commit default-master-foo &&\n+\ttest_push_failure \"\"\n+'\n+\n+test_expect_success 'default triangular behavior acts like \"current\"' '\n+\ttest_config branch.master.remote parent1 &&\n+\ttest_config branch.master.merge refs/heads/foo &&\n+\ttest_config remote.pushdefault parent2 &&\n+\ttest_commit default-triangular &&\n+\ttest_push_success \"\" master repo2\n+'\n+\n test_done\n-- \n2.2.0.rc2.402.g4519813\n"},{"id":"252629","messageId":"A90836FF-3EF7-48CC-83C0-4DD09D0F022D@redhat.com","threadId":"38060","inReplyTo":"20141127034306.GA5341@peff.net","subject":"Re: 'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Adam Williamson","fromEmail":"awilliam@redhat.com","sentAt":"2014-11-27T04:24:04Z","receivedAt":"2014-11-27T04:24:04Z","isPatch":false,"sender":{"key":"awilliam@redhat.com","avatar":"https://avatars.githubusercontent.com/u/916551?v=4"},"body":"On November 26, 2014 7:43:06 PM PST, Jeff King <peff@peff.net> wrote:\n>On Wed, Nov 26, 2014 at 02:29:28PM -0800, Adam Williamson wrote:\n>\n>> Hi, folks. Ran into an unfortunate issue with git which helped me\n>mess\n>> up a Fedora package repo today :/\n>> \n>> The problem can be reproduced thus:\n>> \n>> 1. Create an empty repo, clone it\n>> 2. Push its master branch with something in it (just to get started)\n>> 3. git branch --track moo origin/master\n>> 4. git checkout moo\n>> 5. echo moo >> moo && git commit -a -m \"create moo\"\n>> 6. git push\n>> ** BUG HAPPENS - CHANGES ARE PUSHED TO origin/master **\n>> 7. git config --local push.default simple\n>> 8. echo moo2 >> moo && git commit -a -m \"update moo\"\n>> 9. git push\n>> ** PUSH IS CORRECTLY REJECTED **\n>> \n>> In both those cases, the push behaviour is supposed to be 'simple' -\n>at\n>> step 6 it's *implicitly* set to 'simple' (according to the\n>> documentation), while at step 9 it's *explicitly* set to 'simple'. At\n>> step 6, a warning is printed to the console:\n>\n>Ugh. Yeah, this never worked properly, even in the original v2.0.0\n>release. Worse, our tests did not notice it at all.  Patch is below.\n>\n>\n>-- >8 --\n>Subject: push: truly use \"simple\" as default, not \"upstream\"\n>\n>The plan for the push.default transition had all along been\n>to use the \"simple\" method rather than \"upstream\" as a\n>default if the user did not specify their own push.default\n>value. Commit 11037ee (push: switch default from \"matching\"\n>to \"simple\", 2013-01-04) tried to implement that by moving\n>PUSH_DEFAULT_UNSPECIFIED in our switch statement to\n>fall-through to the PUSH_DEFAULT_SIMPLE case.\n>\n>When the commit that became 11037ee was originally written,\n>that would have been enough. We would fall through to\n>calling setup_push_upstream() with the \"simple\" parameter\n>set to 1. However, it was delayed for a while until we were\n>ready to make the transition in Git 2.0.\n>\n>And in the meantime, commit ed2b182 (push: change `simple`\n>to accommodate triangular workflows, 2013-06-19) threw a\n>monkey wrench into the works. That commit drops the \"simple\"\n>parameter to setup_push_upstream, and instead checks whether\n>the global \"push_default\" is PUSH_DEFAULT_SIMPLE. This is\n>right when the user has explicitly configured push.default\n>to simple, but wrong when we are a fall-through for the\n>\"unspecified\" case.\n>\n>We never noticed because our push.default tests do not cover\n>the case of the variable being totally unset; they only\n>check the \"simple\" behavior itself.\n>\n>Signed-off-by: Jeff King <peff@peff.net>\n>---\n>ed2b182 comes from Ram, but the suggestion for this bit of code\n>actually\n>comes from Junio in:\n>\n>http://thread.gmane.org/gmane.comp.version-control.git/228383/focus=228436\n>\n>I am not sure I understand the reason for dropping the \"simple\"\n>parameter in that commit in the first place. If we are in triangular\n>mode, then we would not get to setup_push_upstream from \"simple\" (or\n>the\n>default) in the first place (we would use \"current\" instead). The only\n>time \"triangular\" matters to setup_push_upstream is when push.default\n>really has been set to \"upstream\", but in that case, \"simple\" would\n>always be 0 (and likewise, the equality check that replaces it would\n>also be false).\n>\n>So I have a vague concern that I'm missing something. Maybe one of you\n>who worked on it can recall more.\n>\n> builtin/push.c          |  8 ++++----\n> t/t5528-push-default.sh | 32 ++++++++++++++++++++++++++++++--\n> 2 files changed, 34 insertions(+), 6 deletions(-)\n>\n>diff --git a/builtin/push.c b/builtin/push.c\n>index a076b19..7aedf6f 100644\n>--- a/builtin/push.c\n>+++ b/builtin/push.c\n>@@ -161,7 +161,7 @@ static const char message_detached_head_die[] =\n> \t   \"    git push %s HEAD:<name-of-remote-branch>\\n\");\n> \n>static void setup_push_upstream(struct remote *remote, struct branch\n>*branch,\n>-\t\t\t\tint triangular)\n>+\t\t\t\tint triangular, int simple)\n> {\n> \tstruct strbuf refspec = STRBUF_INIT;\n> \n>@@ -184,7 +184,7 @@ static void setup_push_upstream(struct remote\n>*remote, struct branch *branch,\n> \t\t      \"to update which remote branch.\"),\n> \t\t    remote->name, branch->name);\n> \n>-\tif (push_default == PUSH_DEFAULT_SIMPLE) {\n>+\tif (simple) {\n> \t\t/* Additional safety */\n> \t\tif (strcmp(branch->refname, branch->merge[0]->src))\n> \t\t\tdie_push_simple(branch, remote);\n>@@ -257,11 +257,11 @@ static void setup_default_push_refspecs(struct\n>remote *remote)\n> \t\tif (triangular)\n> \t\t\tsetup_push_current(remote, branch);\n> \t\telse\n>-\t\t\tsetup_push_upstream(remote, branch, triangular);\n>+\t\t\tsetup_push_upstream(remote, branch, triangular, 1);\n> \t\tbreak;\n> \n> \tcase PUSH_DEFAULT_UPSTREAM:\n>-\t\tsetup_push_upstream(remote, branch, triangular);\n>+\t\tsetup_push_upstream(remote, branch, triangular, 0);\n> \t\tbreak;\n> \n> \tcase PUSH_DEFAULT_CURRENT:\n>diff --git a/t/t5528-push-default.sh b/t/t5528-push-default.sh\n>index 6a5ac3a..cc74519 100755\n>--- a/t/t5528-push-default.sh\n>+++ b/t/t5528-push-default.sh\n>@@ -26,7 +26,7 @@ check_pushed_commit () {\n> # $2 = expected target branch for the push\n> # $3 = [optional] repo to check for actual output (repo1 by default)\n> test_push_success () {\n>-\tgit -c push.default=\"$1\" push &&\n>+\tgit ${1:+-c push.default=\"$1\"} push &&\n> \tcheck_pushed_commit HEAD \"$2\" \"$3\"\n> }\n> \n>@@ -34,7 +34,7 @@ test_push_success () {\n> # check that push fails and does not modify any remote branch\n> test_push_failure () {\n> \tgit --git-dir=repo1 log --no-walk --format='%h %s' --all >expect &&\n>-\ttest_must_fail git -c push.default=\"$1\" push &&\n>+\ttest_must_fail git ${1:+-c push.default=\"$1\"} push &&\n> \tgit --git-dir=repo1 log --no-walk --format='%h %s' --all >actual &&\n> \ttest_cmp expect actual\n> }\n>@@ -172,4 +172,32 @@ test_pushdefault_workflow success simple master\n>triangular\n> # master is updated (parent2 does not have foo)\n> test_pushdefault_workflow success matching master triangular\n> \n>+# default tests, when no push-default is specified. This\n>+# should behave the same as \"simple\" in non-triangular\n>+# settings, and as \"current\" otherwise.\n>+\n>+test_expect_success 'default behavior allows \"simple\" push' '\n>+\ttest_config branch.master.remote parent1 &&\n>+\ttest_config branch.master.merge refs/heads/master &&\n>+\ttest_config remote.pushdefault parent1 &&\n>+\ttest_commit default-master-master &&\n>+\ttest_push_success \"\" master\n>+'\n>+\n>+test_expect_success 'default behavior rejects non-simple push' '\n>+\ttest_config branch.master.remote parent1 &&\n>+\ttest_config branch.master.merge refs/heads/foo &&\n>+\ttest_config remote.pushdefault parent1 &&\n>+\ttest_commit default-master-foo &&\n>+\ttest_push_failure \"\"\n>+'\n>+\n>+test_expect_success 'default triangular behavior acts like \"current\"'\n>'\n>+\ttest_config branch.master.remote parent1 &&\n>+\ttest_config branch.master.merge refs/heads/foo &&\n>+\ttest_config remote.pushdefault parent2 &&\n>+\ttest_commit default-triangular &&\n>+\ttest_push_success \"\" master repo2\n>+'\n>+\n> test_done\n\nYeah, I've gone down pretty much exactly the same avenues of investigation, but had to suspend it to go out to dinner. I wanted to try and completely grok the whole history of this particular bit of behavior before suggesting a patch. So far my guess is that junio just got a bit mixed up with working on top of ram's changes and didn't catch that the check wouldn't work in the implicit case, but I wanted to look into it a bit more.\n-- \nAdam Williamson\nFedora QA Community Monkey\nIRC: adamw | Twitter: AdamW_Fedora | XMPP: adamw AT happyassassin DOT net\nhttp://www.happyassassin.net\n"},{"id":"252644","messageId":"1417108347.18654.4.camel@redhat.com","threadId":"38060","inReplyTo":"20141127034306.GA5341@peff.net","subject":"Re: 'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Adam Williamson","fromEmail":"awilliam@redhat.com","sentAt":"2014-11-27T17:12:27Z","receivedAt":"2014-11-27T17:12:27Z","isPatch":false,"sender":{"key":"awilliam@redhat.com","avatar":"https://avatars.githubusercontent.com/u/916551?v=4"},"body":"On Wed, 2014-11-26 at 22:43 -0500, Jeff King wrote:\n> On Wed, Nov 26, 2014 at 02:29:28PM -0800, Adam Williamson wrote:\n> \n> > Hi, folks. Ran into an unfortunate issue with git which helped me mess\n> > up a Fedora package repo today :/\n> > \n> > The problem can be reproduced thus:\n> > \n> > 1. Create an empty repo, clone it\n> > 2. Push its master branch with something in it (just to get started)\n> > 3. git branch --track moo origin/master\n> > 4. git checkout moo\n> > 5. echo moo >> moo && git commit -a -m \"create moo\"\n> > 6. git push\n> > ** BUG HAPPENS - CHANGES ARE PUSHED TO origin/master **\n> > 7. git config --local push.default simple\n> > 8. echo moo2 >> moo && git commit -a -m \"update moo\"\n> > 9. git push\n> > ** PUSH IS CORRECTLY REJECTED **\n> > \n> > In both those cases, the push behaviour is supposed to be 'simple' - at\n> > step 6 it's *implicitly* set to 'simple' (according to the\n> > documentation), while at step 9 it's *explicitly* set to 'simple'. At\n> > step 6, a warning is printed to the console:\n> \n> Ugh. Yeah, this never worked properly, even in the original v2.0.0\n> release. Worse, our tests did not notice it at all.  Patch is below.\n\nI've got a pile of Fedora stuff to do today so I don't know if I'll get\ntime to dig any further into the history of this and see if there are\nany hidden wrinkles, but on the face of it, Jeff's patch looks good to\nme. I'll try and find a moment to test it at least, but the approach\nmakes sense and is what I would've gone for too.\n\nIt might also be worth improving the warn_unspecified_push_default_msg[]\ntext to mention the name matching behaviour? At present it doesn't\nclearly explain this (you could argue it's *sort of* implied, but I\ndoubt many people will read it that way - I didn't), you have to follow\nthe chain into 'git help config' to find the description. Something\nlike:\n\n   \"Since Git 2.0, Git defaults to the more conservative 'simple'\\n\"\n   \"behavior, which only pushes the current branch to the corresponding\\n\"\n   \"remote branch that 'git pull' uses to update the current branch, \\n\"\n   \"if the names of those two branches match.\\n\"\n-- \nAdam Williamson\nFedora QA Community Monkey\nIRC: adamw | Twitter: AdamW_Fedora | XMPP: adamw AT happyassassin . net\nhttp://www.happyassassin.net\n"},{"id":"252653","messageId":"20141128045518.GB19456@peff.net","threadId":"38060","inReplyTo":"1417108347.18654.4.camel@redhat.com","subject":"Re: 'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2014-11-28T04:55:18Z","receivedAt":"2014-11-28T04:55:18Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 27, 2014 at 09:12:27AM -0800, Adam Williamson wrote:\n\n> It might also be worth improving the warn_unspecified_push_default_msg[]\n> text to mention the name matching behaviour? At present it doesn't\n> clearly explain this (you could argue it's *sort of* implied, but I\n> doubt many people will read it that way - I didn't), you have to follow\n> the chain into 'git help config' to find the description. Something\n> like:\n> \n>    \"Since Git 2.0, Git defaults to the more conservative 'simple'\\n\"\n>    \"behavior, which only pushes the current branch to the corresponding\\n\"\n>    \"remote branch that 'git pull' uses to update the current branch, \\n\"\n>    \"if the names of those two branches match.\\n\"\n\nYeah, I agree that is more clear.\n\nThere is some other magic with \"simple\", too, around triangular\nworkflows. Describing it in detail would probably be too verbose in this\nmessage, but we do refer to the description of push.default, which is\nprobably enough.  Technically this new bit you are adding here is\ncovered there, too. But since we can improve the description by adding\nsuch a small amount of text in this case, it seems like a reasonable\ntradeoff.\n\nI suppose we could also customize the message based on the triangular\nand non-triangular cases. I dunno.\n\n-Peff\n"},{"id":"252756","messageId":"xmqqmw78rty7.fsf@gitster.dls.corp.google.com","threadId":"38060","inReplyTo":"20141128045518.GB19456@peff.net","subject":"Re: 'simple' push check that branch name matches does not work if push.default is unset (and hence implicitly simple)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2014-12-01T02:21:20Z","receivedAt":"2014-12-01T02:21:20Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> There is some other magic with \"simple\", too, around triangular\n> workflows. Describing it in detail would probably be too verbose in this\n> message, but we do refer to the description of push.default, which is\n> probably enough.  Technically this new bit you are adding here is\n> covered there, too. But since we can improve the description by adding\n> such a small amount of text in this case, it seems like a reasonable\n> tradeoff.\n>\n> I suppose we could also customize the message based on the triangular\n> and non-triangular cases. I dunno.\n\nYeah, I vaguely recall suggesting to polish advice message further\nto help users along a similar line, but probably that fell in the\ncracks.\n\nThanks for a quick fix.\n"}]}