{"thread":{"id":"33810","subject":"[RFC/PATCH] branch: show me the hot branches","startedAt":"2013-05-13T20:02:45Z","lastAt":"2013-05-16T13:58:43Z","messageCount":6,"participants":["Ramkumar Ramachandra","Phil Hord","Junio C Hamano","Duy Nguyen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"217226","messageId":"1368475365-18680-1-git-send-email-artagnon@gmail.com","threadId":"33810","inReplyTo":null,"subject":"[RFC/PATCH] branch: show me the hot branches","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-05-13T20:02:45Z","receivedAt":"2013-05-13T20:02:45Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Uses commit->date to sort displayed refs.\n\nSigned-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n---\n Just had this idea and wrote it down in five minutes.  The\n implementation is only meant to be indicative.\n\n Isn't this awesome?\n\n builtin/branch.c | 32 +++++++++++++++++++++++++++++---\n 1 file changed, 29 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/branch.c b/builtin/branch.c\nindex 0836890..8b08563 100644\n--- a/builtin/branch.c\n+++ b/builtin/branch.c\n@@ -59,6 +59,11 @@ static enum merge_filter {\n } merge_filter;\n static unsigned char merge_filter_ref[20];\n \n+static enum sort_strategy {\n+\tLEXICAL = 0,\n+\tDATE,\n+} sort_strategy;\n+\n static struct string_list output = STRING_LIST_INIT_DUP;\n static unsigned int colopts;\n \n@@ -406,7 +411,7 @@ static void free_ref_list(struct ref_list *ref_list)\n \tfree(ref_list->list);\n }\n \n-static int ref_cmp(const void *r1, const void *r2)\n+static int ref_cmp_lexical(const void *r1, const void *r2)\n {\n \tstruct ref_item *c1 = (struct ref_item *)(r1);\n \tstruct ref_item *c2 = (struct ref_item *)(r2);\n@@ -416,6 +421,16 @@ static int ref_cmp(const void *r1, const void *r2)\n \treturn strcmp(c1->name, c2->name);\n }\n \n+static int ref_cmp_date(const void *r1, const void *r2)\n+{\n+\tstruct ref_item *c1 = (struct ref_item *)(r1);\n+\tstruct ref_item *c2 = (struct ref_item *)(r2);\n+\n+\tif (c1->kind != c2->kind)\n+\t\treturn c1->kind - c2->kind;\n+\treturn c1->commit->date < c2->commit->date;\n+}\n+\n static void fill_tracking_info(struct strbuf *stat, const char *branch_name,\n \t\tint show_upstream_ref)\n {\n@@ -621,7 +636,6 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \n \tmemset(&ref_list, 0, sizeof(ref_list));\n \tref_list.kinds = kinds;\n-\tref_list.verbose = verbose;\n \tref_list.abbrev = abbrev;\n \tref_list.with_commit = with_commit;\n \tif (merge_filter != NO_FILTER)\n@@ -629,7 +643,14 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \tcb.ref_list = &ref_list;\n \tcb.pattern = pattern;\n \tcb.ret = 0;\n+\n+\tif (sort_strategy == DATE && verbose < 1)\n+\t\tref_list.verbose = 1;\n+\telse\n+\t\tref_list.verbose = verbose;\n \tfor_each_rawref(append_ref, &cb);\n+\tref_list.verbose = verbose;\n+\n \tif (merge_filter != NO_FILTER) {\n \t\tstruct commit *filter;\n \t\tfilter = lookup_commit_reference_gently(merge_filter_ref, 0);\n@@ -646,7 +667,10 @@ static int print_ref_list(int kinds, int detached, int verbose, int abbrev, stru\n \t\t\tref_list.maxwidth = calc_maxwidth(&ref_list);\n \t}\n \n-\tqsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp);\n+\tif (sort_strategy == DATE)\n+\t\tqsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp_date);\n+\telse\n+\t\tqsort(ref_list.list, ref_list.index, sizeof(struct ref_item), ref_cmp_lexical);\n \n \tdetached = (detached && (kinds & REF_LOCAL_BRANCH));\n \tif (detached && match_patterns(pattern, \"HEAD\"))\n@@ -843,6 +867,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)\n \t\tOPT_END(),\n \t};\n \n+\tsort_strategy = DATE;\n+\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage_with_options(builtin_branch_usage, options);\n \n-- \n1.8.3.rc1.49.g8d97506.dirty\n"},{"id":"217396","messageId":"CABURp0rVoRwWUBXP5ZdsPByd47hDj7w9y5eddNQfiDfkttAKvg@mail.gmail.com","threadId":"33810","inReplyTo":"1368475365-18680-1-git-send-email-artagnon@gmail.com","subject":"Re: [RFC/PATCH] branch: show me the hot branches","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-05-14T23:19:43Z","receivedAt":"2013-05-14T23:19:43Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Mon, May 13, 2013 at 4:02 PM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Uses commit->date to sort displayed refs.\n>\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n\nI dig it.\n\nI imagine it with --date-order and whatnot.  But I might like it even\nbetter if it were reverse-sorted.  Maybe it needs -rt for that. ;-)\n\nPhil\n"},{"id":"217400","messageId":"7vip2ldtlg.fsf@alter.siamese.dyndns.org","threadId":"33810","inReplyTo":"CABURp0rVoRwWUBXP5ZdsPByd47hDj7w9y5eddNQfiDfkttAKvg@mail.gmail.com","subject":"Re: [RFC/PATCH] branch: show me the hot branches","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-05-14T23:34:03Z","receivedAt":"2013-05-14T23:34:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Phil Hord <phil.hord@gmail.com> writes:\n\n> I imagine it with --date-order and whatnot.\n\nPerhaps modeled after this one.\n\n    git for-each-ref \\\n        --format='%(refname:short) %(subject)'\n        --sort='-committerdate' refs/heads/\n"},{"id":"217402","messageId":"CACsJy8BQ=+rEfnBj3hqOdWNJXuONB4tPTwY=h1UDM0t++ds9HA@mail.gmail.com","threadId":"33810","inReplyTo":"1368475365-18680-1-git-send-email-artagnon@gmail.com","subject":"Re: [RFC/PATCH] branch: show me the hot branches","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2013-05-15T00:08:21Z","receivedAt":"2013-05-15T00:08:21Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Tue, May 14, 2013 at 3:02 AM, Ramkumar Ramachandra\n<artagnon@gmail.com> wrote:\n> Uses commit->date to sort displayed refs.\n>\n> Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>\n> ---\n>  Just had this idea and wrote it down in five minutes.  The\n>  implementation is only meant to be indicative.\n>\n>  Isn't this awesome?\n\nI tried a more generic approach a while ago.\n\nhttp://thread.gmane.org/gmane.comp.version-control.git/188705\n--\nDuy\n"},{"id":"217430","messageId":"CABURp0oH-n59hbUzUefztf6DjJWR26Tu6zUX6VNQ292icwxh4w@mail.gmail.com","threadId":"33810","inReplyTo":"7vip2ldtlg.fsf@alter.siamese.dyndns.org","subject":"Re: [RFC/PATCH] branch: show me the hot branches","fromName":"Phil Hord","fromEmail":"phil.hord@gmail.com","sentAt":"2013-05-15T12:54:14Z","receivedAt":"2013-05-15T12:54:14Z","isPatch":true,"sender":{"key":"phil.hord@gmail.com","avatar":"https://avatars.githubusercontent.com/u/123908?v=4"},"body":"On Tue, May 14, 2013 at 7:34 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> Phil Hord <phil.hord@gmail.com> writes:\n>\n>> I imagine it with --date-order and whatnot.\n>\n> Perhaps modeled after this one.\n>\n>     git for-each-ref \\\n>         --format='%(refname:short) %(subject)'\n>         --sort='-committerdate' refs/heads/\n>\n\nNice.  I had no idea about for-each-ref.  I knew it was out there, but\nnot what it could do.  Another tool in the swiss army knife that is\ngit.\n\nI think Duy was right about his patch's merits.\n\nPhil\n"},{"id":"217596","messageId":"CALkWK0=LJk_xQA3tLkmSC=-mrk0S+iXW=medvakB7mQ2QorgAg@mail.gmail.com","threadId":"33810","inReplyTo":"CACsJy8BQ=+rEfnBj3hqOdWNJXuONB4tPTwY=h1UDM0t++ds9HA@mail.gmail.com","subject":"Re: [RFC/PATCH] branch: show me the hot branches","fromName":"Ramkumar Ramachandra","fromEmail":"artagnon@gmail.com","sentAt":"2013-05-16T13:58:43Z","receivedAt":"2013-05-16T13:58:43Z","isPatch":true,"sender":{"key":"r@artagnon.com","avatar":"https://avatars.githubusercontent.com/u/37226?v=4"},"body":"Duy Nguyen wrote:\n> I tried a more generic approach a while ago.\n>\n> http://thread.gmane.org/gmane.comp.version-control.git/188705\n\nLooks good.  Why didn't you polish it for inclusion?\n\nIt's a very useful feature in my opinion: the default git branch\noutput is quite horrible.  I want to make sort, count, and verbosity\n(poorly chosen name?) configuration variables.\n"}]}