{"thread":{"id":"19827","subject":"branch.<branch>.merge and --format='%(upstream)'","startedAt":"2009-06-16T11:08:02Z","lastAt":"2009-06-16T22:34:07Z","messageCount":5,"participants":["Santi Béjar","Jeff King","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"116401","messageId":"adf1fd3d0906160408s668f7a3fj5725cc4e98b317fc@mail.gmail.com","threadId":"19827","inReplyTo":null,"subject":"branch.<branch>.merge and --format='%(upstream)'","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-16T11:08:02Z","receivedAt":"2009-06-16T11:08:02Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"Hi,\n\n  I've noticed that having branch.<branch>.merge set with the branch\nname, and not with the full ref, cause problems with\n--format='%(upstream)'  and also with the \"branch -av\" and \"git\nstatus\" upstream branch outputs. But git-fetch and git-pull works ok,\nso it is a valid setting.\n\n$ git clone git.git\n$ cd git\n$ git config branch.master.merge\nrefs/heads/master\n$ git for-each-ref --format='%(upstream)' refs/heads/master\nrefs/remotes/origin/master\n$ git config branch.master.merge master\n$ git config branch.master.merge\nmaster\n$ git for-each-ref --format='%(upstream)' refs/heads/master\n\n$\n\nBest regards,\nSanti\n"},{"id":"116409","messageId":"20090616122312.GB5227@coredump.intra.peff.net","threadId":"19827","inReplyTo":"adf1fd3d0906160408s668f7a3fj5725cc4e98b317fc@mail.gmail.com","subject":"Re: branch.<branch>.merge and --format='%(upstream)'","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-06-16T12:23:12Z","receivedAt":"2009-06-16T12:23:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jun 16, 2009 at 01:08:02PM +0200, Santi Béjar wrote:\n\n>   I've noticed that having branch.<branch>.merge set with the branch\n> name, and not with the full ref, cause problems with\n> --format='%(upstream)'  and also with the \"branch -av\" and \"git\n> status\" upstream branch outputs. But git-fetch and git-pull works ok,\n> so it is a valid setting.\n\nActually, it is broken in a lot of places. for-each-ref relies on the\nsame code as \"git status\", \"git checkout\", etc, which will all fail to\ndisplay tracking info. I believe the same code is also used for updating\ntracking branches on push. So I'm not sure if it was ever intended to be\na valid setting.\n\nFixing it would involve tweaks to remote_find_tracking, I think, but I\nhaven't looked into it too closely.\n\nI'm not sure of the impliciations of allowing non-qualified refs in that\nconfig. Will we detect and warn about ambiguities? Does it actually work\nwith non-branches?\n\n-Peff\n"},{"id":"116411","messageId":"adf1fd3d0906160707m713d9fe0l966d14c0e0af9127@mail.gmail.com","threadId":"19827","inReplyTo":"20090616122312.GB5227@coredump.intra.peff.net","subject":"Re: branch.<branch>.merge and --format='%(upstream)'","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-16T14:07:50Z","receivedAt":"2009-06-16T14:07:50Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/6/16 Jeff King <peff@peff.net>:\n> On Tue, Jun 16, 2009 at 01:08:02PM +0200, Santi Béjar wrote:\n>\n>>   I've noticed that having branch.<branch>.merge set with the branch\n>> name, and not with the full ref, cause problems with\n>> --format='%(upstream)'  and also with the \"branch -av\" and \"git\n>> status\" upstream branch outputs. But git-fetch and git-pull works ok,\n>> so it is a valid setting.\n>\n> Actually, it is broken in a lot of places. for-each-ref relies on the\n> same code as \"git status\", \"git checkout\", etc, which will all fail to\n> display tracking info. I believe the same code is also used for updating\n> tracking branches on push. So I'm not sure if it was ever intended to be\n> a valid setting.\n>\n> Fixing it would involve tweaks to remote_find_tracking, I think, but I\n> haven't looked into it too closely.\n\nIt should be interpreted as \"git pull branchname\" does, or at least as\nclose as possible.\n\nAnother non-working example is with:\n\nremote.origin.fetch=+master:refs/remotes/origin/master\nbranch.master.merge=refs/heads/master\n\nso it looks like that both have to match for remote_find_tracking to\nwork (and in this case \"git fetch\" also works ok).\n\nI suppose that remote_find_tracking should DWIM: build the full ref\nprepending refs/ and heads/, as necessary.\n\n>\n> I'm not sure of the impliciations of allowing non-qualified refs in that\n> config.\n\nThey are currently allowed (fetch/pull) since a long time, and it is\nnot only this config, but also remote.<remote>.fetch (see above).\n\nIn b888d61 (Make fetch a builtin, 2007-09-10):\n\ncommit b888d61c8308027433df9c243fa551f42db1c76a\nAuthor: Daniel Barkalow <barkalow@iabervon.org>\nDate:   Tue Sep 11 05:03:25 2007\n\n[...]\n\n    This changes a few small bits of behavior:\n\n    branch.<name>.merge is parsed as if it were the lhs of a fetch\n    refspec, and does not have to exactly match the actual lhs of a\n    refspec, so long as it is a valid abbreviation for the same ref.\n\n[...]\n\n\n> Will we detect and warn about ambiguities? Does it actually work\n> with non-branches?\n\nWith tags yes, but full qualified.\n\nSanti\n"},{"id":"116415","messageId":"7v7hzcdvvr.fsf@alter.siamese.dyndns.org","threadId":"19827","inReplyTo":"20090616122312.GB5227@coredump.intra.peff.net","subject":"Re: branch.<branch>.merge and --format='%(upstream)'","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-06-16T15:46:32Z","receivedAt":"2009-06-16T15:46:32Z","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> On Tue, Jun 16, 2009 at 01:08:02PM +0200, Santi Béjar wrote:\n>\n>>   I've noticed that having branch.<branch>.merge set with the branch\n>> name, and not with the full ref, cause problems with\n>> --format='%(upstream)'  and also with the \"branch -av\" and \"git\n>> status\" upstream branch outputs. But git-fetch and git-pull works ok,\n>> so it is a valid setting.\n>\n> Actually, it is broken in a lot of places. for-each-ref relies on the\n> same code as \"git status\", \"git checkout\", etc, which will all fail to\n> display tracking info. I believe the same code is also used for updating\n> tracking branches on push. So I'm not sure if it was ever intended to be\n> a valid setting.\n\nIt wasn't.  Some places may accept them gracefully by either being extra\nnice or by accident.\n"},{"id":"116452","messageId":"1245191647-21353-1-git-send-email-santi@agolina.net","threadId":"19827","inReplyTo":"7v7hzcdvvr.fsf@alter.siamese.dyndns.org","subject":"Re: branch.<branch>.merge and --format='%(upstream)'","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-06-16T22:34:07Z","receivedAt":"2009-06-16T22:34:07Z","isPatch":false,"sender":{"key":"santi@agolina.net","avatar":null},"body":"\n2009/6/16 Junio C Hamano <gitster@pobox.com>\n>\n> Jeff King <peff@peff.net> writes:\n>\n> > On Tue, Jun 16, 2009 at 01:08:02PM +0200, Santi BÃ©jar wrote:\n> >\n> >>   I've noticed that having branch.<branch>.merge set with the branch\n> >> name, and not with the full ref, cause problems with\n> >> --format='%(upstream)'  and also with the \"branch -av\" and \"git\n> >> status\" upstream branch outputs. But git-fetch and git-pull works ok,\n> >> so it is a valid setting.\n> >\n> > Actually, it is broken in a lot of places. for-each-ref relies on the\n> > same code as \"git status\", \"git checkout\", etc, which will all fail to\n> > display tracking info. I believe the same code is also used for updating\n> > tracking branches on push. So I'm not sure if it was ever intended to be\n> > a valid setting.\n>\n> It wasn't.  Some places may accept them gracefully by either being extra\n> nice or by accident.\n\nAnd what about the comments in my reply. And in the branch.<name>.merge\ndocs says: The value is handled like the remote part of a refspec.\n\nIn fact I found it trying to implement a patch to get the local tracking\nfor a given remote and branch. But it only works if you spell the branch with\nits full form:\n\n$ git remote tracking origin master # does not work\n$ git remote tracking origin refs/heads/master # does work\nrefs/remotes/origin/master\n\nso I thought it would be better to resolve the %(upstream) first.\n\nSo if you know how to resolve this and or the %(upstream) issue, please tell me.\n\nAnyway, here you have the WIP patch to get the tracking branch, I'm not sure\nabout the UI (or the script interface?), it is also a RFC.\n\n---8<----\nSubject: [RFC/PATCH]: Output tracking branch from remote and branch\n---\n\nHi,\n\n  as said above it is a RFC, specially for the UI, and also can anyone help\nme with the:\n\n$ git remote tracking origin master # does not work\n\ncase?\n\nThanks,\nSanti\n\nP.D: This case will be used in the \"git pull --rebase remote branch\" case.\n\n builtin-remote.c |   34 ++++++++++++++++++++++++++++++++++\n 1 files changed, 34 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin-remote.c b/builtin-remote.c\nindex 709f8a6..03bcc27 100644\n--- a/builtin-remote.c\n+++ b/builtin-remote.c\n@@ -665,6 +665,38 @@ static int remove_branches(struct string_list *branches)\n \treturn result;\n }\n \n+static int tracking(int argc, const char **argv)\n+{\n+\tstruct option options[] = {\n+\t\tOPT_END()\n+\t};\n+\tstruct remote *remote;\n+\tstatic const char **refs = NULL;\n+\tint ref_nr = 0;\n+\tint i = 0;\n+\tstruct refspec *refspec;\n+\n+\tif (argc < 3)\n+\t\tusage_with_options(builtin_remote_usage, options);\n+\tremote = remote_get(argv[1]);\n+\tif (!remote)\n+\t\tdie(\"No such remote: %s\", argv[1]);\n+\trefs = xcalloc(argc + 1, sizeof(const char *));\n+\tfor (i = 2; i < argc; i++) {\n+\t\trefs[ref_nr++] = argv[i];\n+\t}\n+\trefs[ref_nr] = NULL;\n+\tmemset(&refspec, 0, sizeof(*refspec));\n+\trefspec = parse_fetch_refspec(ref_nr, refs);\n+\tfor (i = 0; i < ref_nr ; i++) {\n+\t\tif (!remote_find_tracking(remote, &refspec[i]))\n+\t\t\tprintf(\"%s\\n\", refspec[i].dst);\n+\t\telse\n+\t\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\n+\n static int rm(int argc, const char **argv)\n {\n \tstruct option options[] = {\n@@ -1348,6 +1380,8 @@ int cmd_remote(int argc, const char **argv, const char *prefix)\n \t\tresult = show_all();\n \telse if (!strcmp(argv[0], \"add\"))\n \t\tresult = add(argc, argv);\n+\telse if (!strcmp(argv[0], \"tracking\"))\n+\t\tresult = tracking(argc, argv);\n \telse if (!strcmp(argv[0], \"rename\"))\n \t\tresult = mv(argc, argv);\n \telse if (!strcmp(argv[0], \"rm\"))\n-- \n1.6.3.2.406.gd6a466\n"}]}