{"thread":{"id":"20610","subject":"Simplify '--prett=xyz' options","startedAt":"2009-08-15T19:01:13Z","lastAt":"2009-08-15T21:39:58Z","messageCount":9,"participants":["Linus Torvalds","Thomas Rast","Junio C Hamano","Johannes Schindelin","Avery Pennarun"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"120726","messageId":"alpine.LFD.2.01.0908151156510.3162@localhost.localdomain","threadId":"20610","inReplyTo":null,"subject":"Simplify '--prett=xyz' options","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-08-15T19:01:13Z","receivedAt":"2009-08-15T19:01:13Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nI keep on thinking that I can write\n\n\tgit log --format:'%aN: %s'\n\ninstead of using the long-form \"--pretty=format:xyz' thing. And each time, \nI curse myself for being stupid for forgetting the proper format.\n\nAnd I'm tired of being stupid. So this patch makes me smart and \nforward-thinking instead.\n\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n---\n\nNow I just need a patch to make me athletic and handsome.\n\n commit.h   |    1 +\n pretty.c   |   26 ++++++++++++++++----------\n revision.c |    2 ++\n 3 files changed, 19 insertions(+), 10 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex ba9f638..cc4229b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -68,6 +68,7 @@ struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */\n extern char *reencode_commit_message(const struct commit *commit,\n \t\t\t\t     const char **encoding_p);\n extern void get_commit_format(const char *arg, struct rev_info *);\n+extern int try_get_commit_format(const char *arg, struct rev_info *);\n extern void format_commit_message(const struct commit *commit,\n \t\t\t\t  const void *format, struct strbuf *sb,\n \t\t\t\t  enum date_mode dmode);\ndiff --git a/pretty.c b/pretty.c\nindex e5328da..97d36c5 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -19,7 +19,7 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma\n \trev->commit_format = CMIT_FMT_USERFORMAT;\n }\n \n-void get_commit_format(const char *arg, struct rev_info *rev)\n+int try_get_commit_format(const char *arg, struct rev_info *rev)\n {\n \tint i;\n \tstatic struct cmt_fmt_map {\n@@ -36,14 +36,9 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n \t\t{ \"oneline\",\t1,\tCMIT_FMT_ONELINE },\n \t};\n \n-\trev->use_terminator = 0;\n-\tif (!arg || !*arg) {\n-\t\trev->commit_format = CMIT_FMT_DEFAULT;\n-\t\treturn;\n-\t}\n \tif (!prefixcmp(arg, \"format:\") || !prefixcmp(arg, \"tformat:\")) {\n \t\tsave_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');\n-\t\treturn;\n+\t\treturn 1;\n \t}\n \tfor (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {\n \t\tif (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&\n@@ -51,15 +46,26 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n \t\t\tif (cmt_fmts[i].v == CMIT_FMT_ONELINE)\n \t\t\t\trev->use_terminator = 1;\n \t\t\trev->commit_format = cmt_fmts[i].v;\n-\t\t\treturn;\n+\t\t\treturn 1;\n \t\t}\n \t}\n \tif (strchr(arg, '%')) {\n \t\tsave_user_format(rev, arg, 1);\n-\t\treturn;\n+\t\treturn 1;\n \t}\n \n-\tdie(\"invalid --pretty format: %s\", arg);\n+\treturn 0;\n+}\n+\n+void get_commit_format(const char *arg, struct rev_info *rev)\n+{\n+\trev->use_terminator = 0;\n+\tif (!arg || !*arg) {\n+\t\trev->commit_format = CMIT_FMT_DEFAULT;\n+\t\treturn;\n+\t}\n+\tif (!try_get_commit_format(arg, rev))\n+\t\tdie(\"invalid --pretty format: %s\", arg);\n }\n \n /*\ndiff --git a/revision.c b/revision.c\nindex 9f5dac5..181593f 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1192,6 +1192,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!strcmp(arg, \"--children\")) {\n \t\trevs->children.name = \"children\";\n \t\trevs->limited = 1;\n+\t} else if (!strncmp(arg, \"--\", 2) && try_get_commit_format(arg+2, revs)) {\n+\t\trevs->verbose_header = 1;\n \t} else {\n \t\tint opts = diff_opt_parse(&revs->diffopt, argv, argc);\n \t\tif (!opts)\n"},{"id":"120727","messageId":"200908152119.56606.trast@student.ethz.ch","threadId":"20610","inReplyTo":"alpine.LFD.2.01.0908151156510.3162@localhost.localdomain","subject":"Re: Simplify '--prett=xyz' options","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-08-15T19:19:55Z","receivedAt":"2009-08-15T19:19:55Z","isPatch":false,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Linus Torvalds wrote:\n> \n> I keep on thinking that I can write\n> \n> \tgit log --format:'%aN: %s'\n> \n> instead of using the long-form \"--pretty=format:xyz' thing. And each time, \n> I curse myself for being stupid for forgetting the proper format.\n> \n> And I'm tired of being stupid. So this patch makes me smart and \n> forward-thinking instead.\n\nBut we already have --format=\"%aN: %s\" since these two commits:\n\ncommit 36407548a2825462a91b456755412a65fd611fc0\nAuthor: Nanako Shiraishi <nanako3@lavabit.com>\nDate:   Tue Feb 24 18:59:15 2009 +0900\n\n    Give short-hands to --pretty=tformat:%formatstring\n\n    Allow --pretty=\"%h %s\" (and --format=\"%h %s\") as shorthand for an often\n    used option --pretty=tformat:\"%h %s\".\n\n    Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\ncommit 3a4c1a5e212357c3df030b6713c75466694c2e77\nAuthor: Nanako Shiraishi <nanako3@lavabit.com>\nDate:   Tue Feb 24 18:59:14 2009 +0900\n\n    Add --format that is a synonym to --pretty\n\n    Some people prefer to call the pretty-print styles \"format\", and get\n    annoyed to see \"git log --format=short\" fail.  Introduce it as a synonym\n    to --pretty so that both can be used.\n\n    Signed-off-by: Nanako Shiraishi <nanako3@lavabit.com>\n    Signed-off-by: Junio C Hamano <gitster@pobox.com>\n\n\nGranted, it makes it equivalent to --pretty=tformat:foo, but isn't\ntformat the better choice in many cases?\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"120728","messageId":"alpine.LFD.2.01.0908151236250.3162@localhost.localdomain","threadId":"20610","inReplyTo":"200908152119.56606.trast@student.ethz.ch","subject":"Re: Simplify '--prett=xyz' options","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-08-15T19:50:49Z","receivedAt":"2009-08-15T19:50:49Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 15 Aug 2009, Thomas Rast wrote:\n> \n> But we already have --format=\"%aN: %s\" since these two commits:\n\nYeah. Junio pointed that out.\n\nWe also have --oneline, which I actually like (but it doesn't work like \n--pretty=oneline - it also enables --abbrev-commit). But then we don't \nhave --fuller (which is what I usually want to use when I want to see \ncommitter info).\n\nAnd \"format\" takes ':' when with --pretty=, but '=' when alone. Which is \nwhat made me not notice that it worked due to silly semantic changes.And \nthe confusion with tformat vs format is fundamental.\n\n> Granted, it makes it equivalent to --pretty=tformat:foo, but isn't\n> tformat the better choice in many cases?\n\nNot really. Look at what happens with\n\n\tgit log --stat --pretty=format:%s\n\nand then try tformat instead. 'tformat' is broken, as is our current \n--format=%s.\n\nIn other words, all of that crud is totally illogical, and our \"short \nversions\" (--oneline and --format=) were done entirely incorrectly (well, \n--oneline probably has the _right_ semantics, and --pretty=oneline is just \nwrong, but whatever).\n\nSadly, we can't fix those things well.\n\nBut here's a fixed version of my patch that gets rid of some problems.\n\nAnd our current --format= thing really _is_ fundamentaly broken, as shown \nby my example above. Making it work like 'tformat' was a bug. With this, \nyou can say\n\n\tgit log --tformat=%s\n\nif you want the stupid tformat semantics.\n\n[ Junio, I fixed that, so this is strictly \"version 3\" of the patch. Now \n  \"--format=x\" works like \"--pretty=format:x\" and if you want tformat \n  semantics, you need to say \"--tformat=x\")\n\n  That's why the test-cases got modified with this patch - we were \n  actually _testing_ for that idiotic behavior of --pretty=format:x being \n  different from --format=x ]\n\nI would like to also make \"--pretty=oneline\" have the same abbrev-commit \nsemantics as \"--oneline\" has, but I didn't actually do that change.\n\n\t\tLinus\n\n---\n commit.h       |    1 +\n pretty.c       |   42 +++++++++++++++++++++++++++++-------------\n revision.c     |    9 +++++++--\n t/t4202-log.sh |   14 +++++++-------\n 4 files changed, 44 insertions(+), 22 deletions(-)\n\ndiff --git a/commit.h b/commit.h\nindex ba9f638..cc4229b 100644\n--- a/commit.h\n+++ b/commit.h\n@@ -68,6 +68,7 @@ struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */\n extern char *reencode_commit_message(const struct commit *commit,\n \t\t\t\t     const char **encoding_p);\n extern void get_commit_format(const char *arg, struct rev_info *);\n+extern int try_get_commit_format(const char *arg, struct rev_info *);\n extern void format_commit_message(const struct commit *commit,\n \t\t\t\t  const void *format, struct strbuf *sb,\n \t\t\t\t  enum date_mode dmode);\ndiff --git a/pretty.c b/pretty.c\nindex e5328da..1a76320 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -19,7 +19,7 @@ static void save_user_format(struct rev_info *rev, const char *cp, int is_tforma\n \trev->commit_format = CMIT_FMT_USERFORMAT;\n }\n \n-void get_commit_format(const char *arg, struct rev_info *rev)\n+int try_get_commit_format(const char *arg, struct rev_info *rev)\n {\n \tint i;\n \tstatic struct cmt_fmt_map {\n@@ -36,30 +36,46 @@ void get_commit_format(const char *arg, struct rev_info *rev)\n \t\t{ \"oneline\",\t1,\tCMIT_FMT_ONELINE },\n \t};\n \n-\trev->use_terminator = 0;\n-\tif (!arg || !*arg) {\n-\t\trev->commit_format = CMIT_FMT_DEFAULT;\n-\t\treturn;\n+\tif (!prefixcmp(arg, \"format\")) {\n+\t\tif (arg[6] == ':' || arg[6] == '=') {\n+\t\t\tsave_user_format(rev, arg+7, 0);\n+\t\t\treturn 1;\n+\t\t}\n \t}\n-\tif (!prefixcmp(arg, \"format:\") || !prefixcmp(arg, \"tformat:\")) {\n-\t\tsave_user_format(rev, strchr(arg, ':') + 1, arg[0] == 't');\n-\t\treturn;\n+\tif (!prefixcmp(arg, \"tformat\")) {\n+\t\tif (arg[7] == ':' || arg[7] == '=') {\n+\t\t\tsave_user_format(rev, arg+8, 1);\n+\t\t\treturn 1;\n+\t\t}\n \t}\n+\n \tfor (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {\n \t\tif (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&\n \t\t    !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {\n \t\t\tif (cmt_fmts[i].v == CMIT_FMT_ONELINE)\n \t\t\t\trev->use_terminator = 1;\n \t\t\trev->commit_format = cmt_fmts[i].v;\n-\t\t\treturn;\n+\t\t\treturn 1;\n \t\t}\n \t}\n-\tif (strchr(arg, '%')) {\n-\t\tsave_user_format(rev, arg, 1);\n+\n+\treturn 0;\n+}\n+\n+void get_commit_format(const char *arg, struct rev_info *rev)\n+{\n+\trev->use_terminator = 0;\n+\tif (!arg || !*arg) {\n+\t\trev->commit_format = CMIT_FMT_DEFAULT;\n \t\treturn;\n \t}\n-\n-\tdie(\"invalid --pretty format: %s\", arg);\n+\tif (!try_get_commit_format(arg, rev)) {\n+\t\tif (strchr(arg, '%')) {\n+\t\t\tsave_user_format(rev, arg, 0);\n+\t\t\treturn;\n+\t\t}\n+\t\tdie(\"invalid --pretty format: %s\", arg);\n+\t}\n }\n \n /*\ndiff --git a/revision.c b/revision.c\nindex 9f5dac5..bdace8b 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1123,7 +1123,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!strcmp(arg, \"--pretty\")) {\n \t\trevs->verbose_header = 1;\n \t\tget_commit_format(arg+8, revs);\n-\t} else if (!prefixcmp(arg, \"--pretty=\") || !prefixcmp(arg, \"--format=\")) {\n+\t} else if (!prefixcmp(arg, \"--pretty=\")) {\n \t\trevs->verbose_header = 1;\n \t\tget_commit_format(arg+9, revs);\n \t} else if (!strcmp(arg, \"--oneline\")) {\n@@ -1194,8 +1194,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t\trevs->limited = 1;\n \t} else {\n \t\tint opts = diff_opt_parse(&revs->diffopt, argv, argc);\n-\t\tif (!opts)\n+\t\tif (!opts) {\n+\t\t\tif (!strncmp(arg, \"--\", 2) && try_get_commit_format(arg+2, revs)) {\n+\t\t\t\trevs->verbose_header = 1;\n+\t\t\t\treturn 1;\n+\t\t\t}\n \t\t\tunkv[(*unkc)++] = arg;\n+\t\t}\n \t\treturn opts;\n \t}\n \ndiff --git a/t/t4202-log.sh b/t/t4202-log.sh\nindex 48e0088..2f1a5a5 100755\n--- a/t/t4202-log.sh\n+++ b/t/t4202-log.sh\n@@ -44,13 +44,6 @@ test_expect_success 'pretty' '\n \ttest_cmp expect actual\n '\n \n-printf \"sixth\\nfifth\\nfourth\\nthird\\nsecond\\ninitial\\n\" > expect\n-test_expect_success 'pretty (tformat)' '\n-\n-\tgit log --pretty=\"tformat:%s\" > actual &&\n-\ttest_cmp expect actual\n-'\n-\n test_expect_success 'pretty (shortcut)' '\n \n \tgit log --pretty=\"%s\" > actual &&\n@@ -63,6 +56,13 @@ test_expect_success 'format' '\n \ttest_cmp expect actual\n '\n \n+printf \"sixth\\nfifth\\nfourth\\nthird\\nsecond\\ninitial\\n\" > expect\n+test_expect_success 'pretty (tformat)' '\n+\n+\tgit log --pretty=\"tformat:%s\" > actual &&\n+\ttest_cmp expect actual\n+'\n+\n cat > expect << EOF\n 804a787 sixth\n 394ef78 fifth\n"},{"id":"120731","messageId":"7viqgoestz.fsf@alter.siamese.dyndns.org","threadId":"20610","inReplyTo":"alpine.LFD.2.01.0908151236250.3162@localhost.localdomain","subject":"Re: Simplify '--prett=xyz' options","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-15T20:16:08Z","receivedAt":"2009-08-15T20:16:08Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Sat, 15 Aug 2009, Thomas Rast wrote:\n>\n>> Granted, it makes it equivalent to --pretty=tformat:foo, but isn't\n>> tformat the better choice in many cases?\n>\n> Not really. Look at what happens with\n>\n> \tgit log --stat --pretty=format:%s\n>\n> and then try tformat instead. 'tformat' is broken, as is our current \n> --format=%s.\n>\n> In other words, all of that crud is totally illogical, and our \"short \n> versions\" (--oneline and --format=) were done entirely incorrectly (well, \n> --oneline probably has the _right_ semantics, and --pretty=oneline is just \n> wrong, but whatever).\n\nIf you try that without --stat, i.e.\n\n    $ git log -4 --pretty=format:%s | cat -e\n    $ git log -4 --pretty=tformat:%s | cat -e\n\nI suspect you may then find that --pretty=format (not --pretty=tformat) is\nbroken.\n"},{"id":"120732","messageId":"alpine.DEB.1.00.0908152220060.8306@pacific.mpi-cbg.de","threadId":"20610","inReplyTo":"alpine.LFD.2.01.0908151156510.3162@localhost.localdomain","subject":"Re: Simplify '--prett=xyz' options","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-08-15T20:22:36Z","receivedAt":"2009-08-15T20:22:36Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 15 Aug 2009, Linus Torvalds wrote:\n\n> \n> I keep on thinking that I can write\n> \n> \tgit log --format:'%aN: %s'\n\nYou mean as opposed to \"--format=%aN:\\ %s\" (which works)?\n\n> Now I just need a patch to make me athletic and handsome.\n\nI thought that already happened?  /me remembers seeing a youtube video \nwith you in speedos.\n\n\n> diff --git a/revision.c b/revision.c\n> index 9f5dac5..181593f 100644\n> --- a/revision.c\n> +++ b/revision.c\n> @@ -1192,6 +1192,8 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n>  \t} else if (!strcmp(arg, \"--children\")) {\n>  \t\trevs->children.name = \"children\";\n>  \t\trevs->limited = 1;\n> +\t} else if (!strncmp(arg, \"--\", 2) && try_get_commit_format(arg+2, revs)) {\n\nprefixcmp?\n\nCiao,\nDscho\n"},{"id":"120734","messageId":"alpine.LFD.2.01.0908151324380.3162@localhost.localdomain","threadId":"20610","inReplyTo":"7viqgoestz.fsf@alter.siamese.dyndns.org","subject":"Re: Simplify '--prett=xyz' options","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-08-15T20:36:13Z","receivedAt":"2009-08-15T20:36:13Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 15 Aug 2009, Junio C Hamano wrote:\n> \n> If you try that without --stat, i.e.\n> \n>     $ git log -4 --pretty=format:%s | cat -e\n>     $ git log -4 --pretty=tformat:%s | cat -e\n> \n> I suspect you may then find that --pretty=format (not --pretty=tformat) is\n> broken.\n\nI disagree. The real brokenness is that we don't have any way to say \"I \nwant no newline at all after the format\", and then having this mixup with \nthe whole \"terminator\" thing - sometimes it's \"between commits\" (which is \n_correct_ any time you have stat info or something), and sometimes it's \n\"after header\" (which is almost always incorrect).\n\nFor an example of this, try to do a one-line format that shows the \ndiffstat on the same line. IOW, what you really want is something like\n\n\tgit log -4 --shortstat --format=%s%NOTERM\n\nbut you can't do it at all right now - and defaulting to the \"tformat\" \nthing is actually _worse_.\n\nSo I do agree that \"format\" is broken and confused. I just think that \n\"tformat\" is EVEN MORE broken and confused, it just happens to fix that \none form of brokenness that \"format\" has.\n\nNotice how \"CMIT_FMT_ONELINE\" use the \"use_terminator\" (like tformat), but \nthen does things right (unlike tformat). In particular, it's this one:\n\n        pp_header(fmt, abbrev, dmode, encoding, commit, &msg, sb);\n        if (fmt != CMIT_FMT_ONELINE && !subject) {\n                strbuf_addch(sb, '\\n');\n        }       \n\t..\n        /* Make sure there is an EOLN for the non-oneline case */\n        if (fmt != CMIT_FMT_ONELINE)\n                strbuf_addch(sb, '\\n');\n\nand notice how we have no way to edit those from the \"format\" descriptors.\n\n\t\t\tLinus\n"},{"id":"120736","messageId":"32541b130908151405j661cde8fh9783e91cebf1e398@mail.gmail.com","threadId":"20610","inReplyTo":"alpine.LFD.2.01.0908151324380.3162@localhost.localdomain","subject":"Re: Simplify '--prett=xyz' options","fromName":"Avery Pennarun","fromEmail":"apenwarr@gmail.com","sentAt":"2009-08-15T21:05:39Z","receivedAt":"2009-08-15T21:05:39Z","isPatch":false,"sender":{"key":"apenwarr@gmail.com","avatar":"https://avatars.githubusercontent.com/u/20592?v=4"},"body":"On Sat, Aug 15, 2009 at 4:36 PM, Linus\nTorvalds<torvalds@linux-foundation.org> wrote:\n> On Sat, 15 Aug 2009, Junio C Hamano wrote:\n>> If you try that without --stat, i.e.\n>>\n>>     $ git log -4 --pretty=format:%s | cat -e\n>>     $ git log -4 --pretty=tformat:%s | cat -e\n>>\n>> I suspect you may then find that --pretty=format (not --pretty=tformat) is\n>> broken.\n>\n> I disagree. The real brokenness is that we don't have any way to say \"I\n> want no newline at all after the format\", and then having this mixup with\n> the whole \"terminator\" thing - sometimes it's \"between commits\" (which is\n> _correct_ any time you have stat info or something), and sometimes it's\n> \"after header\" (which is almost always incorrect).\n\nI'm guessing that \"after header\" was just an implementation error.  It\nwas presumably intended to be \"after commit\", so that the only\ndifference between format and tformat is the presence or absence of\nthe very last terminator.\n\nMaybe the correct fix is just to make tformat not broken?\n\nAvery\n"},{"id":"120738","messageId":"alpine.LFD.2.01.0908151422140.3162@localhost.localdomain","threadId":"20610","inReplyTo":"32541b130908151405j661cde8fh9783e91cebf1e398@mail.gmail.com","subject":"Re: Simplify '--prett=xyz' options","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-08-15T21:29:33Z","receivedAt":"2009-08-15T21:29:33Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 15 Aug 2009, Avery Pennarun wrote:\n> \n> I'm guessing that \"after header\" was just an implementation error.  It\n> was presumably intended to be \"after commit\", so that the only\n> difference between format and tformat is the presence or absence of\n> the very last terminator.\n> \n> Maybe the correct fix is just to make tformat not broken?\n\nI do agree. 'tformat' is broken. But my point was more that 'tformat' was \nintroduced for all the wrong reasons (ie that 'format' was broken, and \nthen instead of fixing 'format', people introduced 'tformat' with a \n_different_ brokenness).\n\n\t\tLinus\n"},{"id":"120739","messageId":"alpine.LFD.2.01.0908151434250.3162@localhost.localdomain","threadId":"20610","inReplyTo":"alpine.LFD.2.01.0908151236250.3162@localhost.localdomain","subject":"Re: Simplify '--prett=xyz' options","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-08-15T21:39:58Z","receivedAt":"2009-08-15T21:39:58Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 15 Aug 2009, Linus Torvalds wrote:\n> \n> I would like to also make \"--pretty=oneline\" have the same abbrev-commit \n> semantics as \"--oneline\" has, but I didn't actually do that change.\n\nHere's a patch if anybody cares.\n\nIt basically replaces the tests that do\n\n\tcut -b42-\n\nor\n\n\tsed -e \"s/^.\\{41\\}//\"\n\n(to get just the subject) with\n\n\tsed -e \"s/^[0-9a-f]* //\"\n\ninstead (which is an already pre-existing pattern that some other tests \nused).\n\nThe patch itself was trivial. The only question is whether the semantic \nchange is ok (it certainly makes _sense_, it's just silly how \"--oneline\" \nis different from \"--pretty=oneline\"). \n\nThis patch obviously depends on the previous one, since it just removes \nthe special-casing of \"--oneline\" (it now falls out automatically from the \n\"if you can't recognize the flag, see if it's a format flag\" logic, and is \nno longer a special case).\n\nThe 'format/tformat' misdesigns I've not touched.\n\n\t\tLinus\n\n---\n pretty.c                      |    4 +++-\n revision.c                    |    4 ----\n t/t3413-rebase-hook.sh        |    2 +-\n t/t5510-fetch.sh              |    2 +-\n t/t6009-rev-list-parent.sh    |    2 +-\n t/t9108-git-svn-glob.sh       |    4 ++--\n t/t9109-git-svn-multi-glob.sh |    6 +++---\n 7 files changed, 11 insertions(+), 13 deletions(-)\n\ndiff --git a/pretty.c b/pretty.c\nindex 1a76320..6d0fa60 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -52,8 +52,10 @@ int try_get_commit_format(const char *arg, struct rev_info *rev)\n \tfor (i = 0; i < ARRAY_SIZE(cmt_fmts); i++) {\n \t\tif (!strncmp(arg, cmt_fmts[i].n, cmt_fmts[i].cmp_len) &&\n \t\t    !strncmp(arg, cmt_fmts[i].n, strlen(arg))) {\n-\t\t\tif (cmt_fmts[i].v == CMIT_FMT_ONELINE)\n+\t\t\tif (cmt_fmts[i].v == CMIT_FMT_ONELINE) {\n \t\t\t\trev->use_terminator = 1;\n+\t\t\t\trev->abbrev_commit = 1;\n+\t\t\t}\n \t\t\trev->commit_format = cmt_fmts[i].v;\n \t\t\treturn 1;\n \t\t}\ndiff --git a/revision.c b/revision.c\nindex bdace8b..b7f047a 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1126,10 +1126,6 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg\n \t} else if (!prefixcmp(arg, \"--pretty=\")) {\n \t\trevs->verbose_header = 1;\n \t\tget_commit_format(arg+9, revs);\n-\t} else if (!strcmp(arg, \"--oneline\")) {\n-\t\trevs->verbose_header = 1;\n-\t\tget_commit_format(\"oneline\", revs);\n-\t\trevs->abbrev_commit = 1;\n \t} else if (!strcmp(arg, \"--graph\")) {\n \t\trevs->topo_order = 1;\n \t\trevs->rewrite_parents = 1;\ndiff --git a/t/t3413-rebase-hook.sh b/t/t3413-rebase-hook.sh\nindex 098b755..2f14c5c 100755\n--- a/t/t3413-rebase-hook.sh\n+++ b/t/t3413-rebase-hook.sh\n@@ -19,7 +19,7 @@ test_expect_success setup '\n \ttest_tick &&\n \tgit commit -m side &&\n \tgit checkout master &&\n-\tgit log --pretty=oneline --abbrev-commit --graph --all &&\n+\tgit log --oneline --graph --all &&\n \tgit branch test side\n '\n \ndiff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh\nindex d13c806..62a45c0 100755\n--- a/t/t5510-fetch.sh\n+++ b/t/t5510-fetch.sh\n@@ -168,7 +168,7 @@ test_expect_success 'bundle 1 has only 3 files ' '\n test_expect_success 'unbundle 2' '\n \tcd \"$D/bundle\" &&\n \tgit fetch ../bundle2 master:master &&\n-\ttest \"tip\" = \"$(git log -1 --pretty=oneline master | cut -b42-)\"\n+\ttest \"tip\" = \"$(git log -1 --pretty=oneline master | sed 's/^[0-9a-f]* //')\"\n '\n \n test_expect_success 'bundle does not prerequisite objects' '\ndiff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh\nindex c8a96a9..9a90ce8 100755\n--- a/t/t6009-rev-list-parent.sh\n+++ b/t/t6009-rev-list-parent.sh\n@@ -24,7 +24,7 @@ test_expect_success setup '\n \tcommit three &&\n \tcommit four &&\n \n-\tgit log --pretty=oneline --abbrev-commit\n+\tgit log --oneline\n '\n \n test_expect_success 'one is ancestor of others and should not be shown' '\ndiff --git a/t/t9108-git-svn-glob.sh b/t/t9108-git-svn-glob.sh\nindex d732d31..4d386f2 100755\n--- a/t/t9108-git-svn-glob.sh\n+++ b/t/t9108-git-svn-glob.sh\n@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '\n \t                 \"tags/*/src/a:refs/remotes/tags/*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/end | \\\n-\t    sed -e \"s/^.\\{41\\}//\" > output.end &&\n+\t    sed -e \"s/^[0-9a-f]* //\" > output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"`git rev-parse refs/remotes/tags/end~1`\" = \\\n \t\t\"`git rev-parse refs/remotes/branches/start`\" &&\n@@ -82,7 +82,7 @@ test_expect_success 'test left-hand-side only globbing' '\n \ttest `git rev-parse refs/remotes/two/tags/end~3` = \\\n \t     `git rev-parse refs/remotes/two/branches/start` &&\n \tgit log --pretty=oneline refs/remotes/two/tags/end | \\\n-\t    sed -e \"s/^.\\{41\\}//\" > output.two &&\n+\t    sed -e \"s/^[0-9a-f]* //\" > output.two &&\n \ttest_cmp expect.two output.two\n \t'\n \ndiff --git a/t/t9109-git-svn-multi-glob.sh b/t/t9109-git-svn-multi-glob.sh\nindex c318f9f..da93cf1 100755\n--- a/t/t9109-git-svn-multi-glob.sh\n+++ b/t/t9109-git-svn-multi-glob.sh\n@@ -48,7 +48,7 @@ test_expect_success 'test refspec globbing' '\n \t                 \"tags/*/src/a:refs/remotes/tags/*\" &&\n \tgit svn multi-fetch &&\n \tgit log --pretty=oneline refs/remotes/tags/end | \\\n-\t    sed -e \"s/^.\\{41\\}//\" > output.end &&\n+\t    sed -e \"s/^[0-9a-f]* //\" > output.end &&\n \ttest_cmp expect.end output.end &&\n \ttest \"`git rev-parse refs/remotes/tags/end~1`\" = \\\n \t\t\"`git rev-parse refs/remotes/branches/v1/start`\" &&\n@@ -82,7 +82,7 @@ test_expect_success 'test left-hand-side only globbing' '\n \ttest `git rev-parse refs/remotes/two/tags/end~3` = \\\n \t     `git rev-parse refs/remotes/two/branches/v1/start` &&\n \tgit log --pretty=oneline refs/remotes/two/tags/end | \\\n-\t    sed -e \"s/^.\\{41\\}//\" > output.two &&\n+\t    sed -e \"s/^[0-9a-f]* //\" > output.two &&\n \ttest_cmp expect.two output.two\n \t'\n cat > expect.four <<EOF\n@@ -131,7 +131,7 @@ test_expect_success 'test another branch' '\n \ttest `git rev-parse refs/remotes/four/tags/next~2` = \\\n \t     `git rev-parse refs/remotes/four/branches/v2/start` &&\n \tgit log --pretty=oneline refs/remotes/four/tags/next | \\\n-\t    sed -e \"s/^.\\{41\\}//\" > output.four &&\n+\t    sed -e \"s/^[0-9a-f]* //\" > output.four &&\n \ttest_cmp expect.four output.four\n \t'\n \n"}]}