{"thread":{"id":"25730","subject":"[BUG] git show <remote>: bad information: Local branch|ref configured","startedAt":"2010-11-13T00:41:39Z","lastAt":"2010-11-13T04:46:56Z","messageCount":4,"participants":["Seth Robertson","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"155810","messageId":"201011130041.oAD0fdmM017083@no.baka.org","threadId":"25730","inReplyTo":null,"subject":"[BUG] git show <remote>: bad information: Local branch|ref configured","fromName":"Seth Robertson","fromEmail":"in-gitvger@baka.org","sentAt":"2010-11-13T00:41:39Z","receivedAt":"2010-11-13T00:41:39Z","isPatch":false,"sender":{"key":"in-gitvger@baka.org","avatar":null},"body":"\nOver in #git we ran into a user wondering why a particular remote said\nsomething about \"master pushes to master\" when the local branch mapped\nto that remote was not named master.\n\nNot having inspected the code, it certainly appears as if the \"Local\nbranch configured\" and \"Local ref configured\" information is only\naccidentally correct, but since the normal configuration is the case\nin which it is accurate, no-one noticed the problem.\n\nIn the test case below, in the \"bar\" case we are missing the \"Local\nref configured for 'git push'\" section entirely.  Strange since git push\ndoes indeed work.\n\nIn the \"baz\" case we see the message and master does push to master.\n\nIn the \"biff\" case we see the confluence of the two previous cases.\nThe \"foo\" remote/subcase shows what we might expect, but the \"baz\"\nremote/subcase shows the 'Local ref configured' information is a lie.\nFinally, the \"bar\" remote/subcase shows that even the \"Local branch\nconfigured\" information is somehow magic based on the remote branch\nbeing named master.\n\nThis test was done using git 1.7.3.1\n\nTest case prep\n----------------------------------------------------------------------\nmkdir foo; cd foo; git init; echo A>A; git add A; git commit -m A;\ngit checkout -b other; echo B>B; git add B; git commit -m B;\ngit checkout master\n\nmkdir ../bar; cd ../bar; git init; git remote add foo ../foo;\ngit fetch foo; git checkout --track -b foo_master foo/other\n\nmkdir ../baz; cd ../baz; git init; git remote add foo ../foo;\ngit fetch foo; git checkout --track -b master foo/master\n\nmkdir ../biff; cd ../biff; git init; git remote add foo ../foo;\ngit fetch foo; git checkout --track -b master foo/master;\ngit remote add baz ../baz; git fetch baz;\ngit checkout --track -b baz_master baz/master\ngit remote add bar ../bar; git fetch bar;\ngit checkout --track -b bar_master bar/master\n----------------------------------------------------------------------\n\ncd ../bar; git remote show foo\n --------------------------------------------------\n * remote foo\n   Fetch URL: ../foo\n   Push  URL: ../foo\n   HEAD branch: master\n   Remote branches:\n     master tracked\n     other  tracked\n   Local branch configured for 'git pull':\n     foo_master merges with remote other\n --------------------------------------------------\n\ncd ../baz; git remote show foo\n --------------------------------------------------\n * remote foo\n   Fetch URL: ../foo\n   Push  URL: ../foo\n   HEAD branch: master\n   Remote branches:\n     master tracked\n     other  tracked\n   Local branch configured for 'git pull':\n     master merges with remote master\n   Local ref configured for 'git push':\n     master pushes to master (up to date)\n --------------------------------------------------\n\ncd ../biff; git remote show foo; git remote show baz; git remote show bar\n --------------------------------------------------\n * remote foo\n   Fetch URL: ../foo\n   Push  URL: ../foo\n   HEAD branch: master\n   Remote branches:\n     master tracked\n     other  tracked\n   Local branch configured for 'git pull':\n     master merges with remote master\n   Local ref configured for 'git push':\n     master pushes to master (up to date)\n * remote baz\n   Fetch URL: ../baz\n   Push  URL: ../baz\n   HEAD branch: master\n   Remote branch:\n     master tracked\n   Local branch configured for 'git pull':\n     baz_master merges with remote master\n   Local ref configured for 'git push':\n     master pushes to master (up to date)\n * remote bar\n   Fetch URL: ../bar\n   Push  URL: ../bar\n   HEAD branch: foo_master\n   Remote branch:\n     foo_master tracked\n --------------------------------------------------\n\n\t\t\t\t\t-Seth Robertson\n"},{"id":"155814","messageId":"20101113010934.GA4017@burratino","threadId":"25730","inReplyTo":"201011130041.oAD0fdmM017083@no.baka.org","subject":"Re: [BUG] git show <remote>: bad information: Local branch|ref configured","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-13T01:09:34Z","receivedAt":"2010-11-13T01:09:34Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"On Fri, Nov 12, 2010 at 07:41:39PM -0500, Seth Robertson wrote:\n\n> Not having inspected the code, it certainly appears as if the \"Local\n> branch configured\" and \"Local ref configured\" information is only\n> accidentally correct, but since the normal configuration is the case\n> in which it is accurate, no-one noticed the problem.\n\nFunny. :)  But no, lots of people set up local branches as downstream\nto no branch or to some distinct remote branch.  So first I guess it\nmight be useful to explain the \"push matching\" behavior.\n\nBackground: suppose the upstream repository has three branches:\n\n\tmaster\n\tnext\n\ttopic/better-frotz\n\nNow I have an idea for a new feature, so I do\n\n\tgit checkout -b topic/xyzzy origin/master\n\nwhich forks a new branch set up to pull from master.\n\nNow I go about usual work, making changes to master, next,\ntopic/better-frotz, and so on, and at the end I am on my private\ntopic/xyzzy branch.  Everything looks good, so it is time to push:\n\n\tgit push origin\n\nThis is a shortcut for\n\n\tgit push origin :\n\nwhich pushes all local branches for which an upstream branch with the\nsame name exists.\n\n\"Wait!\" you might ask.  \"Why push all branches?\"\n\nIt is partly historical.  A lot of people have public repositories\nwith multiple branches, and this is a behavior that has been found to\nbe very convenient for that.\n\n\"Why only branches for which an upstream branch exists?\"\n\nSome work might be private.  If you actually want to push everything,\nuse \"git push --mirror\".\n\n\"Why branches with the same name?  Why not to the branch each branch\npulls from?\"\n\nEach branch forked from master does not necessarily contain changes\nthat are suitable for inclusion in master immediately.  In general,\nthe upstream for each branch is often more stable rather than\nequally stable to it, so automatic pushing upstream does not always\nmake sense.\n\nHowever, if you want the push-to-where-you-pull-from behavior,\njust add\n\n\t[push]\n\t\tdefault = tracking\n\nto your ~/.gitconfig.\n\nSee the documentation for branch.<name>.merge in git-config(1) for\ndetails on that.\n\nFor your test example: rather than sample output, could you describe\nnext to each command what you expect to happen and how that differs\nfrom what happens instead?  This would make it easier to find the\nlurking bugs.\n\nHope that helps,\nJonathan\n"},{"id":"155816","messageId":"201011130144.oAD1iBeK022905@no.baka.org","threadId":"25730","inReplyTo":"20101113010934.GA4017@burratino","subject":"Re: [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking","fromName":"Seth Robertson","fromEmail":"in-gitvger@baka.org","sentAt":"2010-11-13T01:44:11Z","receivedAt":"2010-11-13T01:44:11Z","isPatch":false,"sender":{"key":"in-gitvger@baka.org","avatar":null},"body":"\nIn message <20101113010934.GA4017@burratino>, Jonathan Nieder writes:\n\n    On Fri, Nov 12, 2010 at 07:41:39PM -0500, Seth Robertson wrote:\n\n    > Not having inspected the code, it certainly appears as if the \"Local\n    > branch configured\" and \"Local ref configured\" information is only\n    > accidentally correct, but since the normal configuration is the case\n    > in which it is accurate, no-one noticed the problem.\n\n    However, if you want the push-to-where-you-pull-from behavior,\n    just add\n\t    [push]\n\t\t    default = tracking\n    to your ~/.gitconfig.\n\nI already had this turned on in my ~/.gitconfig.  However, you bring\nup a good point, the output as shown would be correct if the default\n\"matching\" value was used.  Thus I guess the bug summary needs to be:\n\ngit show <remote> produces inaccurate information about \"Local ref\nconfigured\" if git-config's push.default==tracking\n\n    For your test example: rather than sample output, could you describe\n    next to each command what you expect to happen and how that differs\n    from what happens instead?  This would make it easier to find the\n    lurking bugs.\n\nIn my example, I set up each remote identically and only varied the\nname of the branch.  In all cases, you could push and pull changes\nusing `git pull` and `git push`, meaning that they were properly\nconfigured tracking branches.  Thus, I argue that they should produce\ninformation for \"Local ref configured\" in each case, and furthermore\nthat the named refs should be appropriate for the mapping in question.\n\nI'll annotate the output below with my desired behavior.  Search for\n\"^**\" in the output below.\n\nIn other news, the last argument of the last command of the Test case\nprep should have been bar/foo_master instead of bar/master.  This\naffects the \"git remote show bar\" subcase output, showing that the\n\"Local branch configured\" information is correct.  The \"Local ref\nconfigured\" information remains incorrect/obscure.  I updated the test\ncase to include the push.default=tracking configuration.\n\n\t\t\t\t\t-Seth Robertson\n\n\n----------------------------------------------------------------------\nmkdir foo; cd foo; git init; echo A>A; git add A; git commit -m A;\ngit checkout -b other; echo B>B; git add B; git commit -m B;\ngit checkout master; git config push.default tracking\n\nmkdir ../bar; cd ../bar; git init; git remote add foo ../foo;\ngit fetch foo; git checkout --track -b foo_master foo/other\ngit config push.default tracking\n\nmkdir ../baz; cd ../baz; git init; git remote add foo ../foo;\ngit fetch foo; git checkout --track -b master foo/master\ngit config push.default tracking\n\nmkdir ../biff; cd ../biff; git init; git remote add foo ../foo;\ngit fetch foo; git checkout --track -b master foo/master;\ngit remote add baz ../baz; git fetch baz;\ngit checkout --track -b baz_master baz/master\ngit remote add bar ../bar; git fetch bar;\ngit checkout --track -b bar_master bar/foo_master\ngit config push.default tracking\n----------------------------------------------------------------------\n\ncd ../bar; git remote show foo\n --------------------------------------------------\n * remote foo\n   Fetch URL: ../foo\n   Push  URL: ../foo\n   HEAD branch: master\n   Remote branches:\n     master tracked\n     other  tracked\n   Local branch configured for 'git pull':\n     foo_master merges with remote other\n --------------------------------------------------\n** DESIRED ADDITION **\n --------------------------------------------------\n   Local ref configured for 'git push':\n     foo_master pushes to other (up to date)\n --------------------------------------------------\n\ncd ../baz; git remote show foo\n --------------------------------------------------\n * remote foo\n   Fetch URL: ../foo\n   Push  URL: ../foo\n   HEAD branch: master\n   Remote branches:\n     master tracked\n     other  tracked\n   Local branch configured for 'git pull':\n     master merges with remote master\n   Local ref configured for 'git push':\n     master pushes to master (up to date)\n --------------------------------------------------\n** OUTPUT CORRECT **\n\ncd ../biff; git remote show foo\n --------------------------------------------------\n * remote foo\n   Fetch URL: ../foo\n   Push  URL: ../foo\n   HEAD branch: master\n   Remote branches:\n     master tracked\n     other  tracked\n   Local branch configured for 'git pull':\n     master merges with remote master\n   Local ref configured for 'git push':\n     master pushes to master (up to date)\n --------------------------------------------------\n** OUTPUT CORRECT **\n\ncd ../biff; git remote show baz\n --------------------------------------------------\n * remote baz\n   Fetch URL: ../baz\n   Push  URL: ../baz\n   HEAD branch: master\n   Remote branch:\n     master tracked\n   Local branch configured for 'git pull':\n     baz_master merges with remote master\n   Local ref configured for 'git push':\n     master pushes to master (up to date)\n --------------------------------------------------\n** CORRECTED LAST TWO LINES **\n --------------------------------------------------\n   Local ref configured for 'git push':\n     baz_master pushes to master (up to date)\n --------------------------------------------------\n\ncd ../biff; git remote show bar\n --------------------------------------------------\n * remote bar\n   Fetch URL: ../bar\n   Push  URL: ../bar\n   HEAD branch: foo_master\n   Remote branch:\n     foo_master tracked\n   Local branch configured for 'git pull':\n     bar_master merges with remote foo_master\n --------------------------------------------------\n** DESIRED ADDITION **\n --------------------------------------------------\n   Local ref configured for 'git push':\n     bar_master pushes to foo_master (up to date)\n --------------------------------------------------\n"},{"id":"155820","messageId":"20101113044656.GA7934@burratino","threadId":"25730","inReplyTo":"201011130144.oAD1iBeK022905@no.baka.org","subject":"Re: [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-11-13T04:46:56Z","receivedAt":"2010-11-13T04:46:56Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Seth Robertson wrote:\n\n> I already had this turned on in my ~/.gitconfig.  However, you bring\n> up a good point, the output as shown would be correct if the default\n> \"matching\" value was used.\n\nYep, the get_push_ref_states() function used by \"git remote show\"\nwasn't updated when the \"[push] default\" configuration item was\nintroduced.\n\n>     For your test example: rather than sample output, could you\n\nSorry to make busy work.  Your examples still would useful as a\ntest script for anyone who wants to fix this.\n\nThanks again for the report.\n\nRegards,\nJonathan\n"}]}