{"thread":{"id":"40175","subject":"[RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","startedAt":"2015-08-25T17:45:21Z","lastAt":"2015-08-26T09:02:18Z","messageCount":6,"participants":["Karthik Nayak","Junio C Hamano","Matthieu Moy"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"268670","messageId":"CAOLa=ZRpMsFr2p=X+Z7z95W+0wGd9i5XaSDeVSmS-BUFCj6dWw@mail.gmail.com","threadId":"40175","inReplyTo":null,"subject":"[RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-08-25T17:45:21Z","receivedAt":"2015-08-25T17:45:21Z","isPatch":false,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"I'm working on porting over the printing options of ref-filter to `git\nbranch -l`.\nThis is a follow up to\nhttp://article.gmane.org/gmane.comp.version-control.git/276377\n\nTheres a slight issue with this which I'd like to discuss about.\n\nWhen we use `-a` option in `git branch -l`\nIt lists local branches and remotes with each having a different output format.\nThis with reference to ref-filter would mean either\n\n1. Change format in between local and remote refs\n2. Have a format like %(if)...local check....%(then)....local branch\nformat....%(else)....remote format %(end).\n\nI prefer the latter, but that might lead to a large format. Any suggestions?\n\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"268677","messageId":"xmqq4mjnyzfy.fsf@gitster.dls.corp.google.com","threadId":"40175","inReplyTo":"CAOLa=ZRpMsFr2p=X+Z7z95W+0wGd9i5XaSDeVSmS-BUFCj6dWw@mail.gmail.com","subject":"Re: [RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-25T18:50:57Z","receivedAt":"2015-08-25T18:50:57Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> I'm working on porting over the printing options of ref-filter to `git\n> branch -l`.\n> This is a follow up to\n> http://article.gmane.org/gmane.comp.version-control.git/276377\n>\n> Theres a slight issue with this which I'd like to discuss about.\n>\n> When we use `-a` option in `git branch -l`\n> It lists local branches and remotes with each having a different output format.\n> This with reference to ref-filter would mean either\n>\n> 1. Change format in between local and remote refs\n\nI thought the end result of consolidation would be for for-each-ref,\nbranch -l, and tag -l to be \"first collect what to show, and then\nshow them according to a single format given\".  How could it be\npossible to switch format?  It's not even like each element collected\nin the first phase is marked so that the second \"display\" phase know\nwhich one is which.\n\n> 2. Have a format like %(if)...local check....%(then)....local branch\n> format....%(else)....remote format %(end).\n\nThat, if we had a working if/then/else/end, would be a good\ndemonstration of it.  \n\nIf this were only for internal use by \"branch -l\", it might be\noverkill, but the end users with for-each-ref --format options would\nwant to do the same thing as built-in patterns, so it is a good goal\nto aim at.\n\n> I prefer the latter, but that might lead to a large format. Any suggestions?\n\nA less ambitious option might be:\n\n  3. Invent \"%(refname:<some magic>)\" format similar to\n     %(refname:short) but does your thing depending on the prefix\n     refs/heads/ and refs/remotes/.\n\nbut that will not work if the difference between local and remote\nformat is not merely textual (e.g. paint them in different color).\n"},{"id":"268685","messageId":"vpqvbc3t9no.fsf@anie.imag.fr","threadId":"40175","inReplyTo":"xmqq4mjnyzfy.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-08-25T20:06:51Z","receivedAt":"2015-08-25T20:06:51Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> A less ambitious option might be:\n>\n>   3. Invent \"%(refname:<some magic>)\" format similar to\n>      %(refname:short) but does your thing depending on the prefix\n>      refs/heads/ and refs/remotes/.\n\nActually, this is the option I suggest offline.\n\n> but that will not work if the difference between local and remote\n> format is not merely textual (e.g. paint them in different color).\n\nHmm, yes, colors would be difficult to get with this solution. Perhaps a\n%(refname:autoprefix,autocolor) that would pick the color and do the\ntextual rendering?\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"268691","messageId":"xmqqbndvxfgl.fsf@gitster.dls.corp.google.com","threadId":"40175","inReplyTo":"vpqvbc3t9no.fsf@anie.imag.fr","subject":"Re: [RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2015-08-25T20:47:54Z","receivedAt":"2015-08-25T20:47:54Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> writes:\n\n> Hmm, yes, colors would be difficult to get with this solution. Perhaps a\n> %(refname:autoprefix,autocolor) that would pick the color and do the\n> textual rendering?\n\nYeah, that's workable.\n"},{"id":"268718","messageId":"CAOLa=ZRZpy8_KGNZL1TahEkOOdQ35e1168pwuCpkxbogRDXNnw@mail.gmail.com","threadId":"40175","inReplyTo":"xmqq4mjnyzfy.fsf@gitster.dls.corp.google.com","subject":"Re: [RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2015-08-26T06:39:45Z","receivedAt":"2015-08-26T06:39:45Z","isPatch":false,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"On Wed, Aug 26, 2015 at 12:20 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Karthik Nayak <karthik.188@gmail.com> writes:\n>\n>> I'm working on porting over the printing options of ref-filter to `git\n>> branch -l`.\n>> This is a follow up to\n>> http://article.gmane.org/gmane.comp.version-control.git/276377\n>>\n>> Theres a slight issue with this which I'd like to discuss about.\n>>\n>> When we use `-a` option in `git branch -l`\n>> It lists local branches and remotes with each having a different output format.\n>> This with reference to ref-filter would mean either\n>>\n>> 1. Change format in between local and remote refs\n>\n> I thought the end result of consolidation would be for for-each-ref,\n> branch -l, and tag -l to be \"first collect what to show, and then\n> show them according to a single format given\".  How could it be\n> possible to switch format?  It's not even like each element collected\n> in the first phase is marked so that the second \"display\" phase know\n> which one is which.\n>\n\nAbsolutely right! Currently this is not even possible, It was just a shot in the\ndark. I was just shooting out possibilities I could think of :)\n\n>> 2. Have a format like %(if)...local check....%(then)....local branch\n>> format....%(else)....remote format %(end).\n>\n> That, if we had a working if/then/else/end, would be a good\n> demonstration of it.\n>\n> If this were only for internal use by \"branch -l\", it might be\n> overkill, but the end users with for-each-ref --format options would\n> want to do the same thing as built-in patterns, so it is a good goal\n> to aim at.\n>\n\nI have a version of that running in my local repo, I'll probably\npost a WIP soon, when I get this done.\n\n>> I prefer the latter, but that might lead to a large format. Any suggestions?\n>\n> A less ambitious option might be:\n>\n>   3. Invent \"%(refname:<some magic>)\" format similar to\n>      %(refname:short) but does your thing depending on the prefix\n>      refs/heads/ and refs/remotes/.\n>\n> but that will not work if the difference between local and remote\n> format is not merely textual (e.g. paint them in different color).\n\nIt's more than just colors. The whole format changes.\n\n$ git branch -a\nFor local:\n\"%(if)%(HEAD)%(then)%(HEAD) %(color:green)%(refname:short)%(else)\n%(refname:short)%(end)\"\nFor remote:\n\"  remotes/%(color:red)%(refname:short)%(color:reset)%(if)%(symref)%(then)\n-> %(symref:short)%(end)\"\n\n\n\nOn Wed, Aug 26, 2015 at 1:36 AM, Matthieu Moy\n<Matthieu.Moy@grenoble-inp.fr> wrote:\n>\n> Hmm, yes, colors would be difficult to get with this solution. Perhaps a\n> %(refname:autoprefix,autocolor) that would pick the color and do the\n> textual rendering?\n>\n\nThat sounds, good, probably could work on something of this sort.\n\n-- \nRegards,\nKarthik Nayak\n"},{"id":"268720","messageId":"vpqlhcyqv6t.fsf@anie.imag.fr","threadId":"40175","inReplyTo":"CAOLa=ZRZpy8_KGNZL1TahEkOOdQ35e1168pwuCpkxbogRDXNnw@mail.gmail.com","subject":"Re: [RFC] Porting builtin/branch.c to use the printing options of ref-filter.{c,h}","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2015-08-26T09:02:18Z","receivedAt":"2015-08-26T09:02:18Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> It's more than just colors. The whole format changes.\n>\n> $ git branch -a\n> For local:\n> \"%(if)%(HEAD)%(then)%(HEAD) %(color:green)%(refname:short)%(else)\n> %(refname:short)%(end)\"\n> For remote:\n> \"  remotes/%(color:red)%(refname:short)%(color:reset)%(if)%(symref)%(then)\n> -> %(symref:short)%(end)\"\n\nI think both versions are not so different. You have %(if) on one format\nstrings that would be disabled by construction on the second. For\nexample, adding %(if)%(HEAD)%(then)%(HEAD) at the start of the\nformat-string for remotes would be a no-op, right?\n\nAnd in case a local branch is a symref, \"git branch\" displays \"-> ...\"\nboth for local and for remotes. You just normally don't have local\nsymref branches other than HEAD, but I tried:\n\n$ git checkout -b branch\n$ cat .git/HEAD > .git/refs/heads/symref\n$ git branch -a\n* branch\n  master\n  symref -> branch\n\nThe only remaining difference I see are the \"remotes/\" prefix and\ncolors.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}