{"thread":{"id":"44945","subject":"[PATCH] blame: add option to print tips (--tips)","startedAt":"2017-01-22T21:29:42Z","lastAt":"2017-01-24T11:44:07Z","messageCount":8,"participants":["Edmundo Carmona Antoranz","Junio C Hamano","Pranit Bauva"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"309946","messageId":"20170122212855.25924-1-eantoranz@gmail.com","threadId":"44945","inReplyTo":null,"subject":"[PATCH] blame: add option to print tips (--tips)","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2017-01-22T21:28:55Z","receivedAt":"2017-01-22T21:29:42Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"---\n builtin/blame.c | 8 +++++++-\n 1 file changed, 7 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/blame.c b/builtin/blame.c\nindex 126b8c9e5..4bc449f40 100644\n--- a/builtin/blame.c\n+++ b/builtin/blame.c\n@@ -1884,6 +1884,7 @@ static const char *format_time(unsigned long time, const char *tz_str,\n #define OUTPUT_NO_AUTHOR       0200\n #define OUTPUT_SHOW_EMAIL\t0400\n #define OUTPUT_LINE_PORCELAIN 01000\n+#define OUTPUT_SHOW_TIPS      02000\n \n static void emit_porcelain_details(struct origin *suspect, int repeat)\n {\n@@ -1939,14 +1940,18 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n \tstruct commit_info ci;\n \tchar hex[GIT_SHA1_HEXSZ + 1];\n \tint show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);\n+\tint revision_length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;\n \n \tget_commit_info(suspect->commit, &ci, 1);\n \tsha1_to_hex_r(hex, suspect->commit->object.oid.hash);\n \n+\tif (opt & OUTPUT_SHOW_TIPS)\n+\t\tprintf(\"\\t%.*s: %s\\n\", revision_length, hex, ci.summary.buf);\n+\n \tcp = nth_line(sb, ent->lno);\n \tfor (cnt = 0; cnt < ent->num_lines; cnt++) {\n \t\tchar ch;\n-\t\tint length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;\n+\t\tint length = revision_length;\n \n \t\tif (suspect->commit->object.flags & UNINTERESTING) {\n \t\t\tif (blank_boundary)\n@@ -2609,6 +2614,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n \t\t{ OPTION_CALLBACK, 'C', NULL, &opt, N_(\"score\"), N_(\"Find line copies within and across files\"), PARSE_OPT_OPTARG, blame_copy_callback },\n \t\t{ OPTION_CALLBACK, 'M', NULL, &opt, N_(\"score\"), N_(\"Find line movements within and across files\"), PARSE_OPT_OPTARG, blame_move_callback },\n \t\tOPT_STRING_LIST('L', NULL, &range_list, N_(\"n,m\"), N_(\"Process only line range n,m, counting from 1\")),\n+\t\tOPT_BIT(0, \"tips\", &output_option, N_(\"Show tips before content lines\"), OUTPUT_SHOW_TIPS),\n \t\tOPT__ABBREV(&abbrev),\n \t\tOPT_END()\n \t};\n-- \n2.11.0.rc1\n\n"},{"id":"309947","messageId":"CAOc6etaQ-fDWn38YzXkGOC0fSan1vrxjVDUXS924nBXWTTrhNQ@mail.gmail.com","threadId":"44945","inReplyTo":"20170122212855.25924-1-eantoranz@gmail.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2017-01-22T21:39:29Z","receivedAt":"2017-01-22T21:39:34Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"Hello, everybody!\n\nSo, this is a draft of what I mean by \"adding tips to blame\".\n\nExample output (sample from builtin/blame.c):\n\n15:32 $ ./git blame --tips -L 1934,1960 builtin/blame.c\n       cee7f245dc: git-pickaxe: blame rewritten.\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1934)\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1935) static void emit_other(struct scoreboard *sb,\nstruct blame_entry *ent, int opt)\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1936) {\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1937)  int cnt;\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1938)  const char *cp;\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1939)  struct origin *suspect = ent->suspect;\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1940)  struct commit_info ci;\n       d59f765ac9: use sha1_to_hex_r() instead of strcpy\nd59f765ac9 builtin/blame.c   (Jeff King                2015-09-24\n17:08:03 -0400 1941)  char hex[GIT_SHA1_HEXSZ + 1];\n       cee7f245dc: git-pickaxe: blame rewritten.\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1942)  int show_raw_time = !!(opt &\nOUTPUT_RAW_TIMESTAMP);\n       f2aea1696f: blame: add option to print tips (--tips)\nf2aea1696f builtin/blame.c   (Edmundo Carmona Antoranz 2017-01-22\n15:23:31 -0600 1943)  int revision_length = (opt &\nOUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;\n       cee7f245dc: git-pickaxe: blame rewritten.\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1944)\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1945)  get_commit_info(suspect->commit, &ci, 1);\n       f2fd0760f6: Convert struct object to object_id\nf2fd0760f6 builtin/blame.c   (brian m. carlson         2015-11-10\n02:22:28 +0000 1946)  sha1_to_hex_r(hex,\nsuspect->commit->object.oid.hash);\n       cee7f245dc: git-pickaxe: blame rewritten.\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1947)\n       f2aea1696f: blame: add option to print tips (--tips)\nf2aea1696f builtin/blame.c   (Edmundo Carmona Antoranz 2017-01-22\n15:23:31 -0600 1948)  if (opt & OUTPUT_SHOW_TIPS)\nf2aea1696f builtin/blame.c   (Edmundo Carmona Antoranz 2017-01-22\n15:23:31 -0600 1949)          printf(\"\\t%.*s: %s\\n\", revision_length,\nhex, ci.summary.buf);\nf2aea1696f builtin/blame.c   (Edmundo Carmona Antoranz 2017-01-22\n15:23:31 -0600 1950)\n       cee7f245dc: git-pickaxe: blame rewritten.\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1951)  cp = nth_line(sb, ent->lno);\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1952)  for (cnt = 0; cnt < ent->num_lines; cnt++) {\ncee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n16:00:04 -0700 1953)          char ch;\n       f2aea1696f: blame: add option to print tips (--tips)\nf2aea1696f builtin/blame.c   (Edmundo Carmona Antoranz 2017-01-22\n15:23:31 -0600 1954)          int length = revision_length;\n       b11121d9e3: git-blame: show lines attributed to boundary\ncommits differently.\nb11121d9e3 builtin-blame.c   (Junio C Hamano           2006-12-01\n20:45:45 -0800 1955)\nb11121d9e3 builtin-blame.c   (Junio C Hamano           2006-12-01\n20:45:45 -0800 1956)          if (suspect->commit->object.flags &\nUNINTERESTING) {\n       e68989a739: annotate: fix for cvsserver.\ne68989a739 builtin-blame.c   (Junio C Hamano           2007-02-06\n01:52:04 -0800 1957)                  if (blank_boundary)\ne68989a739 builtin-blame.c   (Junio C Hamano           2007-02-06\n01:52:04 -0800 1958)                          memset(hex, ' ',\nlength);\n       7ceacdffc5: \"blame -c\" should be compatible with \"annotate\"\n7ceacdffc5 builtin-blame.c   (Junio C Hamano           2008-09-05\n00:57:35 -0700 1959)                  else if (!(opt &\nOUTPUT_ANNOTATE_COMPAT)) {\n       4c10a5caa7: blame: -b (blame.blankboundary) and --root (blame.showroot)\n4c10a5caa7 builtin-blame.c   (Junio C Hamano           2006-12-18\n14:04:38 -0800 1960)                          length--;\n\n\nDoes it look \"worthy\"? And if so, would it be better to think of\nsomething like an \"aggregate\" option (or something like that) that\nwould include the common information as tips, something like:\n\n15:32 $ ./git blame --tips -L 1934,1960 builtin/blame.c\n       cee7f245dc: builtin-pickaxe.c (Junio C Hamano\n2006-10-19 16:00:04 -0700) git-pickaxe: blame rewritten.\n1934\n1935 static void emit_other(struct scoreboard *sb, struct blame_entry\n*ent, int opt)\n1936 {\n1937  int cnt;\n1938  const char *cp;\n1939  struct origin *suspect = ent->suspect;\n1940  struct commit_info ci;\n       d59f765ac9: builtin/blame.c   (Jeff King\n2015-09-24 17:08:03 -0400) use sha1_to_hex_r() instead of strcpy\n1941  char hex[GIT_SHA1_HEXSZ + 1];\n       cee7f245dc: builtin-pickaxe.c (Junio C Hamano\n2006-10-19 16:00:04 -0700) git-pickaxe: blame rewritten.\n1942  int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);\n       f2aea1696f: builtin/blame.c   (Edmundo Carmona Antoranz\n2017-01-22 15:23:31 -0600) blame: add option to print tips (--tips)\n1943  int revision_length = (opt & OUTPUT_LONG_OBJECT_NAME) ?\nGIT_SHA1_HEXSZ : abbrev;\n       cee7f245dc: builtin-pickaxe.c (Junio C Hamano\n2006-10-19 16:00:04 -0700) git-pickaxe: blame rewritten.\n1944\n1945  get_commit_info(suspect->commit, &ci, 1);\n\nBest regards!\n\nOn Sun, Jan 22, 2017 at 3:28 PM, Edmundo Carmona Antoranz\n<eantoranz@gmail.com> wrote:\n> ---\n>  builtin/blame.c | 8 +++++++-\n>  1 file changed, 7 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/blame.c b/builtin/blame.c\n> index 126b8c9e5..4bc449f40 100644\n> --- a/builtin/blame.c\n> +++ b/builtin/blame.c\n> @@ -1884,6 +1884,7 @@ static const char *format_time(unsigned long time, const char *tz_str,\n>  #define OUTPUT_NO_AUTHOR       0200\n>  #define OUTPUT_SHOW_EMAIL      0400\n>  #define OUTPUT_LINE_PORCELAIN 01000\n> +#define OUTPUT_SHOW_TIPS      02000\n>\n>  static void emit_porcelain_details(struct origin *suspect, int repeat)\n>  {\n> @@ -1939,14 +1940,18 @@ static void emit_other(struct scoreboard *sb, struct blame_entry *ent, int opt)\n>         struct commit_info ci;\n>         char hex[GIT_SHA1_HEXSZ + 1];\n>         int show_raw_time = !!(opt & OUTPUT_RAW_TIMESTAMP);\n> +       int revision_length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;\n>\n>         get_commit_info(suspect->commit, &ci, 1);\n>         sha1_to_hex_r(hex, suspect->commit->object.oid.hash);\n>\n> +       if (opt & OUTPUT_SHOW_TIPS)\n> +               printf(\"\\t%.*s: %s\\n\", revision_length, hex, ci.summary.buf);\n> +\n>         cp = nth_line(sb, ent->lno);\n>         for (cnt = 0; cnt < ent->num_lines; cnt++) {\n>                 char ch;\n> -               int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? GIT_SHA1_HEXSZ : abbrev;\n> +               int length = revision_length;\n>\n>                 if (suspect->commit->object.flags & UNINTERESTING) {\n>                         if (blank_boundary)\n> @@ -2609,6 +2614,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix)\n>                 { OPTION_CALLBACK, 'C', NULL, &opt, N_(\"score\"), N_(\"Find line copies within and across files\"), PARSE_OPT_OPTARG, blame_copy_callback },\n>                 { OPTION_CALLBACK, 'M', NULL, &opt, N_(\"score\"), N_(\"Find line movements within and across files\"), PARSE_OPT_OPTARG, blame_move_callback },\n>                 OPT_STRING_LIST('L', NULL, &range_list, N_(\"n,m\"), N_(\"Process only line range n,m, counting from 1\")),\n> +               OPT_BIT(0, \"tips\", &output_option, N_(\"Show tips before content lines\"), OUTPUT_SHOW_TIPS),\n>                 OPT__ABBREV(&abbrev),\n>                 OPT_END()\n>         };\n> --\n> 2.11.0.rc1\n>\n"},{"id":"309961","messageId":"xmqq1svuvh0y.fsf@gitster.mtv.corp.google.com","threadId":"44945","inReplyTo":"CAOc6etaQ-fDWn38YzXkGOC0fSan1vrxjVDUXS924nBXWTTrhNQ@mail.gmail.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-22T22:58:21Z","receivedAt":"2017-01-22T22:58:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:\n\n> So, this is a draft of what I mean by \"adding tips to blame\".\n>\n> Example output (sample from builtin/blame.c):\n> ...\n> 15:32 $ ./git blame --tips -L 1934,1960 builtin/blame.c\n>        cee7f245dc: git-pickaxe: blame rewritten.\n> cee7f245dc builtin-pickaxe.c (Junio C Hamano           2006-10-19\n> 16:00:04 -0700 1934)\n\nThis is unfortunately unreadable to guess what you wanted to\nachieve, not because the lines are too wide, but because they are\nline-wrapped.\n\n> Does it look \"worthy\"? And if so, would it be better to think of\n> something like an \"aggregate\" option (or something like that) that\n> would include the common information as tips, something like:\n\nWhat is the target audience?  If you are trying to write a script\nthat reads output by \"git blame\", you are strongly discouraged\nunless you are reading from \"git blame --porcelain\" which is more\ncompact and has this information already IIRC.\n"},{"id":"309963","messageId":"CAOc6etY5odte=TKyWX3Wf1BVaNTfDeA-xsGOKiyuH88HZgqFDQ@mail.gmail.com","threadId":"44945","inReplyTo":"xmqq1svuvh0y.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Edmundo Carmona Antoranz","fromEmail":"eantoranz@gmail.com","sentAt":"2017-01-22T23:04:46Z","receivedAt":"2017-01-22T23:04:51Z","isPatch":true,"sender":{"key":"eantoranz@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1491018?v=4"},"body":"On Sun, Jan 22, 2017 at 4:58 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> What is the target audience?  If you are trying to write a script\n> that reads output by \"git blame\", you are strongly discouraged\n> unless you are reading from \"git blame --porcelain\" which is more\n> compact and has this information already IIRC.\n\nI wrote this for human consumption, actually. Maybe I overestimated the\nneed for this feature (I definitely find it handy, but it might be just me).\n"},{"id":"309966","messageId":"xmqqlgu2u0qx.fsf@gitster.mtv.corp.google.com","threadId":"44945","inReplyTo":"CAOc6etY5odte=TKyWX3Wf1BVaNTfDeA-xsGOKiyuH88HZgqFDQ@mail.gmail.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-22T23:35:18Z","receivedAt":"2017-01-22T23:35:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Edmundo Carmona Antoranz <eantoranz@gmail.com> writes:\n\n> I wrote this for human consumption, actually. \n\nI see.\n\n> Maybe I overestimated the\n> need for this feature (I definitely find it handy, but it might be just me).\n\nThat is too early to tell.  At this point we only know there are me\nwho won't use it and you who will, among all the other people in the\nworld.\n\n"},{"id":"309980","messageId":"CAFZEwPPx2vDJVf=uk0iUJ2sh9DxWwp2Lp1k-APz9n=7NYMN5uQ@mail.gmail.com","threadId":"44945","inReplyTo":"xmqqlgu2u0qx.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Pranit Bauva","fromEmail":"pranit.bauva@gmail.com","sentAt":"2017-01-23T16:33:45Z","receivedAt":"2017-01-23T16:33:54Z","isPatch":true,"sender":{"key":"pranit.bauva@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2959938?v=4"},"body":"Hey Junio,\n\nOn Mon, Jan 23, 2017 at 5:05 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> That is too early to tell.  At this point we only know there are me\n> who won't use it and you who will, among all the other people in the\n> world.\n\nWe can probably make it useful with some extended efforts. I use\ngit-blame and I sometimes find that I don't need things like the name\nof the author, time, timezone and not even the file name and I have to\nuse a bigger terminal. If we could somehow remove those fields then\nmaybe this would be a useful feature.\n\nIdea: Make git-blame understand `format`\n\ngit-log has a format option in which we can configure what all things\nwe need and what we don't. We could probably do the same here also.\nAfter carefully using the format specification with git-log each\nperson can get a good look at however he seems to view. But I am not\nsure whether this is worth the effort. I personally find this `format`\nfeature useful.\n\nRegards,\nPranit Bauva\n"},{"id":"309995","messageId":"xmqqr33tsjwx.fsf@gitster.mtv.corp.google.com","threadId":"44945","inReplyTo":"CAFZEwPPx2vDJVf=uk0iUJ2sh9DxWwp2Lp1k-APz9n=7NYMN5uQ@mail.gmail.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-23T18:36:30Z","receivedAt":"2017-01-23T18:36:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Pranit Bauva <pranit.bauva@gmail.com> writes:\n\n> We can probably make it useful with some extended efforts. I use\n> git-blame and I sometimes find that I don't need things like the name\n> of the author, time, timezone and not even the file name and I have to\n> use a bigger terminal. If we could somehow remove those fields then\n> maybe this would be a useful feature.\n\nI admit that I didn't recall the option until somebody else told me,\nbut I think \"blame -s\" or something like that for that purpose ;-)\n\n"},{"id":"310085","messageId":"CAFZEwPNGzFhocgXwKA3UjXQdwBmWTCsvSdy47Y+qFfZ6JJpJ4A@mail.gmail.com","threadId":"44945","inReplyTo":"xmqqr33tsjwx.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH] blame: add option to print tips (--tips)","fromName":"Pranit Bauva","fromEmail":"pranit.bauva@gmail.com","sentAt":"2017-01-24T11:36:58Z","receivedAt":"2017-01-24T11:44:07Z","isPatch":true,"sender":{"key":"pranit.bauva@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2959938?v=4"},"body":"Hey Junio,\n\nOn Tue, Jan 24, 2017 at 12:06 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Pranit Bauva <pranit.bauva@gmail.com> writes:\n>\n>> We can probably make it useful with some extended efforts. I use\n>> git-blame and I sometimes find that I don't need things like the name\n>> of the author, time, timezone and not even the file name and I have to\n>> use a bigger terminal. If we could somehow remove those fields then\n>> maybe this would be a useful feature.\n>\n> I admit that I didn't recall the option until somebody else told me,\n> but I think \"blame -s\" or something like that for that purpose ;-)\n\nAh! Thanks a lot!\n\nRegards,\nPranit Bauva\n"}]}