{"thread":{"id":"17686","subject":"[PATCH] builtin-branch: highlight current remote branches with an asterisk","startedAt":"2009-02-09T23:32:06Z","lastAt":"2009-02-10T13:04:16Z","messageCount":16,"participants":["Jay Soffian","Johannes Schindelin","Mark Burton","Junio C Hamano","Björn Steinbrink","Santi Béjar","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"103929","messageId":"1234222326-55818-1-git-send-email-jaysoffian@gmail.com","threadId":"17686","inReplyTo":null,"subject":"[PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-09T23:32:06Z","receivedAt":"2009-02-09T23:32:06Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"Teach git branch -{r,a} how to interpret remote HEADs and highlight the\ncorresponding remote branch with an asterisk, instead of showing literal\n\"<remote_name>/HEAD\".\n\nSigned-off-by: Jay Soffian <jaysoffian@gmail.com>\n---\ngit branch -r before patch:\n  origin/HEAD\n  origin/html\n  origin/maint\n  origin/man\n  origin/master\n  origin/next\n  origin/pu\n  origin/todo\n\ngit branch -r after patch:\n  origin/html\n  origin/maint\n  origin/man\n* origin/master\n  origin/next\n  origin/pu\n  origin/todo\n\nThe coloring for the current remote branch remains red, not green like\nthe current local branch.\n\nI think it's an improvement. :)\n\n builtin-branch.c |   41 ++++++++++++++++++++++++++++++-----------\n 1 files changed, 30 insertions(+), 11 deletions(-)\n\ndiff --git a/builtin-branch.c b/builtin-branch.c\nindex 56a1971..62558a7 100644\n--- a/builtin-branch.c\n+++ b/builtin-branch.c\n@@ -15,6 +15,7 @@\n #include \"branch.h\"\n #include \"diff.h\"\n #include \"revision.h\"\n+#include \"string-list.h\"\n \n static const char * const builtin_branch_usage[] = {\n \t\"git branch [options] [-r | -a] [--merged | --no-merged]\",\n@@ -190,9 +191,19 @@ struct ref_list {\n \tint index, alloc, maxwidth;\n \tstruct ref_item *list;\n \tstruct commit_list *with_commit;\n+\tstruct string_list *remote_heads;\n \tint kinds;\n };\n \n+static void add_to_remote_heads(struct string_list *remote_heads, const char *head) {\n+\tunsigned char sha1[20];\n+\tint flag;\n+\tconst char *refname = resolve_ref(head, sha1, 0, &flag);\n+\tif (refname && (flag & REF_ISSYMREF) &&\n+\t    !prefixcmp(refname, \"refs/remotes/\"))\n+\t\tstring_list_insert(refname + 13, remote_heads);\n+}\n+\n static int append_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data)\n {\n \tstruct ref_list *ref_list = (struct ref_list*)(cb_data);\n@@ -223,6 +234,13 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,\n \tif ((kind & ref_list->kinds) == 0)\n \t\treturn 0;\n \n+\t/* Handle remote HEAD */\n+\tif (kind == REF_REMOTE_BRANCH && ((len = strlen(refname)) > 5) &&\n+\t    !strcmp(refname + len - 5, \"/HEAD\")) {\n+\t\tadd_to_remote_heads(ref_list->remote_heads, refname - 13);\n+\t\treturn 0;\n+\t}\n+\n \tif (merge_filter != NO_FILTER)\n \t\tadd_pending_object(&ref_list->revs,\n \t\t\t\t   (struct object *)commit, refname);\n@@ -294,8 +312,8 @@ static int matches_merge_filter(struct commit *commit)\n static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,\n \t\t\t   int abbrev, int current)\n {\n-\tchar c;\n-\tint color;\n+\tchar c = ' ';\n+\tint color = COLOR_BRANCH_PLAIN, current_color = COLOR_BRANCH_CURRENT;\n \tstruct commit *commit = item->commit;\n \n \tif (!matches_merge_filter(commit))\n@@ -306,17 +324,13 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,\n \t\tcolor = COLOR_BRANCH_LOCAL;\n \t\tbreak;\n \tcase REF_REMOTE_BRANCH:\n-\t\tcolor = COLOR_BRANCH_REMOTE;\n-\t\tbreak;\n-\tdefault:\n-\t\tcolor = COLOR_BRANCH_PLAIN;\n+\t\tcolor = current_color = COLOR_BRANCH_REMOTE;\n \t\tbreak;\n \t}\n \n-\tc = ' ';\n \tif (current) {\n \t\tc = '*';\n-\t\tcolor = COLOR_BRANCH_CURRENT;\n+\t\tcolor = current_color;\n \t}\n \n \tif (verbose) {\n@@ -364,10 +378,12 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str\n \tint i;\n \tstruct ref_list ref_list;\n \tstruct commit *head_commit = lookup_commit_reference_gently(head_sha1, 1);\n+\tstruct string_list remote_heads = { NULL, 0, 0, 1};\n \n \tmemset(&ref_list, 0, sizeof(ref_list));\n \tref_list.kinds = kinds;\n \tref_list.with_commit = with_commit;\n+\tref_list.remote_heads = &remote_heads;\n \tif (merge_filter != NO_FILTER)\n \t\tinit_revisions(&ref_list.revs, NULL);\n \tfor_each_ref(append_ref, &ref_list);\n@@ -399,13 +415,16 @@ static void print_ref_list(int kinds, int detached, int verbose, int abbrev, str\n \t}\n \n \tfor (i = 0; i < ref_list.index; i++) {\n-\t\tint current = !detached &&\n+\t\tint current = (!detached &&\n \t\t\t(ref_list.list[i].kind == REF_LOCAL_BRANCH) &&\n-\t\t\t!strcmp(ref_list.list[i].name, head);\n+\t\t\t!strcmp(ref_list.list[i].name, head)) ||\n+\t\t\t(ref_list.list[i].kind == REF_REMOTE_BRANCH &&\n+\t\t\tstring_list_has_string(&remote_heads,\n+\t\t\t                       ref_list.list[i].name));\n \t\tprint_ref_item(&ref_list.list[i], ref_list.maxwidth, verbose,\n \t\t\t       abbrev, current);\n \t}\n-\n+\tstring_list_clear(&remote_heads, 0);\n \tfree_ref_list(&ref_list);\n }\n \n-- \n1.6.1.2.354.ge44a2\n"},{"id":"103931","messageId":"alpine.DEB.1.00.0902100048410.10279@pacific.mpi-cbg.de","threadId":"17686","inReplyTo":"1234222326-55818-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-02-09T23:49:14Z","receivedAt":"2009-02-09T23:49:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 9 Feb 2009, Jay Soffian wrote:\n\n> Teach git branch -{r,a} how to interpret remote HEADs and highlight the\n> corresponding remote branch with an asterisk, instead of showing literal\n> \"<remote_name>/HEAD\".\n\nLet's hope that nobody's scripts rely on a single star in front of the \nlocal HEAD...\n\nCiao,\nDscho\n"},{"id":"103932","messageId":"20090210000321.78025483@crow","threadId":"17686","inReplyTo":"alpine.DEB.1.00.0902100048410.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Mark Burton","fromEmail":"markb@ordern.com","sentAt":"2009-02-10T00:03:21Z","receivedAt":"2009-02-10T00:03:21Z","isPatch":true,"sender":{"key":"markb@ordern.com","avatar":null},"body":"\nHi,\n\nJohannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> Let's hope that nobody's scripts rely on a single star in front of the \n> local HEAD...\n\nI don't know if I have any scripts that rely on a single star in front of\nthe local HEAD or not (I'm sure some people must have them), but I do\nthink this new feature would be very confusing, especially when used\nwith -a.\n\nAt the very least, make the indicator something other than a star, an @\nor #, perhaps.\n\nCheers,\n\nMark\n"},{"id":"103933","messageId":"76718490902091610v1a53494ajb24b6a87bf207a78@mail.gmail.com","threadId":"17686","inReplyTo":"alpine.DEB.1.00.0902100048410.10279@pacific.mpi-cbg.de","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-10T00:10:41Z","receivedAt":"2009-02-10T00:10:41Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Mon, Feb 9, 2009 at 6:49 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n> On Mon, 9 Feb 2009, Jay Soffian wrote:\n>\n>> Teach git branch -{r,a} how to interpret remote HEADs and highlight the\n>> corresponding remote branch with an asterisk, instead of showing literal\n>> \"<remote_name>/HEAD\".\n>\n> Let's hope that nobody's scripts rely on a single star in front of the\n> local HEAD...\n\nPerhaps you'd be happier with a different marker for the remote head,\nbut in any case, git branch is a porcelain, isn't it?\n\nj.\n"},{"id":"103935","messageId":"76718490902091622y9a6d1bak5dc401858382e2ff@mail.gmail.com","threadId":"17686","inReplyTo":"20090210000321.78025483@crow","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-02-10T00:22:50Z","receivedAt":"2009-02-10T00:22:50Z","isPatch":true,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"(Please don't trim cc:)\n\nOn Mon, Feb 9, 2009 at 7:03 PM, Mark Burton <markb@ordern.com> wrote:\n> I don't know if I have any scripts that rely on a single star in front of\n> the local HEAD or not (I'm sure some people must have them), but I do\n> think this new feature would be very confusing, especially when used\n> with -a.\n>\n> At the very least, make the indicator something other than a star, an @\n> or #, perhaps.\n\nWith color, it shouldn't be confusing at all as only one branch is in\ngreen. W/o color, it still seems clear to me as the remote branches\nhave their remote name prefixed to them. Even if you're on a detached\nhead:\n\n* (no branch)\n  master\n  next\n  sent/branch-show-remote-HEAD\n  wip/am-usability-improvements\n  wip/push-docs\n  origin/html\n  origin/maint\n  origin/man\n* origin/master\n  origin/next\n  origin/pu\n  origin/todo\n\nA different marker doesn't really seem like an improvement to me:\n\n* (no branch)\n  master\n  next\n  sent/branch-show-remote-HEAD\n  wip/am-usability-improvements\n  wip/push-docs\n  origin/html\n  origin/maint\n  origin/man\n@ origin/master\n  origin/next\n  origin/pu\n  origin/todo\n\nBut I'm happy to have the community paint the shed I've constructed.\n\nj.\n"},{"id":"103936","messageId":"7viqnjrveb.fsf@gitster.siamese.dyndns.org","threadId":"17686","inReplyTo":"20090210000321.78025483@crow","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-02-10T00:24:44Z","receivedAt":"2009-02-10T00:24:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Mark Burton <markb@ordern.com> writes:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>> Let's hope that nobody's scripts rely on a single star in front of the \n>> local HEAD...\n>\n> I don't know if I have any scripts that rely on a single star in front of\n> the local HEAD or not (I'm sure some people must have them), but I do\n> think this new feature would be very confusing, especially when used\n> with -a.\n\nPeople use \"git branch | sed -ne 's/^\\* //p' in their scripts (you can say\n\"against recommendation\" but I think it is a sign that the recommendation\nagainst use of Porcelain in the scripts is not loud enough).  I do not\nthink anybody greps in \"git branch -a\", though, for that purpose.\n\nThe current \"branch -a\" output is a mess.  It omits \"remotes/\" even though\nit includes the local ones in the output.  Perhaps with remotes/, the\noutput may become a bit more readable:\n\n    $ git branch -a\n    * master\n      next\n      pu\n    * remotes/dscho/master\n    * remotes/origin/master\n      remotes/origin/next\n      remotes/origin/pu\n    * remotes/spearce/master\n\nwhich may still be too loud with asterisks, but at least there is no\nconfusion.  Or perhaps like this:\n\n    $ git branch -a\n    * master\n      next\n      pu\n      remotes/dscho/HEAD -> master\n      remotes/dscho/master\n      remotes/origin/HEAD -> master\n      remotes/origin/master\n      remotes/origin/next\n      remotes/origin/pu\n      remotes/spearce/HEAD -> master\n      remotes/spearce/master\n\nwith an obvious twist when there is no mixed output:\n\n    $ git branch -r\n      dscho/HEAD -> master\n      dscho/master\n      origin/HEAD -> master\n      origin/master\n      origin/next\n      origin/pu\n      spearce/HEAD -> master\n      spearce/master\n"},{"id":"103952","messageId":"20090210075214.GC1320@atjola.homenet","threadId":"17686","inReplyTo":"1234222326-55818-1-git-send-email-jaysoffian@gmail.com","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-02-10T07:52:14Z","receivedAt":"2009-02-10T07:52:14Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.02.09 18:32:06 -0500, Jay Soffian wrote:\n> Teach git branch -{r,a} how to interpret remote HEADs and highlight the\n> corresponding remote branch with an asterisk, instead of showing literal\n> \"<remote_name>/HEAD\".\n\nHm, what's the use case for having such a marker? And since only \"git\nclone\" sets up origin/HEAD, while \"git remote add foo git://...\" won't\ncreate foo/HEAD, you would get that marker for origin only. Also, the\norigin/HEAD symref isn't updated, so it doesn't tell you which branch\nis \"active\" in the remote repository now, but which one was active when\nyou cloned the repo.\n\nSo basically, what that marker would tell you is that you can use\n\"origin\" as a short-shortname for the remote tracking branch that has\nthe marker. I don't see how that is very useful.\n\nIf the <name>/HEAD symref would be created for all remotes and would get\nupdated, that would at least make the marker more meaningful, but I\nstill don't really see what I'd use it for. From what I've heard, some\npeople just consider origin/HEAD a clone artifact without much use, and\nso far, I think I agree. But maybe there's more to it?\n\nBjörn\n"},{"id":"103954","messageId":"adf1fd3d0902092359o43427e89j2005e3653766723f@mail.gmail.com","threadId":"17686","inReplyTo":"7viqnjrveb.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-02-10T07:59:57Z","receivedAt":"2009-02-10T07:59:57Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/2/10 Junio C Hamano <gitster@pobox.com>:\n> Mark Burton <markb@ordern.com> writes:\n>\n>> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n>>> Let's hope that nobody's scripts rely on a single star in front of the\n>>> local HEAD...\n>>\n>> I don't know if I have any scripts that rely on a single star in front of\n>> the local HEAD or not (I'm sure some people must have them), but I do\n>> think this new feature would be very confusing, especially when used\n>> with -a.\n>\n> People use \"git branch | sed -ne 's/^\\* //p' in their scripts (you can say\n> \"against recommendation\" but I think it is a sign that the recommendation\n> against use of Porcelain in the scripts is not loud enough).  I do not\n> think anybody greps in \"git branch -a\", though, for that purpose.\n>\n> The current \"branch -a\" output is a mess.  It omits \"remotes/\" even though\n> it includes the local ones in the output.  Perhaps with remotes/, the\n> output may become a bit more readable:\n>\n>    $ git branch -a\n>    * master\n>      next\n>      pu\n>    * remotes/dscho/master\n>    * remotes/origin/master\n>      remotes/origin/next\n>      remotes/origin/pu\n>    * remotes/spearce/master\n>\n> which may still be too loud with asterisks, but at least there is no\n> confusion.  Or perhaps like this:\n>\n>    $ git branch -a\n>    * master\n>      next\n>      pu\n>      remotes/dscho/HEAD -> master\n>      remotes/dscho/master\n>      remotes/origin/HEAD -> master\n>      remotes/origin/master\n>      remotes/origin/next\n>      remotes/origin/pu\n>      remotes/spearce/HEAD -> master\n>      remotes/spearce/master\n>\n> with an obvious twist when there is no mixed output:\n>\n>    $ git branch -r\n>      dscho/HEAD -> master\n>      dscho/master\n>      origin/HEAD -> master\n>      origin/master\n>      origin/next\n>      origin/pu\n>      spearce/HEAD -> master\n>      spearce/master\n\nFor me it makes sense.\n\nAlso this type of output for symrefs \"-> master\" makes even more sense\nin the verbose output.\n\nSanti\n"},{"id":"103956","messageId":"adf1fd3d0902100002k5d787e2ewe9012b42f943a6a3@mail.gmail.com","threadId":"17686","inReplyTo":"20090210075214.GC1320@atjola.homenet","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Santi Béjar","fromEmail":"santi@agolina.net","sentAt":"2009-02-10T08:02:02Z","receivedAt":"2009-02-10T08:02:02Z","isPatch":true,"sender":{"key":"santi@agolina.net","avatar":null},"body":"2009/2/10 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> On 2009.02.09 18:32:06 -0500, Jay Soffian wrote:\n>> Teach git branch -{r,a} how to interpret remote HEADs and highlight the\n>> corresponding remote branch with an asterisk, instead of showing literal\n>> \"<remote_name>/HEAD\".\n>\n> Hm, what's the use case for having such a marker? And since only \"git\n> clone\" sets up origin/HEAD, while \"git remote add foo git://...\" won't\n> create foo/HEAD,\n\ngit remote add -f ... would create it.\n\n> you would get that marker for origin only. Also, the\n> origin/HEAD symref isn't updated, so it doesn't tell you which branch\n> is \"active\" in the remote repository now, but which one was active when\n> you cloned the repo.\n\nMaybe there should be a way to update it afterwards.\n\nSanti\n"},{"id":"103957","messageId":"20090210082439.GD1320@atjola.homenet","threadId":"17686","inReplyTo":"adf1fd3d0902100002k5d787e2ewe9012b42f943a6a3@mail.gmail.com","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-02-10T08:24:39Z","receivedAt":"2009-02-10T08:24:39Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.02.10 09:02:02 +0100, Santi Béjar wrote:\n> 2009/2/10 Björn Steinbrink <B.Steinbrink@gmx.de>:\n> > On 2009.02.09 18:32:06 -0500, Jay Soffian wrote:\n> >> Teach git branch -{r,a} how to interpret remote HEADs and highlight the\n> >> corresponding remote branch with an asterisk, instead of showing literal\n> >> \"<remote_name>/HEAD\".\n> >\n> > Hm, what's the use case for having such a marker? And since only \"git\n> > clone\" sets up origin/HEAD, while \"git remote add foo git://...\" won't\n> > create foo/HEAD,\n> \n> git remote add -f ... would create it.\n\nNo, it won't. Only \"git remote add -m <name> ...\" would. And there, you\nhave to pass a branchname yourself, \"-m HEAD\" doesn't do the trick. So\nthere you'd have a \"the branch I have selected\" instead of \"the branch\nthe remote HEAD referenced\". Making it quite different from what \"git\nclone\" does.\n\nBut actually, that looks like a bug. The docs for -m say that it should\njust override what <name>/HEAD is set to, not that it should be required\nto cause the <name>/HEAD creation. I'll try to look into that.\n\n> > you would get that marker for origin only. Also, the\n> > origin/HEAD symref isn't updated, so it doesn't tell you which branch\n> > is \"active\" in the remote repository now, but which one was active when\n> > you cloned the repo.\n> \n> Maybe there should be a way to update it afterwards.\n\nThat may not be the default for remotes added with -m though, as\notherwise the -m option to \"git remote add\" would become quite\npointless.\n\nBjörn\n"},{"id":"103971","messageId":"20090210110546.5ead75a6@crow","threadId":"17686","inReplyTo":"76718490902091622y9a6d1bak5dc401858382e2ff@mail.gmail.com","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Mark Burton","fromEmail":"markb@ordern.com","sentAt":"2009-02-10T11:05:46Z","receivedAt":"2009-02-10T11:05:46Z","isPatch":true,"sender":{"key":"markb@ordern.com","avatar":null},"body":"On Mon, 9 Feb 2009 19:22:50 -0500\nJay Soffian <jaysoffian@gmail.com> wrote:\n\n> (Please don't trim cc:)\n> \n> On Mon, Feb 9, 2009 at 7:03 PM, Mark Burton <markb@ordern.com> wrote:\n> > I don't know if I have any scripts that rely on a single star in front of\n> > the local HEAD or not (I'm sure some people must have them), but I do\n> > think this new feature would be very confusing, especially when used\n> > with -a.\n> >\n> > At the very least, make the indicator something other than a star, an @\n> > or #, perhaps.\n> \n> With color, it shouldn't be confusing at all as only one branch is in\n> green. \n\nHow about the colour blind git users?\n\n> W/o color, it still seems clear to me as the remote branches\n> have their remote name prefixed to them. Even if you're on a detached\n> head:\n> \n> * (no branch)\n>   master\n>   next\n>   sent/branch-show-remote-HEAD\n>   wip/am-usability-improvements\n>   wip/push-docs\n>   origin/html\n>   origin/maint\n>   origin/man\n> * origin/master\n>   origin/next\n>   origin/pu\n>   origin/todo\n> \n> A different marker doesn't really seem like an improvement to me:\n> \n> * (no branch)\n>   master\n>   next\n>   sent/branch-show-remote-HEAD\n>   wip/am-usability-improvements\n>   wip/push-docs\n>   origin/html\n>   origin/maint\n>   origin/man\n> @ origin/master\n>   origin/next\n>   origin/pu\n>   origin/todo\n> \n> But I'm happy to have the community paint the shed I've constructed.\n> \n> j.\n\nYou can paint a rickety old shed any colour you wish but it doesn't\nmake it any stronger.\n\nPersonally, I think the -> syntax is a much better idea as it is unlikely\nto be confused with the existing marker and it shows the relationship\nbetween the (remote) HEAD and remote current branch.\n\nCheers,\n\nMark\n"},{"id":"103976","messageId":"20090210111907.GD12089@coredump.intra.peff.net","threadId":"17686","inReplyTo":"20090210075214.GC1320@atjola.homenet","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-10T11:19:07Z","receivedAt":"2009-02-10T11:19:07Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"[let me answer your email in reverse order, which will hopefully make\nmore sense when reading]\n\nOn Tue, Feb 10, 2009 at 08:52:14AM +0100, Björn Steinbrink wrote:\n\n> still don't really see what I'd use it for. From what I've heard, some\n> people just consider origin/HEAD a clone artifact without much use, and\n> so far, I think I agree. But maybe there's more to it?\n\nThe ref \"origin\" will resolve to \"refs/remotes/origin/HEAD\", if it\nexists. So you can use it as a shorthand for \"origin/master\" (or\nwhatever branch is most interesting to you on the remote).\n\n> If the <name>/HEAD symref would be created for all remotes and would get\n> updated, that would at least make the marker more meaningful, but I\n\nIt has been noted in the past that it should _not_ be automatically\nupdated, since it is really about \"what is the user's preference for the\n'most interesting' branch in this remote\". And we don't want to\noverwrite some preference that they specified.\n\nSo I think it makes sense to:\n\n  - if it doesn't exist, set it up based on the remote's HEAD. Clone\n    already does this, but \"git remote add -f\" should probably do it,\n    too. I'm not sure if every fetch should do it.\n\n  - give the user some nice interface (probably via \"git remote\") to\n    move the pointer around (right now, it is \"git symbolic-ref\n    refs/remotes/$remote/HEAD refs/remotes/$remote/$branch\").\n\n  - give the user some nice interface to re-fetch the remote HEAD and\n    update refs/remotes/$remote/HEAD with it. Probably as an option to\n    the \"git remote\" invocation above.\n\n-Peff\n"},{"id":"103983","messageId":"20090210115036.GG1320@atjola.homenet","threadId":"17686","inReplyTo":"20090210111907.GD12089@coredump.intra.peff.net","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-02-10T11:50:36Z","receivedAt":"2009-02-10T11:50:36Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.02.10 06:19:07 -0500, Jeff King wrote:\n> On Tue, Feb 10, 2009 at 08:52:14AM +0100, Björn Steinbrink wrote:\n> \n> > still don't really see what I'd use it for. From what I've heard, some\n> > people just consider origin/HEAD a clone artifact without much use, and\n> > so far, I think I agree. But maybe there's more to it?\n> \n> The ref \"origin\" will resolve to \"refs/remotes/origin/HEAD\", if it\n> exists. So you can use it as a shorthand for \"origin/master\" (or\n> whatever branch is most interesting to you on the remote).\n\nYeah, that's what I meant when I said \"short-shortname\". Maybe it's just\nme, but I really can't see myself using that. Would be likely that\n\"origin\" references something else than what I expect, especially when\nswitching from one repo to another. And doing \"git branch -r\" to find\nout if \"origin\" is the right thing is slower than just typing the full\nshortname right away. Well, just my 2 cents.\n\n> > If the <name>/HEAD symref would be created for all remotes and would get\n> > updated, that would at least make the marker more meaningful, but I\n> \n> It has been noted in the past that it should _not_ be automatically\n> updated, since it is really about \"what is the user's preference for the\n> 'most interesting' branch in this remote\". And we don't want to\n> overwrite some preference that they specified.\n\nYeah, as I said in the other mail, having it as a default would make add\n-m quite pointless.\n\n> So I think it makes sense to:\n> \n>   - if it doesn't exist, set it up based on the remote's HEAD. Clone\n>     already does this, but \"git remote add -f\" should probably do it,\n>     too. I'm not sure if every fetch should do it.\n\nFWIW, I would hate fetch for doing that. I dislike the whole\n<remote>/HEAD thing, and wouldn't want fetch to recreate that for me all\nthe time.\n\n>   - give the user some nice interface (probably via \"git remote\") to\n>     move the pointer around (right now, it is \"git symbolic-ref\n>     refs/remotes/$remote/HEAD refs/remotes/$remote/$branch\").\n\nMaybe \"git remote set-master\"? Though I kinda dislike the \"master\" part\nof the name, which I just took from the -m option to \"remote add\",\nthough. I guess that could increase the confusion about the \"master\"\nbranch as pre-setup by \"git init\" being special, and might lead to\ninteresting conclusions about that command affecting the remote\nrepository.\n\n>   - give the user some nice interface to re-fetch the remote HEAD and\n>     update refs/remotes/$remote/HEAD with it. Probably as an option to\n>     the \"git remote\" invocation above.\n\nYeah, would make sense.\n\nBjörn\n"},{"id":"103986","messageId":"20090210115943.GA15387@coredump.intra.peff.net","threadId":"17686","inReplyTo":"20090210115036.GG1320@atjola.homenet","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-10T11:59:43Z","receivedAt":"2009-02-10T11:59:43Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 10, 2009 at 12:50:36PM +0100, Björn Steinbrink wrote:\n\n> Yeah, that's what I meant when I said \"short-shortname\". Maybe it's just\n> me, but I really can't see myself using that. Would be likely that\n> \"origin\" references something else than what I expect, especially when\n> switching from one repo to another. And doing \"git branch -r\" to find\n> out if \"origin\" is the right thing is slower than just typing the full\n> shortname right away. Well, just my 2 cents.\n\nHmm. I use it all the time. :) I find it especially useful in one\nproject where everybody has a personal repo with one interesting branch,\nand I am the integration manager. I use \"git remote update' to fetch\nfrom everybody, and then I can diff and pull against them just by naming\ntheir remote.\n\nSo I think it is just one of those features that some people find useful\nand others don't.\n\n> Yeah, as I said in the other mail, having it as a default would make add\n> -m quite pointless.\n\nNot necessarily. You might be interested in some other branch that isn't\ntheir HEAD. So yes, you would hopefully be using it much less because we\nwould be guessing what you wanted to put there instead of making you\ntype it. But it would still be useful as an override.\n\n> >   - if it doesn't exist, set it up based on the remote's HEAD. Clone\n> >     already does this, but \"git remote add -f\" should probably do it,\n> >     too. I'm not sure if every fetch should do it.\n> \n> FWIW, I would hate fetch for doing that. I dislike the whole\n> <remote>/HEAD thing, and wouldn't want fetch to recreate that for me all\n> the time.\n\nYeah, I think that is a good reason not to have fetch do it.\n\n> >   - give the user some nice interface (probably via \"git remote\") to\n> >     move the pointer around (right now, it is \"git symbolic-ref\n> >     refs/remotes/$remote/HEAD refs/remotes/$remote/$branch\").\n> \n> Maybe \"git remote set-master\"? Though I kinda dislike the \"master\" part\n> of the name, which I just took from the -m option to \"remote add\",\n> though. I guess that could increase the confusion about the \"master\"\n> branch as pre-setup by \"git init\" being special, and might lead to\n> interesting conclusions about that command affecting the remote\n> repository.\n\nI think somebody suggested \"set-default\" in another thread, which\ndoesn't quite work either. Perhaps \"set-head\" is too literal? Maybe\n\"favorite-branch\"? :)\n\n-Peff\n"},{"id":"103990","messageId":"20090210122341.GH1320@atjola.homenet","threadId":"17686","inReplyTo":"20090210115943.GA15387@coredump.intra.peff.net","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-02-10T12:23:41Z","receivedAt":"2009-02-10T12:23:41Z","isPatch":true,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.02.10 06:59:43 -0500, Jeff King wrote:\n> On Tue, Feb 10, 2009 at 12:50:36PM +0100, Björn Steinbrink wrote:\n> > Yeah, as I said in the other mail, having it as a default would make add\n> > -m quite pointless.\n> \n> Not necessarily. You might be interested in some other branch that isn't\n> their HEAD. So yes, you would hopefully be using it much less because we\n> would be guessing what you wanted to put there instead of making you\n> type it. But it would still be useful as an override.\n\nI guess you read that in the wrong context (or I replied in the wrong\ncontext). What I meant is that it would be bad if \"git remote update\" or\n\"git fetch <remote>\" or whatever would update <remote>/HEAD\nautomatically, as that would kill what you have setup with -m.\n\nUsing -m as an override for the automatic guessing makes sense, sure.\nIt's even what the docs say how it's supposed to work already (it just\ndoesn't create <remote>/HEAD at all atm, unless -m is given).\n\nBjörn\n"},{"id":"104001","messageId":"20090210130416.GB17305@coredump.intra.peff.net","threadId":"17686","inReplyTo":"20090210122341.GH1320@atjola.homenet","subject":"Re: [PATCH] builtin-branch: highlight current remote branches with an asterisk","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-02-10T13:04:16Z","receivedAt":"2009-02-10T13:04:16Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Feb 10, 2009 at 01:23:41PM +0100, Björn Steinbrink wrote:\n\n> > > Yeah, as I said in the other mail, having it as a default would make add\n> > > -m quite pointless.\n> > \n> > Not necessarily. You might be interested in some other branch that isn't\n> > their HEAD. So yes, you would hopefully be using it much less because we\n> > would be guessing what you wanted to put there instead of making you\n> > type it. But it would still be useful as an override.\n> \n> I guess you read that in the wrong context (or I replied in the wrong\n> context). What I meant is that it would be bad if \"git remote update\" or\n> \"git fetch <remote>\" or whatever would update <remote>/HEAD\n> automatically, as that would kill what you have setup with -m.\n\nAh, OK, I totally misunderstood. Yes, I think we are in agreement, then.\n\n-Peff\n"}]}