* [BUG] git show <remote>: bad information: Local branch|ref configured @ 2010-11-13 0:41 Seth Robertson 2010-11-13 1:09 ` Jonathan Nieder 0 siblings, 1 reply; 4+ messages in thread From: Seth Robertson @ 2010-11-13 0:41 UTC (permalink / raw) To: git Over in #git we ran into a user wondering why a particular remote said something about "master pushes to master" when the local branch mapped to that remote was not named master. Not having inspected the code, it certainly appears as if the "Local branch configured" and "Local ref configured" information is only accidentally correct, but since the normal configuration is the case in which it is accurate, no-one noticed the problem. In the test case below, in the "bar" case we are missing the "Local ref configured for 'git push'" section entirely. Strange since git push does indeed work. In the "baz" case we see the message and master does push to master. In the "biff" case we see the confluence of the two previous cases. The "foo" remote/subcase shows what we might expect, but the "baz" remote/subcase shows the 'Local ref configured' information is a lie. Finally, the "bar" remote/subcase shows that even the "Local branch configured" information is somehow magic based on the remote branch being named master. This test was done using git 1.7.3.1 Test case prep ---------------------------------------------------------------------- mkdir foo; cd foo; git init; echo A>A; git add A; git commit -m A; git checkout -b other; echo B>B; git add B; git commit -m B; git checkout master mkdir ../bar; cd ../bar; git init; git remote add foo ../foo; git fetch foo; git checkout --track -b foo_master foo/other mkdir ../baz; cd ../baz; git init; git remote add foo ../foo; git fetch foo; git checkout --track -b master foo/master mkdir ../biff; cd ../biff; git init; git remote add foo ../foo; git fetch foo; git checkout --track -b master foo/master; git remote add baz ../baz; git fetch baz; git checkout --track -b baz_master baz/master git remote add bar ../bar; git fetch bar; git checkout --track -b bar_master bar/master ---------------------------------------------------------------------- cd ../bar; git remote show foo -------------------------------------------------- * remote foo Fetch URL: ../foo Push URL: ../foo HEAD branch: master Remote branches: master tracked other tracked Local branch configured for 'git pull': foo_master merges with remote other -------------------------------------------------- cd ../baz; git remote show foo -------------------------------------------------- * remote foo Fetch URL: ../foo Push URL: ../foo HEAD branch: master Remote branches: master tracked other tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) -------------------------------------------------- cd ../biff; git remote show foo; git remote show baz; git remote show bar -------------------------------------------------- * remote foo Fetch URL: ../foo Push URL: ../foo HEAD branch: master Remote branches: master tracked other tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) * remote baz Fetch URL: ../baz Push URL: ../baz HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': baz_master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) * remote bar Fetch URL: ../bar Push URL: ../bar HEAD branch: foo_master Remote branch: foo_master tracked -------------------------------------------------- -Seth Robertson ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] git show <remote>: bad information: Local branch|ref configured 2010-11-13 0:41 [BUG] git show <remote>: bad information: Local branch|ref configured Seth Robertson @ 2010-11-13 1:09 ` Jonathan Nieder 2010-11-13 1:44 ` [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking Seth Robertson 0 siblings, 1 reply; 4+ messages in thread From: Jonathan Nieder @ 2010-11-13 1:09 UTC (permalink / raw) To: Seth Robertson; +Cc: git On Fri, Nov 12, 2010 at 07:41:39PM -0500, Seth Robertson wrote: > Not having inspected the code, it certainly appears as if the "Local > branch configured" and "Local ref configured" information is only > accidentally correct, but since the normal configuration is the case > in which it is accurate, no-one noticed the problem. Funny. :) But no, lots of people set up local branches as downstream to no branch or to some distinct remote branch. So first I guess it might be useful to explain the "push matching" behavior. Background: suppose the upstream repository has three branches: master next topic/better-frotz Now I have an idea for a new feature, so I do git checkout -b topic/xyzzy origin/master which forks a new branch set up to pull from master. Now I go about usual work, making changes to master, next, topic/better-frotz, and so on, and at the end I am on my private topic/xyzzy branch. Everything looks good, so it is time to push: git push origin This is a shortcut for git push origin : which pushes all local branches for which an upstream branch with the same name exists. "Wait!" you might ask. "Why push all branches?" It is partly historical. A lot of people have public repositories with multiple branches, and this is a behavior that has been found to be very convenient for that. "Why only branches for which an upstream branch exists?" Some work might be private. If you actually want to push everything, use "git push --mirror". "Why branches with the same name? Why not to the branch each branch pulls from?" Each branch forked from master does not necessarily contain changes that are suitable for inclusion in master immediately. In general, the upstream for each branch is often more stable rather than equally stable to it, so automatic pushing upstream does not always make sense. However, if you want the push-to-where-you-pull-from behavior, just add [push] default = tracking to your ~/.gitconfig. See the documentation for branch.<name>.merge in git-config(1) for details on that. For your test example: rather than sample output, could you describe next to each command what you expect to happen and how that differs from what happens instead? This would make it easier to find the lurking bugs. Hope that helps, Jonathan ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking 2010-11-13 1:09 ` Jonathan Nieder @ 2010-11-13 1:44 ` Seth Robertson 2010-11-13 4:46 ` Jonathan Nieder 0 siblings, 1 reply; 4+ messages in thread From: Seth Robertson @ 2010-11-13 1:44 UTC (permalink / raw) To: Jonathan Nieder; +Cc: git In message <20101113010934.GA4017@burratino>, Jonathan Nieder writes: On Fri, Nov 12, 2010 at 07:41:39PM -0500, Seth Robertson wrote: > Not having inspected the code, it certainly appears as if the "Local > branch configured" and "Local ref configured" information is only > accidentally correct, but since the normal configuration is the case > in which it is accurate, no-one noticed the problem. However, if you want the push-to-where-you-pull-from behavior, just add [push] default = tracking to your ~/.gitconfig. I already had this turned on in my ~/.gitconfig. However, you bring up a good point, the output as shown would be correct if the default "matching" value was used. Thus I guess the bug summary needs to be: git show <remote> produces inaccurate information about "Local ref configured" if git-config's push.default==tracking For your test example: rather than sample output, could you describe next to each command what you expect to happen and how that differs from what happens instead? This would make it easier to find the lurking bugs. In my example, I set up each remote identically and only varied the name of the branch. In all cases, you could push and pull changes using `git pull` and `git push`, meaning that they were properly configured tracking branches. Thus, I argue that they should produce information for "Local ref configured" in each case, and furthermore that the named refs should be appropriate for the mapping in question. I'll annotate the output below with my desired behavior. Search for "^**" in the output below. In other news, the last argument of the last command of the Test case prep should have been bar/foo_master instead of bar/master. This affects the "git remote show bar" subcase output, showing that the "Local branch configured" information is correct. The "Local ref configured" information remains incorrect/obscure. I updated the test case to include the push.default=tracking configuration. -Seth Robertson ---------------------------------------------------------------------- mkdir foo; cd foo; git init; echo A>A; git add A; git commit -m A; git checkout -b other; echo B>B; git add B; git commit -m B; git checkout master; git config push.default tracking mkdir ../bar; cd ../bar; git init; git remote add foo ../foo; git fetch foo; git checkout --track -b foo_master foo/other git config push.default tracking mkdir ../baz; cd ../baz; git init; git remote add foo ../foo; git fetch foo; git checkout --track -b master foo/master git config push.default tracking mkdir ../biff; cd ../biff; git init; git remote add foo ../foo; git fetch foo; git checkout --track -b master foo/master; git remote add baz ../baz; git fetch baz; git checkout --track -b baz_master baz/master git remote add bar ../bar; git fetch bar; git checkout --track -b bar_master bar/foo_master git config push.default tracking ---------------------------------------------------------------------- cd ../bar; git remote show foo -------------------------------------------------- * remote foo Fetch URL: ../foo Push URL: ../foo HEAD branch: master Remote branches: master tracked other tracked Local branch configured for 'git pull': foo_master merges with remote other -------------------------------------------------- ** DESIRED ADDITION ** -------------------------------------------------- Local ref configured for 'git push': foo_master pushes to other (up to date) -------------------------------------------------- cd ../baz; git remote show foo -------------------------------------------------- * remote foo Fetch URL: ../foo Push URL: ../foo HEAD branch: master Remote branches: master tracked other tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) -------------------------------------------------- ** OUTPUT CORRECT ** cd ../biff; git remote show foo -------------------------------------------------- * remote foo Fetch URL: ../foo Push URL: ../foo HEAD branch: master Remote branches: master tracked other tracked Local branch configured for 'git pull': master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) -------------------------------------------------- ** OUTPUT CORRECT ** cd ../biff; git remote show baz -------------------------------------------------- * remote baz Fetch URL: ../baz Push URL: ../baz HEAD branch: master Remote branch: master tracked Local branch configured for 'git pull': baz_master merges with remote master Local ref configured for 'git push': master pushes to master (up to date) -------------------------------------------------- ** CORRECTED LAST TWO LINES ** -------------------------------------------------- Local ref configured for 'git push': baz_master pushes to master (up to date) -------------------------------------------------- cd ../biff; git remote show bar -------------------------------------------------- * remote bar Fetch URL: ../bar Push URL: ../bar HEAD branch: foo_master Remote branch: foo_master tracked Local branch configured for 'git pull': bar_master merges with remote foo_master -------------------------------------------------- ** DESIRED ADDITION ** -------------------------------------------------- Local ref configured for 'git push': bar_master pushes to foo_master (up to date) -------------------------------------------------- ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking 2010-11-13 1:44 ` [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking Seth Robertson @ 2010-11-13 4:46 ` Jonathan Nieder 0 siblings, 0 replies; 4+ messages in thread From: Jonathan Nieder @ 2010-11-13 4:46 UTC (permalink / raw) To: Seth Robertson; +Cc: git, Finn Arne Gangstad, Michael J Gruber Seth Robertson wrote: > I already had this turned on in my ~/.gitconfig. However, you bring > up a good point, the output as shown would be correct if the default > "matching" value was used. Yep, the get_push_ref_states() function used by "git remote show" wasn't updated when the "[push] default" configuration item was introduced. > For your test example: rather than sample output, could you Sorry to make busy work. Your examples still would useful as a test script for anyone who wants to fix this. Thanks again for the report. Regards, Jonathan ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-11-13 4:47 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-11-13 0:41 [BUG] git show <remote>: bad information: Local branch|ref configured Seth Robertson 2010-11-13 1:09 ` Jonathan Nieder 2010-11-13 1:44 ` [BUG] git show <remote>: bad information: Local ref configured if push.default=tracking Seth Robertson 2010-11-13 4:46 ` Jonathan Nieder
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).