{"thread":{"id":"12383","subject":"[PATCH] pretty format now configurable","startedAt":"2008-02-29T19:44:23Z","lastAt":"2008-03-02T17:12:28Z","messageCount":15,"participants":["Denis Cheng","Linus Torvalds","Johannes Schindelin","rae l","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"70409","messageId":"1204314263-8072-1-git-send-email-crquan@gmail.com","threadId":"12383","inReplyTo":null,"subject":"[PATCH] pretty format now configurable","fromName":"Denis Cheng","fromEmail":"crquan@gmail.com","sentAt":"2008-02-29T19:44:23Z","receivedAt":"2008-02-29T19:44:23Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":" * New configuration variable \"format.pretty\" can be used\n    in git log/show/whathappened.\n\nSigned-off-by: Denis Cheng <crquan@gmail.com>\n---\n builtin-log.c |   10 +++++++++-\n 1 files changed, 9 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex bbadbc0..0f7ee1f 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -20,6 +20,7 @@\n \n static int default_show_root = 1;\n static const char *fmt_patch_subject_prefix = \"PATCH\";\n+static const char *fmt_pretty;\n \n static void add_name_decoration(const char *prefix, const char *name, struct object *obj)\n {\n@@ -53,7 +54,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \tint decorate = 0;\n \n \trev->abbrev = DEFAULT_ABBREV;\n-\trev->commit_format = CMIT_FMT_DEFAULT;\n+\tif (fmt_pretty)\n+\t\trev->commit_format = get_commit_format(fmt_pretty);\n \trev->verbose_header = 1;\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n@@ -221,6 +223,12 @@ static int cmd_log_walk(struct rev_info *rev)\n \n static int git_log_config(const char *var, const char *value)\n {\n+\tif (!strcmp(var, \"format.pretty\")) {\n+\t\tif (!value)\n+\t\t\tconfig_error_nonbool(var);\n+\t\tfmt_pretty = xstrdup(value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"format.subjectprefix\")) {\n \t\tif (!value)\n \t\t\tconfig_error_nonbool(var);\n-- \n1.5.4.2\n\n"},{"id":"70410","messageId":"alpine.LFD.1.00.0802291155550.17889@woody.linux-foundation.org","threadId":"12383","inReplyTo":"1204314263-8072-1-git-send-email-crquan@gmail.com","subject":"Re: [PATCH] pretty format now configurable","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-02-29T20:00:47Z","receivedAt":"2008-02-29T20:00:47Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Sat, 1 Mar 2008, Denis Cheng wrote:\n>  \n>  \trev->abbrev = DEFAULT_ABBREV;\n> -\trev->commit_format = CMIT_FMT_DEFAULT;\n> +\tif (fmt_pretty)\n> +\t\trev->commit_format = get_commit_format(fmt_pretty);\n\nUmm. Now it looks like commit_format isn't initialized at all if \nfmt_pretty hasn't been set.\n\nNow, it looks like it will have been initialized properly in \n\"init_revisions()\", but your commit log doesn't mention that, so it was \nharder to review this patch than necessary.\n\nAlso, can you describe what the background for this is? The reason I ask \nis that if anybody ever sets that default commit format to anythign else, \nit will now *seriously* confuse not just users but potentially other git \ntools too (at least gitk uses \"--pretty=raw\", but who knows what other \ntools/scripts are around that just expected the default format).\n\n\t\tLinus\n"},{"id":"70427","messageId":"alpine.LSU.1.00.0802292150350.22527@racer.site","threadId":"12383","inReplyTo":"1204314263-8072-1-git-send-email-crquan@gmail.com","subject":"Re: [PATCH] pretty format now configurable","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-02-29T21:51:12Z","receivedAt":"2008-02-29T21:51:12Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 1 Mar 2008, Denis Cheng wrote:\n\n> Signed-off-by: Denis Cheng <crquan@gmail.com>\n> ---\n>  builtin-log.c |   10 +++++++++-\n>  1 files changed, 9 insertions(+), 1 deletions(-)\n> \n> diff --git a/builtin-log.c b/builtin-log.c\n> index bbadbc0..0f7ee1f 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -20,6 +20,7 @@\n>  \n>  static int default_show_root = 1;\n>  static const char *fmt_patch_subject_prefix = \"PATCH\";\n> +static const char *fmt_pretty;\n\nDon't you want to initialise this?\n\nCiao,\nDscho\n"},{"id":"70479","messageId":"91b13c310802292207j1b130077we11859bd20187226@mail.gmail.com","threadId":"12383","inReplyTo":"alpine.LFD.1.00.0802291155550.17889@woody.linux-foundation.org","subject":"Re: [PATCH] pretty format now configurable","fromName":"rae l","fromEmail":"crquan@gmail.com","sentAt":"2008-03-01T06:07:23Z","receivedAt":"2008-03-01T06:07:23Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":"On Sat, Mar 1, 2008 at 4:00 AM, Linus Torvalds\n<torvalds@linux-foundation.org> wrote:\n>\n>  On Sat, 1 Mar 2008, Denis Cheng wrote:\n>  >\n>  >       rev->abbrev = DEFAULT_ABBREV;\n>  > -     rev->commit_format = CMIT_FMT_DEFAULT;\n>  > +     if (fmt_pretty)\n>  > +             rev->commit_format = get_commit_format(fmt_pretty);\n>\n>  Umm. Now it looks like commit_format isn't initialized at all if\n>  fmt_pretty hasn't been set.\n>\n>  Now, it looks like it will have been initialized properly in\n>  \"init_revisions()\", but your commit log doesn't mention that, so it was\n>  harder to review this patch than necessary.\n>\n>  Also, can you describe what the background for this is? The reason I ask\n>  is that if anybody ever sets that default commit format to anythign else,\n>  it will now *seriously* confuse not just users but potentially other git\n>  tools too (at least gitk uses \"--pretty=raw\", but who knows what other\n>  tools/scripts are around that just expected the default format).\nyes, rev->commit_format has been initialized to CMIT_FMT_DEFAULT in\n\"init_revisions()\", so the code of this patch has been working well in\nmy local repo,\n\nthe \"format.pretty\" configuration's background is that I often use\n\"--pretty=fuller\" on my command line, and different \"format:...\" on my\ndifferent local repos, I hope there is a configuration to store this\nto gitconfig.\n\nnow git log/show/whathappened accept pretty format in the following sort:\n1. rev->commit_format set to CMIT_FMT_DEFAULT in init_revisions;\n2. call to gitconfig will set fmt_pretty properly;\n3. set rev->commit_format according to fmt_pretty;\n4. setup_revisions will accept \"--pretty=\" from the command line;\n\nso the \"--pretty=\" precedence is:\n1. the command line \"--pretty=\";\n2. \"format.pretty\" from the gitconfig;\n3. default CMIT_FMT_DEFAULT;\n\nand indeed I need to  generate a new patch including comments of this\nin the source and in Documentation/*.txt; I will soon send a new\npatch.\n\n>\n>                 Linus\n>\n\n--\nDenis Cheng\n"},{"id":"70543","messageId":"1204391724-566-1-git-send-email-crquan@gmail.com","threadId":"12383","inReplyTo":"alpine.LFD.1.00.0802291155550.17889@woody.linux-foundation.org","subject":"[PATCH] add pretty format configuration to git log/show/whatchanged","fromName":"Denis Cheng","fromEmail":"crquan@gmail.com","sentAt":"2008-03-01T17:15:24Z","receivedAt":"2008-03-01T17:15:24Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":" * New configuration variable \"format.pretty\" can be used\n    in git log/show/whatchanged.\n\nthe \"format.pretty\" configuration's design background is that I often use\n\"--pretty=fuller\" on my command line, and different \"--pretty=format:...\"\n on my different local repos, I hope there is a configuration to store this\nto git-config.\n\nafter applying the patch, rev->commit_format in `git log/show/whatchanged`\n will be initialized in the following order:\n1. call to gitconfig will set static fmt_pretty according to git-config:\n   if the user never config \"format.pretty\", fmt_pretty doesn't need to be\n   initialized;\n2. rev->commit_format set to CMIT_FMT_DEFAULT in init_revisions;\n3. set rev->commit_format according to fmt_pretty if the user has configured\n   \"format.pretty\" in git-config;\n4. setup_revisions will accept \"--pretty=\" from the command line;\n\nso the pretty format's setting precedence is:\n1. the command line \"--pretty=\";\n2. \"format.pretty\" from the gitconfig;\n3. default CMIT_FMT_DEFAULT;\n\nhere documentation of `git config/log/show/whatchanged` also updated.\n\nSigned-off-by: Denis Cheng <crquan@gmail.com>\n---\n Documentation/config.txt          |    5 +++++\n Documentation/git-whatchanged.txt |    9 ++++-----\n Documentation/pretty-options.txt  |    8 ++++++++\n builtin-log.c                     |   10 +++++++++-\n 4 files changed, 26 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4027726..8a0dff9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -556,6 +556,11 @@ format.suffix::\n \t`.patch`. Use this variable to change that suffix (make sure to\n \tinclude the dot if you want it).\n \n+format.pretty::\n+\tThe default pretty format for log/show/whatchanged command,\n+\tSee linkgit:git-log[1], linkgit:git-show[1],\n+\tlinkgit:git-whatchanged[1].\n+\n gc.aggressiveWindow::\n \tThe window size parameter used in the delta compression\n \talgorithm used by 'git gc --aggressive'.  This defaults\ndiff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt\nindex 54947b6..a6e7bd4 100644\n--- a/Documentation/git-whatchanged.txt\n+++ b/Documentation/git-whatchanged.txt\n@@ -38,11 +38,6 @@ OPTIONS\n \tShow git internal diff output, but for the whole tree,\n \tnot just the top level.\n \n---pretty=<format>::\n-\tControls the output format for the commit logs.\n-\t<format> can be one of 'raw', 'medium', 'short', 'full',\n-\tand 'oneline'.\n-\n -m::\n \tBy default, differences for merge commits are not shown.\n \tWith this flag, show differences to that commit from all\n@@ -51,6 +46,10 @@ OPTIONS\n However, it is not very useful in general, although it\n *is* useful on a file-by-file basis.\n \n+include::pretty-options.txt[]\n+\n+include::pretty-formats.txt[]\n+\n Examples\n --------\n git-whatchanged -p v2.6.12.. include/scsi drivers/scsi::\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex 973d8dd..15e01fa 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -4,6 +4,14 @@\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n \t'full', 'fuller', 'email', 'raw' and 'format:<string>'.\n \tWhen omitted, the format defaults to 'medium'.\n++\n+Note: now you can specify the default pretty format in the repository\n+configuration (see linkgit:git-config[1]), like this in .git/config:\n++\n+-----------------------\n+[format]\n+\tpretty = fuller\n+-----------------------\n \n --abbrev-commit::\n \tInstead of showing the full 40-byte hexadecimal commit object\ndiff --git a/builtin-log.c b/builtin-log.c\nindex bbadbc0..0f7ee1f 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -20,6 +20,7 @@\n \n static int default_show_root = 1;\n static const char *fmt_patch_subject_prefix = \"PATCH\";\n+static const char *fmt_pretty;\n \n static void add_name_decoration(const char *prefix, const char *name, struct object *obj)\n {\n@@ -53,7 +54,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \tint decorate = 0;\n \n \trev->abbrev = DEFAULT_ABBREV;\n-\trev->commit_format = CMIT_FMT_DEFAULT;\n+\tif (fmt_pretty)\n+\t\trev->commit_format = get_commit_format(fmt_pretty);\n \trev->verbose_header = 1;\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n@@ -221,6 +223,12 @@ static int cmd_log_walk(struct rev_info *rev)\n \n static int git_log_config(const char *var, const char *value)\n {\n+\tif (!strcmp(var, \"format.pretty\")) {\n+\t\tif (!value)\n+\t\t\tconfig_error_nonbool(var);\n+\t\tfmt_pretty = xstrdup(value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"format.subjectprefix\")) {\n \t\tif (!value)\n \t\t\tconfig_error_nonbool(var);\n-- \n1.5.4.2\n\n"},{"id":"70546","messageId":"alpine.LSU.1.00.0803011821420.22527@racer.site","threadId":"12383","inReplyTo":"1204391724-566-1-git-send-email-crquan@gmail.com","subject":"Re: [PATCH] add pretty format configuration to git log/show/whatchanged","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-03-01T18:22:10Z","receivedAt":"2008-03-01T18:22:10Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 2 Mar 2008, Denis Cheng wrote:\n\n> diff --git a/builtin-log.c b/builtin-log.c\n> index bbadbc0..0f7ee1f 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -20,6 +20,7 @@\n>  \n>  static int default_show_root = 1;\n>  static const char *fmt_patch_subject_prefix = \"PATCH\";\n> +static const char *fmt_pretty;\n\nI still think this should default to CMIT_FMT_DEFAULT.\n\nCiao,\nDscho\n"},{"id":"70549","messageId":"1204401056-8763-1-git-send-email-crquan@gmail.com","threadId":"12383","inReplyTo":"alpine.LSU.1.00.0803011821420.22527@racer.site","subject":"[PATCH] add pretty format configuration to git log/show/whatchanged","fromName":"Denis Cheng","fromEmail":"crquan@gmail.com","sentAt":"2008-03-01T19:50:56Z","receivedAt":"2008-03-01T19:50:56Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":" * New configuration variable \"format.pretty\" can be used\n    in git log/show/whatchanged.\n\nthe \"format.pretty\" configuration's design background is that I often use\n\"--pretty=fuller\" on my command line, and different \"--pretty=format:...\"\n on my different local repos, I hope there is a configuration to store this\nto git-config, and I think many people also need this to avoid specifying\n\"--pretty=...\" every time.\n\nwith applying the patch, code in `git log/show/whatchanged` executed in\nthe following order:\n1. call to gitconfig will set static fmt_pretty according to user's git-config:\n   if the user never config \"format.pretty\", fmt_pretty doesn't need to be\n   initialized;\n2. rev->commit_format set to CMIT_FMT_DEFAULT in init_revisions;\n3. set rev->commit_format according to fmt_pretty if the user has configured\n   \"format.pretty\" in git-config, else default to CMIT_FMT_DEFAULT;\n4. setup_revisions will accept \"--pretty=\" from the command line;\n\nso the pretty format's setting precedence will be:\n1. the command line \"--pretty=\";\n2. \"format.pretty\" from the git-config;\n3. default CMIT_FMT_DEFAULT;\n\nhere documentation of `git config/log/show/whatchanged` also updated.\n\nSigned-off-by: Denis Cheng <crquan@gmail.com>\n---\nto Johannes: rev->commit_format default to CMIT_FMT_DEFAULT instead of fmt_pretty\ncould avoid an extra call to get_commit_format.\n---\n Documentation/config.txt          |    5 +++++\n Documentation/git-whatchanged.txt |    9 ++++-----\n Documentation/pretty-options.txt  |    8 ++++++++\n builtin-log.c                     |    9 +++++++++\n 4 files changed, 26 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4027726..8a0dff9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -556,6 +556,11 @@ format.suffix::\n \t`.patch`. Use this variable to change that suffix (make sure to\n \tinclude the dot if you want it).\n \n+format.pretty::\n+\tThe default pretty format for log/show/whatchanged command,\n+\tSee linkgit:git-log[1], linkgit:git-show[1],\n+\tlinkgit:git-whatchanged[1].\n+\n gc.aggressiveWindow::\n \tThe window size parameter used in the delta compression\n \talgorithm used by 'git gc --aggressive'.  This defaults\ndiff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt\nindex 54947b6..a6e7bd4 100644\n--- a/Documentation/git-whatchanged.txt\n+++ b/Documentation/git-whatchanged.txt\n@@ -38,11 +38,6 @@ OPTIONS\n \tShow git internal diff output, but for the whole tree,\n \tnot just the top level.\n \n---pretty=<format>::\n-\tControls the output format for the commit logs.\n-\t<format> can be one of 'raw', 'medium', 'short', 'full',\n-\tand 'oneline'.\n-\n -m::\n \tBy default, differences for merge commits are not shown.\n \tWith this flag, show differences to that commit from all\n@@ -51,6 +46,10 @@ OPTIONS\n However, it is not very useful in general, although it\n *is* useful on a file-by-file basis.\n \n+include::pretty-options.txt[]\n+\n+include::pretty-formats.txt[]\n+\n Examples\n --------\n git-whatchanged -p v2.6.12.. include/scsi drivers/scsi::\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex 973d8dd..15e01fa 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -4,6 +4,14 @@\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n \t'full', 'fuller', 'email', 'raw' and 'format:<string>'.\n \tWhen omitted, the format defaults to 'medium'.\n++\n+Note: now you can specify the default pretty format in the repository\n+configuration (see linkgit:git-config[1]), like this in .git/config:\n++\n+-----------------------\n+[format]\n+\tpretty = fuller\n+-----------------------\n \n --abbrev-commit::\n \tInstead of showing the full 40-byte hexadecimal commit object\ndiff --git a/builtin-log.c b/builtin-log.c\nindex bbadbc0..23c05bc 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -20,6 +20,7 @@\n \n static int default_show_root = 1;\n static const char *fmt_patch_subject_prefix = \"PATCH\";\n+static const char *fmt_pretty;\n \n static void add_name_decoration(const char *prefix, const char *name, struct object *obj)\n {\n@@ -54,6 +55,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \n \trev->abbrev = DEFAULT_ABBREV;\n \trev->commit_format = CMIT_FMT_DEFAULT;\n+\tif (fmt_pretty)\n+\t\trev->commit_format = get_commit_format(fmt_pretty);\n \trev->verbose_header = 1;\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n@@ -221,6 +224,12 @@ static int cmd_log_walk(struct rev_info *rev)\n \n static int git_log_config(const char *var, const char *value)\n {\n+\tif (!strcmp(var, \"format.pretty\")) {\n+\t\tif (!value)\n+\t\t\tconfig_error_nonbool(var);\n+\t\tfmt_pretty = xstrdup(value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(var, \"format.subjectprefix\")) {\n \t\tif (!value)\n \t\t\tconfig_error_nonbool(var);\n-- \n1.5.4.2\n\n"},{"id":"70574","messageId":"7vr6etvlgm.fsf@gitster.siamese.dyndns.org","threadId":"12383","inReplyTo":"1204401056-8763-1-git-send-email-crquan@gmail.com","subject":"Re: [PATCH] add pretty format configuration to git log/show/whatchanged","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-02T03:44:25Z","receivedAt":"2008-03-02T03:44:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denis Cheng <crquan@gmail.com> writes:\n\n>  * New configuration variable \"format.pretty\" can be used\n>     in git log/show/whatchanged.\n>\n> the \"format.pretty\" configuration's design background is that I often use\n> \"--pretty=fuller\" on my command line, and different \"--pretty=format:...\"\n>  on my different local repos, I hope there is a configuration to store this\n> to git-config, and I think many people also need this to avoid specifying\n> \"--pretty=...\" every time.\n\nI had to wonder what foreign project this commit log format message was\nborrowed from.  also, in english, each sentence begins with a capital\nletter.  not only the the first sentence ;-).\n\n> with applying the patch, code in `git log/show/whatchanged` executed in\n> the following order:\n> 1. call to gitconfig will set static fmt_pretty according to user's git-config:\n>    if the user never config \"format.pretty\", fmt_pretty doesn't need to be\n>    initialized;\n> 2. rev->commit_format set to CMIT_FMT_DEFAULT in init_revisions;\n> 3. set rev->commit_format according to fmt_pretty if the user has configured\n>    \"format.pretty\" in git-config, else default to CMIT_FMT_DEFAULT;\n> 4. setup_revisions will accept \"--pretty=\" from the command line;\n\nIt is good to show that you looked at the codepath, but I think this can\ngo after the three-dashes line.  But what this part describes.\n\n> so the pretty format's setting precedence will be:\n> 1. the command line \"--pretty=\";\n> 2. \"format.pretty\" from the git-config;\n> 3. default CMIT_FMT_DEFAULT;\n\nis a must-have in the commit log message.  The precedence order looks\nsane.\n\nBy the way, I also share the concern Linus raised earlier that end-user\nconfiguration may break existing scripts.\n\nIn-tree, there are only two callers that do not use --pretty on the\ncommand line when calling these three commands:\n\n * \"bisect visualize\" calls \"git log\" when gitk is not available, with the\n   user supplied formatting options.  This is very much Ok --- we actively\n   want your configuration feature for this caller.\n\n * \"git merge --squash\" calls \"git log\" to prepare the commit message\n   template.  This is _not_ Ok, and will be broken if we accept your\n   patch.\n\nSo you will need a preliminary patch to \"git-merge\" _before_ submitting\nthis patch to make the latter codepath use \"git log --pretty\" instead.\nDoing so would have raised _my_ confidence level of the patch that you\nmade your best effort not to introduce regression.\n\n> diff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt\n> index 54947b6..a6e7bd4 100644\n> --- a/Documentation/git-whatchanged.txt\n> +++ b/Documentation/git-whatchanged.txt\n> @@ -38,11 +38,6 @@ OPTIONS\n>  \tShow git internal diff output, but for the whole tree,\n>  \tnot just the top level.\n>  \n> ---pretty=<format>::\n> -\tControls the output format for the commit logs.\n> -\t<format> can be one of 'raw', 'medium', 'short', 'full',\n> -\tand 'oneline'.\n> -\n>  -m::\n>  \tBy default, differences for merge commits are not shown.\n>  \tWith this flag, show differences to that commit from all\n> @@ -51,6 +46,10 @@ OPTIONS\n>  However, it is not very useful in general, although it\n>  *is* useful on a file-by-file basis.\n>  \n> +include::pretty-options.txt[]\n> +\n> +include::pretty-formats.txt[]\n> +\n>  Examples\n>  --------\n>  git-whatchanged -p v2.6.12.. include/scsi drivers/scsi::\n\nWhile this may be a sensible clean-up (note: I didn't actually formatted\nthe results and proofread it), it does not belong to your topic, does it?\nIt is also a preliminary clean-up before your change.\n\n> diff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\n> index 973d8dd..15e01fa 100644\n> --- a/Documentation/pretty-options.txt\n> +++ b/Documentation/pretty-options.txt\n> @@ -4,6 +4,14 @@\n>  \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n>  \t'full', 'fuller', 'email', 'raw' and 'format:<string>'.\n>  \tWhen omitted, the format defaults to 'medium'.\n> ++\n> +Note: now you can specify the default pretty format in the repository\n> +configuration (see linkgit:git-config[1]), like this in .git/config:\n\nIn the commit log message, it is very sane to say \"earlier we couldn't but\nnow we can\", but in the end-user documentation we should avoid that.  The\ndocumentation does not talk only to git old timers, but should be written\nfor first time readers as well.  Drop \"now\".\n\n> diff --git a/builtin-log.c b/builtin-log.c\n> index bbadbc0..23c05bc 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -221,6 +224,12 @@ static int cmd_log_walk(struct rev_info *rev)\n>  \n>  static int git_log_config(const char *var, const char *value)\n>  {\n> +\tif (!strcmp(var, \"format.pretty\")) {\n> +\t\tif (!value)\n> +\t\t\tconfig_error_nonbool(var);\n> +\t\tfmt_pretty = xstrdup(value);\n> +\t\treturn 0;\n> +\t}\n\nThese days, this can be written as:\n\n\tif (!strcmp(var, \"format.pretty\"))\n\t\treturn git_config_string(&fmt_pretty, var, value);\n\nOther than that, I think it is reasonably well done.\n\nMy suggestion would be to (re)do this as three series of patches:\n\n [1/3] whatchanged documentation: share description of --pretty with others\n\n    The documentation had its own description for --pretty and did not\n    include pretty-options/formats as documentation for other commands in\n    the \"log\" family did.\n\n [2/3] merge --squash: explicitly ask for --pretty when preparing the message\n\n    \"git-merge --squash\" uses \"git log\" when preparing the commit log\n    message template without passing --pretty.\n\n    When format.pretty configuration variable is used by the end user,\n    this will result in the message template to be formatted with the\n    configured format, regressing the current behaviour.\n\n    This commit makes it explicitly ask for the default pretty format by\n    passing the --pretty option when running \"git log\".\n\n [3/3] log/show/whatchanged: introduce format.pretty configuration\n\n    When running log/show/whatchanged from the command line, the user may\n    want to use a preferred format without having to pass --pretty=<fmt>\n    option every time from the command line.  This teaches these three\n    commands to honor a new configuration variable, format.pretty.\n\n    The --pretty option given from the command line will override the\n    configured format.\n\n    The earlier patch fixed the only in-tree caller that runs these\n    commands for a purpose other than showing the output directly to the\n    end user (the other in-tree caller is \"git bisect visualize\", whose\n    output directly goes to the end user and should be affected by this\n    patch).  Similar fixes will be needed for end-user scripts that expect\n    the output from these commands to be in the default pretty format\n    (i.e. for the purpose of parsing it themselves).\n\nThanks.\n"},{"id":"70585","messageId":"7vve45tzoe.fsf@gitster.siamese.dyndns.org","threadId":"12383","inReplyTo":"7vr6etvlgm.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] add pretty format configuration to git log/show/whatchanged","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-02T06:20:17Z","receivedAt":"2008-03-02T06:20:17Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> In-tree, there are only two callers that do not use --pretty on the\n> command line when calling these three commands:\n>\n>  * \"bisect visualize\" calls \"git log\" when gitk is not available, with the\n>    user supplied formatting options.  This is very much Ok --- we actively\n>    want your configuration feature for this caller.\n>\n>  * \"git merge --squash\" calls \"git log\" to prepare the commit message\n>    template.  This is _not_ Ok, and will be broken if we accept your\n>    patch.\n>\n> So you will need a preliminary patch to \"git-merge\" _before_ submitting\n> this patch to make the latter codepath use \"git log --pretty\" instead.\n> Doing so would have raised _my_ confidence level of the patch that you\n> made your best effort not to introduce regression.\n\nI should point out that I did not look at things outside shell scripts,\ni.e. stuff I do not consider really the core part of the system.  I did\nnot look at contrib/ area either.\n\nI suspect the following have calls to show/log/whatchanged and do expect\nto read the default format out of them, and can be broken by your patch:\n\n * contrib/emacs/git.el (git-setup-commit-buffer)\n * git-cvsserver.perl (sub update)\n\nThere also is a call to git log, but I think it is Ok.\n\n * contrib/hooks/post-receive (generate_general_email)\n\nYou should not blindly trust nor take the above as an exhaustive list; it\nis just from my quick survey.\n"},{"id":"70606","messageId":"1204448753-4471-1-git-send-email-crquan@gmail.com","threadId":"12383","inReplyTo":"7vr6etvlgm.fsf@gitster.siamese.dyndns.org","subject":"[PATCH 1/3] whatchanged documentation: share description of --pretty with others","fromName":"Denis Cheng","fromEmail":"crquan@gmail.com","sentAt":"2008-03-02T09:05:51Z","receivedAt":"2008-03-02T09:05:51Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":"The documentation had its own description for --pretty and did not\ninclude pretty-options/formats as documentation for other commands in\nthe \"log\" family did.\n\nSigned-off-by: Denis Cheng <crquan@gmail.com>\n---\n Documentation/git-whatchanged.txt |    9 ++++-----\n 1 files changed, 4 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/git-whatchanged.txt b/Documentation/git-whatchanged.txt\nindex 54947b6..a6e7bd4 100644\n--- a/Documentation/git-whatchanged.txt\n+++ b/Documentation/git-whatchanged.txt\n@@ -38,11 +38,6 @@ OPTIONS\n \tShow git internal diff output, but for the whole tree,\n \tnot just the top level.\n \n---pretty=<format>::\n-\tControls the output format for the commit logs.\n-\t<format> can be one of 'raw', 'medium', 'short', 'full',\n-\tand 'oneline'.\n"},{"id":"70607","messageId":"1204448753-4471-2-git-send-email-crquan@gmail.com","threadId":"12383","inReplyTo":"1204448753-4471-1-git-send-email-crquan@gmail.com","subject":"[PATCH 2/3] specify explicit \"--pretty=medium\" with `git log/show/whatchanged`","fromName":"Denis Cheng","fromEmail":"crquan@gmail.com","sentAt":"2008-03-02T09:05:52Z","receivedAt":"2008-03-02T09:05:52Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":"The following patch will introduce a new configuration variable,\n\"format.pretty\", from then on the pretty format without specifying\n\"--pretty\" might not be the default \"--pretty=medium\", it depends on\nthe user's config. So all kinds of Shell/Perl/Emacs scripts that needs\nthe default medium pretty format must specify it explicitly.\n\nSigned-off-by: Denis Cheng <crquan@gmail.com>\n---\n contrib/emacs/git.el             |    2 +-\n contrib/hooks/post-receive-email |    2 +-\n git-cvsserver.perl               |    2 +-\n git-merge.sh                     |    2 +-\n 4 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/emacs/git.el b/contrib/emacs/git.el\nindex c926823..4fa853f 100644\n--- a/contrib/emacs/git.el\n+++ b/contrib/emacs/git.el\n@@ -1299,7 +1299,7 @@ Return the list of files that haven't been handled.\"\n   (let (author-name author-email subject date msg)\n     (with-temp-buffer\n       (let ((coding-system (git-get-logoutput-coding-system)))\n-        (git-call-process-env t nil \"log\" \"-1\" commit)\n+        (git-call-process-env t nil \"log\" \"-1\" \"--pretty=medium\" commit)\n         (goto-char (point-min))\n         (when (re-search-forward \"^Author: *\\\\(.*\\\\) <\\\\(.*\\\\)>$\" nil t)\n           (setq author-name (match-string 1))\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 77c88eb..62a740c 100644\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -567,7 +567,7 @@ generate_general_email()\n \techo \"\"\n \tif [ \"$newrev_type\" = \"commit\" ]; then\n \t\techo $LOGBEGIN\n-\t\tgit show --no-color --root -s $newrev\n+\t\tgit show --no-color --root -s --pretty=medium $newrev\n \t\techo $LOGEND\n \telse\n \t\t# What can we do here?  The tag marks an object that is not\ndiff --git a/git-cvsserver.perl b/git-cvsserver.perl\nindex afe3d0b..7f632af 100755\n--- a/git-cvsserver.perl\n+++ b/git-cvsserver.perl\n@@ -2556,7 +2556,7 @@ sub update\n                     if ($base) {\n                         my @merged;\n                         # print \"want to log between  $base $parent \\n\";\n-                        open(GITLOG, '-|', 'git-log', \"$base..$parent\")\n+                        open(GITLOG, '-|', 'git-log', '--pretty=medium', \"$base..$parent\")\n \t\t\t  or die \"Cannot call git-log: $!\";\n                         my $mergedhash;\n                         while (<GITLOG>) {\ndiff --git a/git-merge.sh b/git-merge.sh\nindex 1c123a3..39aa5f5 100755\n--- a/git-merge.sh\n+++ b/git-merge.sh\n@@ -70,7 +70,7 @@ finish_up_to_date () {\n squash_message () {\n \techo Squashed commit of the following:\n \techo\n-\tgit log --no-merges ^\"$head\" $remoteheads\n+\tgit log --no-merges --pretty=medium ^\"$head\" $remoteheads\n }\n \n finish () {\n-- \n1.5.4.3.368.g2bb0a\n\n"},{"id":"70608","messageId":"1204448753-4471-3-git-send-email-crquan@gmail.com","threadId":"12383","inReplyTo":"1204448753-4471-2-git-send-email-crquan@gmail.com","subject":"[PATCH 3/3] log/show/whatchanged: introduce format.pretty configuration","fromName":"Denis Cheng","fromEmail":"crquan@gmail.com","sentAt":"2008-03-02T09:05:53Z","receivedAt":"2008-03-02T09:05:53Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":"When running log/show/whatchanged from the command line, the user may\nwant to use a preferred format without having to pass --pretty=<fmt>\noption every time from the command line.  This teaches these three\ncommands to honor a new configuration variable, format.pretty.\n\nThe --pretty option given from the command line will override the\nconfigured format.\n\nThe earlier patch fixed the only in-tree caller that runs these\ncommands for a purpose other than showing the output directly to the\nend user (the other in-tree caller is \"git bisect visualize\", whose\noutput directly goes to the end user and should be affected by this\npatch).\n\nSigned-off-by: Denis Cheng <crquan@gmail.com>\n---\n Documentation/config.txt         |    5 +++++\n Documentation/pretty-options.txt |    8 ++++++++\n builtin-log.c                    |    5 +++++\n 3 files changed, 18 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 4027726..8a0dff9 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -556,6 +556,11 @@ format.suffix::\n \t`.patch`. Use this variable to change that suffix (make sure to\n \tinclude the dot if you want it).\n \n+format.pretty::\n+\tThe default pretty format for log/show/whatchanged command,\n+\tSee linkgit:git-log[1], linkgit:git-show[1],\n+\tlinkgit:git-whatchanged[1].\n+\n gc.aggressiveWindow::\n \tThe window size parameter used in the delta compression\n \talgorithm used by 'git gc --aggressive'.  This defaults\ndiff --git a/Documentation/pretty-options.txt b/Documentation/pretty-options.txt\nindex 973d8dd..f86b0cc 100644\n--- a/Documentation/pretty-options.txt\n+++ b/Documentation/pretty-options.txt\n@@ -4,6 +4,14 @@\n \twhere '<format>' can be one of 'oneline', 'short', 'medium',\n \t'full', 'fuller', 'email', 'raw' and 'format:<string>'.\n \tWhen omitted, the format defaults to 'medium'.\n++\n+Note: you can specify the default pretty format in the repository\n+configuration (see linkgit:git-config[1]), like this in .git/config:\n++\n+-----------------------\n+[format]\n+\tpretty = fuller\n+-----------------------\n \n --abbrev-commit::\n \tInstead of showing the full 40-byte hexadecimal commit object\ndiff --git a/builtin-log.c b/builtin-log.c\nindex bbadbc0..67f13ff 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -20,6 +20,7 @@\n \n static int default_show_root = 1;\n static const char *fmt_patch_subject_prefix = \"PATCH\";\n+static const char *fmt_pretty;\n \n static void add_name_decoration(const char *prefix, const char *name, struct object *obj)\n {\n@@ -54,6 +55,8 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \n \trev->abbrev = DEFAULT_ABBREV;\n \trev->commit_format = CMIT_FMT_DEFAULT;\n+\tif (fmt_pretty)\n+\t\trev->commit_format = get_commit_format(fmt_pretty);\n \trev->verbose_header = 1;\n \tDIFF_OPT_SET(&rev->diffopt, RECURSIVE);\n \trev->show_root_diff = default_show_root;\n@@ -221,6 +224,8 @@ static int cmd_log_walk(struct rev_info *rev)\n \n static int git_log_config(const char *var, const char *value)\n {\n+\tif (!strcmp(var, \"format.pretty\"))\n+\t\treturn git_config_string(&fmt_pretty, var, value);\n \tif (!strcmp(var, \"format.subjectprefix\")) {\n \t\tif (!value)\n \t\t\tconfig_error_nonbool(var);\n-- \n1.5.4.3.368.g2bb0a\n\n"},{"id":"70664","messageId":"7vod9xoyc5.fsf@gitster.siamese.dyndns.org","threadId":"12383","inReplyTo":"1204448753-4471-2-git-send-email-crquan@gmail.com","subject":"Re: [PATCH 2/3] specify explicit \"--pretty=medium\" with `git log/show/whatchanged`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-02T17:00:26Z","receivedAt":"2008-03-02T17:00:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denis Cheng <crquan@gmail.com> writes:\n\n> The following patch will introduce a new configuration variable,\n> \"format.pretty\", from then on the pretty format without specifying\n> \"--pretty\" might not be the default \"--pretty=medium\", it depends on\n> the user's config. So all kinds of Shell/Perl/Emacs scripts that needs\n> the default medium pretty format must specify it explicitly.\n>\n> Signed-off-by: Denis Cheng <crquan@gmail.com>\n> ---\n>  contrib/emacs/git.el             |    2 +-\n>  contrib/hooks/post-receive-email |    2 +-\n>  git-cvsserver.perl               |    2 +-\n>  git-merge.sh                     |    2 +-\n>  4 files changed, 4 insertions(+), 4 deletions(-)\n\nI think --pretty is enough and you do not have to say --pretty=medium, but\nas long as we are being explicit, we'd better be fully explicit to future\nproof them.\n\nThe list of in-tree users and places match what I found with my quick\nreview, which hopefully means both of us did our best effort to catch\npotential breakages.\n\nThanks.\n\n\n"},{"id":"70665","messageId":"7vir05oybp.fsf@gitster.siamese.dyndns.org","threadId":"12383","inReplyTo":"1204448753-4471-3-git-send-email-crquan@gmail.com","subject":"Re: [PATCH 3/3] log/show/whatchanged: introduce format.pretty configuration","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-03-02T17:00:42Z","receivedAt":"2008-03-02T17:00:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Denis Cheng <crquan@gmail.com> writes:\n\n> When running log/show/whatchanged from the command line, the user may\n> want to use a preferred format without having to pass --pretty=<fmt>\n> option every time from the command line.  This teaches these three\n> commands to honor a new configuration variable, format.pretty.\n>\n> The --pretty option given from the command line will override the\n> configured format.\n>\n> The earlier patch fixed the only in-tree caller that runs these\n> commands for a purpose other than showing the output directly to the\n> end user (the other in-tree caller is \"git bisect visualize\", whose\n> output directly goes to the end user and should be affected by this\n> patch).\n>\n> Signed-off-by: Denis Cheng <crquan@gmail.com>\n\nI see you pretty much copied my suggested commit log messages except that\nyou dropped the warning about the need to adjust out-of-tree scripts by\nend users from this one.  I however think that was the most important\npart.  We need to warn our users fairly aggressively in Release Notes\nabout possible compatibility issues, and commit log messages are one of\nthe most important sources for that.\n\nIncidentally, I noticed only one when I wrote the above but now we have\nmore, so \"the only in-tree caller that runs\" part is totally bogus.\n\nNo need to resend anything, as I can manage with these three messages.\n\nThanks.\n"},{"id":"70669","messageId":"91b13c310803020912u44dea924ked9684e3e3537111@mail.gmail.com","threadId":"12383","inReplyTo":"7vir05oybp.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH 3/3] log/show/whatchanged: introduce format.pretty configuration","fromName":"rae l","fromEmail":"crquan@gmail.com","sentAt":"2008-03-02T17:12:28Z","receivedAt":"2008-03-02T17:12:28Z","isPatch":true,"sender":{"key":"crquan@gmail.com","avatar":"https://gravatar.com/avatar/8689a8a26f5d1c7515ca8226258710684dac5c5208b84a9e16a086377f2d3ded?d=mp&s=160"},"body":"On Mon, Mar 3, 2008 at 1:00 AM, Junio C Hamano <gitster@pobox.com> wrote:\n>  I see you pretty much copied my suggested commit log messages except that\n>  you dropped the warning about the need to adjust out-of-tree scripts by\n>  end users from this one.  I however think that was the most important\n>  part.  We need to warn our users fairly aggressively in Release Notes\n>  about possible compatibility issues, and commit log messages are one of\n>  the most important sources for that.\n>\n>  Incidentally, I noticed only one when I wrote the above but now we have\n>  more, so \"the only in-tree caller that runs\" part is totally bogus.\n>\n>  No need to resend anything, as I can manage with these three messages.\nThanks. :-)\n"}]}