{"thread":{"id":"20602","subject":"[PATCH] git-log: allow --decorate[=short|full]","startedAt":"2009-08-15T09:50:25Z","lastAt":"2009-08-18T20:18:23Z","messageCount":6,"participants":["Lars Hjemli","Jeff King","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"120694","messageId":"8c5c35580908150250y62b1042cmf6071016bac98a48@mail.gmail.com","threadId":"20602","inReplyTo":null,"subject":"[PATCH] git-log: allow --decorate[=short|full]","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2009-08-15T09:50:25Z","receivedAt":"2009-08-15T09:50:25Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"This extension to --decorate makes it possible to generate decorations\nsimilar to pre-1.6.4 git, which is nice when the output from git-log\nis used by external tools.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n Documentation/git-log.txt                          |    6 ++++--\n builtin-log.c                                      |   12 ++++++++++--\n log-tree.c                                         |    7 ++++---\n log-tree.h                                         |    2 +-\n pretty.c                                           |    2 +-\n revision.c                                         |    2 +-\n revision.h                                         |    6 +++++-\n t/t4013-diff-various.sh                            |    1 +\n ...corate_--all => diff.log_--decorate=full_--all} |    8 ++++----\n 9 files changed, 31 insertions(+), 15 deletions(-)\n copy t/t4013/{diff.log_--decorate_--all =>\ndiff.log_--decorate=full_--all} (72%)\n\ndiff --git a/Documentation/git-log.txt b/Documentation/git-log.txt\nindex 34cf4e5..451839c 100644\n--- a/Documentation/git-log.txt\n+++ b/Documentation/git-log.txt\n@@ -37,8 +37,10 @@ include::diff-options.txt[]\n \tand <until>, see \"SPECIFYING REVISIONS\" section in\n \tlinkgit:git-rev-parse[1].\n\n---decorate::\n-\tPrint out the ref names of any commits that are shown.\n+--decorate[=short|full]::\n+\tPrint out the ref names of any commits that are shown. If 'short' is\n+\tspecified, the ref names will be shortened, and if 'full' is specified,\n+\tthe ref names will not be shortened. The default option is 'short'.\n\n --source::\n \tPrint out the ref name given on the command line by which each\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 3817bf1..cb886d8 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -61,8 +61,14 @@ static void cmd_log_init(int argc, const char\n**argv, const char *prefix,\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tif (!strcmp(arg, \"--decorate\")) {\n-\t\t\tload_ref_decorations();\n-\t\t\trev->show_decorations = 1;\n+\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n+\t\t} else if (!strncmp(arg, \"--decorate=\", 11)) {\n+\t\t\tif (!strcmp(arg + 11, \"full\"))\n+\t\t\t\trev->show_decorations = DECORATE_FULL_REFS;\n+\t\t\telse if (!strcmp(arg + 11, \"short\"))\n+\t\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n+\t\t\telse\n+\t\t\t\tdie(\"invalid --decorate option: %s\", arg + 11);\n \t\t} else if (!strcmp(arg, \"--source\")) {\n \t\t\trev->show_source = 1;\n \t\t} else if (!strcmp(arg, \"-h\")) {\n@@ -70,6 +76,8 @@ static void cmd_log_init(int argc, const char\n**argv, const char *prefix,\n \t\t} else\n \t\t\tdie(\"unrecognized argument: %s\", arg);\n \t}\n+\tif (rev->show_decorations)\n+\t\tload_ref_decorations(rev->show_decorations);\n }\n\n /*\ndiff --git a/log-tree.c b/log-tree.c\nindex 6f73c17..70223eb 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -25,7 +25,8 @@ static int add_ref_decoration(const char *refname,\nconst unsigned char *sha1, in\n \tstruct object *obj = parse_object(sha1);\n \tif (!obj)\n \t\treturn 0;\n-\trefname = prettify_refname(refname);\n+\tif (!cb_data || *(int *)cb_data & DECORATE_SHORT_REFS)\n+\t\trefname = prettify_refname(refname);\n \tadd_name_decoration(\"\", refname, obj);\n \twhile (obj->type == OBJ_TAG) {\n \t\tobj = ((struct tag *)obj)->tagged;\n@@ -36,12 +37,12 @@ static int add_ref_decoration(const char *refname,\nconst unsigned char *sha1, in\n \treturn 0;\n }\n\n-void load_ref_decorations(void)\n+void load_ref_decorations(int flags)\n {\n \tstatic int loaded;\n \tif (!loaded) {\n \t\tloaded = 1;\n-\t\tfor_each_ref(add_ref_decoration, NULL);\n+\t\tfor_each_ref(add_ref_decoration, &flags);\n \t}\n }\n\ndiff --git a/log-tree.h b/log-tree.h\nindex 20b5caf..3f7b400 100644\n--- a/log-tree.h\n+++ b/log-tree.h\n@@ -17,7 +17,7 @@ void log_write_email_headers(struct rev_info *opt,\nstruct commit *commit,\n \t\t\t     const char **subject_p,\n \t\t\t     const char **extra_headers_p,\n \t\t\t     int *need_8bit_cte_p);\n-void load_ref_decorations(void);\n+void load_ref_decorations(int flags);\n\n #define FORMAT_PATCH_NAME_MAX 64\n void get_patch_filename(struct commit *commit, int nr, const char *suffix,\ndiff --git a/pretty.c b/pretty.c\nindex e5328da..daa721b 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -571,7 +571,7 @@ static void format_decoration(struct strbuf *sb,\nconst struct commit *commit)\n \tstruct name_decoration *d;\n \tconst char *prefix = \" (\";\n\n-\tload_ref_decorations();\n+\tload_ref_decorations(DECORATE_SHORT_REFS);\n \td = lookup_decoration(&name_decoration, &commit->object);\n \twhile (d) {\n \t\tstrbuf_addstr(sb, prefix);\ndiff --git a/revision.c b/revision.c\nindex 9f5dac5..ce24ad9 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1052,7 +1052,7 @@ static int handle_revision_opt(struct rev_info\n*revs, int argc, const char **arg\n \t\trevs->simplify_by_decoration = 1;\n \t\trevs->limited = 1;\n \t\trevs->prune = 1;\n-\t\tload_ref_decorations();\n+\t\tload_ref_decorations(DECORATE_SHORT_REFS);\n \t} else if (!strcmp(arg, \"--date-order\")) {\n \t\trevs->lifo = 0;\n \t\trevs->topo_order = 1;\ndiff --git a/revision.h b/revision.h\nindex fb74492..16e65f6 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -15,6 +15,10 @@\n #define SYMMETRIC_LEFT\t(1u<<8)\n #define ALL_REV_FLAGS\t((1u<<9)-1)\n\n+\n+#define DECORATE_SHORT_REFS\t1\n+#define DECORATE_FULL_REFS\t2\n+\n struct rev_info;\n struct log_info;\n\n@@ -56,7 +60,7 @@ struct rev_info {\n \t\t\trewrite_parents:1,\n \t\t\tprint_parents:1,\n \t\t\tshow_source:1,\n-\t\t\tshow_decorations:1,\n+\t\t\tshow_decorations:2,\n \t\t\treverse:1,\n \t\t\treverse_output_stage:1,\n \t\t\tcherry_pick:1,\ndiff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh\nindex 8b33321..8e3694e 100755\n--- a/t/t4013-diff-various.sh\n+++ b/t/t4013-diff-various.sh\n@@ -207,6 +207,7 @@ log --root --cc --patch-with-stat --summary master\n log -SF master\n log -SF -p master\n log --decorate --all\n+log --decorate=full --all\n\n rev-list --parents HEAD\n rev-list --children HEAD\ndiff --git a/t/t4013/diff.log_--decorate_--all\nb/t/t4013/diff.log_--decorate=full_--all\nsimilarity index 72%\ncopy from t/t4013/diff.log_--decorate_--all\ncopy to t/t4013/diff.log_--decorate=full_--all\nindex 954210e..903d9d9 100644\n--- a/t/t4013/diff.log_--decorate_--all\n+++ b/t/t4013/diff.log_--decorate=full_--all\n@@ -1,12 +1,12 @@\n-$ git log --decorate --all\n-commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (master)\n+$ git log --decorate=full --all\n+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (refs/heads/master)\n Merge: 9a6d494 c7a2ab9\n Author: A U Thor <author@example.com>\n Date:   Mon Jun 26 00:04:00 2006 +0000\n\n     Merge branch 'side'\n\n-commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side)\n+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side)\n Author: A U Thor <author@example.com>\n Date:   Mon Jun 26 00:03:00 2006 +0000\n\n@@ -26,7 +26,7 @@ Date:   Mon Jun 26 00:01:00 2006 +0000\n\n     This is the second commit.\n\n-commit 444ac553ac7612cc88969031b02b3767fb8a353a (initial)\n+commit 444ac553ac7612cc88969031b02b3767fb8a353a (refs/heads/initial)\n Author: A U Thor <author@example.com>\n Date:   Mon Jun 26 00:00:00 2006 +0000\n\n-- \n1.6.4.135.g4e5b\n"},{"id":"120704","messageId":"8c5c35580908150326i661a3203kdd82023bb694734d@mail.gmail.com","threadId":"20602","inReplyTo":"8c5c35580908150250y62b1042cmf6071016bac98a48@mail.gmail.com","subject":"Re: [PATCH] git-log: allow --decorate[=short|full]","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2009-08-15T10:26:20Z","receivedAt":"2009-08-15T10:26:20Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"On Sat, Aug 15, 2009 at 11:50, Lars Hjemli<hjemli@gmail.com> wrote:\n> This extension to --decorate makes it possible to generate decorations\n> similar to pre-1.6.4 git, which is nice when the output from git-log\n> is used by external tools.\n\nBTW: the patch was made on top of current master (b2139dbd) - if\naccepted, it might be considered for maint.\n\n--\nlarsh\n"},{"id":"120708","messageId":"20090815122812.GB30630@coredump.intra.peff.net","threadId":"20602","inReplyTo":"8c5c35580908150250y62b1042cmf6071016bac98a48@mail.gmail.com","subject":"Re: [PATCH] git-log: allow --decorate[=short|full]","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-15T12:28:12Z","receivedAt":"2009-08-15T12:28:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 15, 2009 at 11:50:25AM +0200, Lars Hjemli wrote:\n\n> This extension to --decorate makes it possible to generate decorations\n> similar to pre-1.6.4 git, which is nice when the output from git-log\n> is used by external tools.\n\nThis commit message really lacks context.  When I read it, I thought to\nmyself \"what happened to decorations in 1.6.4?\" It really needs to say:\n\n  - exactly what changed\n  - why did it change\n  - why the change has drawbacks\n\nAfter reading the patch and digging through the history, I think you\nwant something more like:\n\n-- >8 --\nCommit de435ac0 changed the behavior of --decorate from printing the\nfull ref (e.g., \"refs/heads/master\") to a shorter, more human-readable\nversion (e.g., just \"master\"). While this is nice for human readers,\nexternal tools using the output from \"git log\" may prefer the full\nversion.\n\nThis patch introduces an extension to --decorate to allow the caller to\nspecify either the short or the full versions.\n-- 8< --\n\nAs for the patch, it mostly looks good, but a few comments:\n\n> +\t\t} else if (!strncmp(arg, \"--decorate=\", 11)) {\n> +\t\t\tif (!strcmp(arg + 11, \"full\"))\n> +\t\t\t\trev->show_decorations = DECORATE_FULL_REFS;\n> +\t\t\telse if (!strcmp(arg + 11, \"short\"))\n> +\t\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n> +\t\t\telse\n> +\t\t\t\tdie(\"invalid --decorate option: %s\", arg + 11);\n\nTo avoid the magic 11's, we have a few helpers:\n\n  if (!prefixcmp(arg, \"--decorate=\")) {\n          const char *v = skip_prefix(arg, \"--decorate=\");\n          ...\n\nthough arguably that is just as bad because you have to repeat the\n\"--decorate=\".\n\n> --- a/revision.h\n> +++ b/revision.h\n> @@ -15,6 +15,10 @@\n>  #define SYMMETRIC_LEFT\t(1u<<8)\n>  #define ALL_REV_FLAGS\t((1u<<9)-1)\n> \n> +\n> +#define DECORATE_SHORT_REFS\t1\n> +#define DECORATE_FULL_REFS\t2\n> +\n\nStyle nit: extra blank line?\n\n> @@ -56,7 +60,7 @@ struct rev_info {\n>  \t\t\trewrite_parents:1,\n>  \t\t\tprint_parents:1,\n>  \t\t\tshow_source:1,\n> -\t\t\tshow_decorations:1,\n> +\t\t\tshow_decorations:2,\n>  \t\t\treverse:1,\n>  \t\t\treverse_output_stage:1,\n>  \t\t\tcherry_pick:1,\n\nShould we perhaps just turn show_decorations into its own variable? It\njust seems like a trap for future maintainers to want to add more\nDECORATE_* flags but not realize they have to keep bumping up the size\nof the bitfield.\n\nAnd rev_info is not a struct that we are particularly trying to optimize\nthe memory on.\n\n> diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh\n> index 8b33321..8e3694e 100755\n> --- a/t/t4013-diff-various.sh\n> +++ b/t/t4013-diff-various.sh\n> @@ -207,6 +207,7 @@ log --root --cc --patch-with-stat --summary master\n>  log -SF master\n>  log -SF -p master\n>  log --decorate --all\n> +log --decorate=full --all\n\nYay, tests.\n\n-Peff\n"},{"id":"120713","messageId":"8c5c35580908150723h6e4c8fcay43b708969a86ae27@mail.gmail.com","threadId":"20602","inReplyTo":"20090815122812.GB30630@coredump.intra.peff.net","subject":"Re: [PATCH] git-log: allow --decorate[=short|full]","fromName":"Lars Hjemli","fromEmail":"hjemli@gmail.com","sentAt":"2009-08-15T14:23:12Z","receivedAt":"2009-08-15T14:23:12Z","isPatch":true,"sender":{"key":"hjemli@gmail.com","avatar":null},"body":"Commit de435ac0 changed the behavior of --decorate from printing the\nfull ref (e.g., \"refs/heads/master\") to a shorter, more human-readable\nversion (e.g., just \"master\"). While this is nice for human readers,\nexternal tools using the output from \"git log\" may prefer the full\nversion.\n\nThis patch introduces an extension to --decorate to allow the caller to\nspecify either the short or the full versions.\n\nSigned-off-by: Lars Hjemli <hjemli@gmail.com>\n---\n\nThanks for the review. I've adapted the patch to your comments, and\nmodified the documentation of '--decorate' to be more specific.\n\n Documentation/git-log.txt                          |    8 ++++++--\n builtin-log.c                                      |   13 +++++++++++--\n log-tree.c                                         |    7 ++++---\n log-tree.h                                         |    2 +-\n pretty.c                                           |    2 +-\n revision.c                                         |    2 +-\n revision.h                                         |    5 ++++-\n t/t4013-diff-various.sh                            |    1 +\n ...corate_--all => diff.log_--decorate=full_--all} |    8 ++++----\n 9 files changed, 33 insertions(+), 15 deletions(-)\n copy t/t4013/{diff.log_--decorate_--all =>\ndiff.log_--decorate=full_--all} (72%)\n\ndiff --git a/Documentation/git-log.txt b/Documentation/git-log.txt\nindex 34cf4e5..3d79de1 100644\n--- a/Documentation/git-log.txt\n+++ b/Documentation/git-log.txt\n@@ -37,8 +37,12 @@ include::diff-options.txt[]\n \tand <until>, see \"SPECIFYING REVISIONS\" section in\n \tlinkgit:git-rev-parse[1].\n\n---decorate::\n-\tPrint out the ref names of any commits that are shown.\n+--decorate[=short|full]::\n+\tPrint out the ref names of any commits that are shown. If 'short' is\n+\tspecified, the ref name prefixes 'refs/heads/', 'refs/tags/' and\n+\t'refs/remotes/' will not be printed. If 'full' is specified, the\n+\tfull ref name (including prefix) will be printed. The default option\n+\tis 'short'.\n\n --source::\n \tPrint out the ref name given on the command line by which each\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 3817bf1..1ed4c76 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -61,8 +61,15 @@ static void cmd_log_init(int argc, const char\n**argv, const char *prefix,\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tif (!strcmp(arg, \"--decorate\")) {\n-\t\t\tload_ref_decorations();\n-\t\t\trev->show_decorations = 1;\n+\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n+\t\t} else if (!prefixcmp(arg, \"--decorate=\")) {\n+\t\t\tconst char *v = skip_prefix(arg, \"--decorate=\");\n+\t\t\tif (!strcmp(v, \"full\"))\n+\t\t\t\trev->show_decorations = DECORATE_FULL_REFS;\n+\t\t\telse if (!strcmp(v, \"short\"))\n+\t\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n+\t\t\telse\n+\t\t\t\tdie(\"invalid --decorate option: %s\", arg);\n \t\t} else if (!strcmp(arg, \"--source\")) {\n \t\t\trev->show_source = 1;\n \t\t} else if (!strcmp(arg, \"-h\")) {\n@@ -70,6 +77,8 @@ static void cmd_log_init(int argc, const char\n**argv, const char *prefix,\n \t\t} else\n \t\t\tdie(\"unrecognized argument: %s\", arg);\n \t}\n+\tif (rev->show_decorations)\n+\t\tload_ref_decorations(rev->show_decorations);\n }\n\n /*\ndiff --git a/log-tree.c b/log-tree.c\nindex 6f73c17..70223eb 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -25,7 +25,8 @@ static int add_ref_decoration(const char *refname,\nconst unsigned char *sha1, in\n \tstruct object *obj = parse_object(sha1);\n \tif (!obj)\n \t\treturn 0;\n-\trefname = prettify_refname(refname);\n+\tif (!cb_data || *(int *)cb_data & DECORATE_SHORT_REFS)\n+\t\trefname = prettify_refname(refname);\n \tadd_name_decoration(\"\", refname, obj);\n \twhile (obj->type == OBJ_TAG) {\n \t\tobj = ((struct tag *)obj)->tagged;\n@@ -36,12 +37,12 @@ static int add_ref_decoration(const char *refname,\nconst unsigned char *sha1, in\n \treturn 0;\n }\n\n-void load_ref_decorations(void)\n+void load_ref_decorations(int flags)\n {\n \tstatic int loaded;\n \tif (!loaded) {\n \t\tloaded = 1;\n-\t\tfor_each_ref(add_ref_decoration, NULL);\n+\t\tfor_each_ref(add_ref_decoration, &flags);\n \t}\n }\n\ndiff --git a/log-tree.h b/log-tree.h\nindex 20b5caf..3f7b400 100644\n--- a/log-tree.h\n+++ b/log-tree.h\n@@ -17,7 +17,7 @@ void log_write_email_headers(struct rev_info *opt,\nstruct commit *commit,\n \t\t\t     const char **subject_p,\n \t\t\t     const char **extra_headers_p,\n \t\t\t     int *need_8bit_cte_p);\n-void load_ref_decorations(void);\n+void load_ref_decorations(int flags);\n\n #define FORMAT_PATCH_NAME_MAX 64\n void get_patch_filename(struct commit *commit, int nr, const char *suffix,\ndiff --git a/pretty.c b/pretty.c\nindex e5328da..daa721b 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -571,7 +571,7 @@ static void format_decoration(struct strbuf *sb,\nconst struct commit *commit)\n \tstruct name_decoration *d;\n \tconst char *prefix = \" (\";\n\n-\tload_ref_decorations();\n+\tload_ref_decorations(DECORATE_SHORT_REFS);\n \td = lookup_decoration(&name_decoration, &commit->object);\n \twhile (d) {\n \t\tstrbuf_addstr(sb, prefix);\ndiff --git a/revision.c b/revision.c\nindex 9f5dac5..ce24ad9 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -1052,7 +1052,7 @@ static int handle_revision_opt(struct rev_info\n*revs, int argc, const char **arg\n \t\trevs->simplify_by_decoration = 1;\n \t\trevs->limited = 1;\n \t\trevs->prune = 1;\n-\t\tload_ref_decorations();\n+\t\tload_ref_decorations(DECORATE_SHORT_REFS);\n \t} else if (!strcmp(arg, \"--date-order\")) {\n \t\trevs->lifo = 0;\n \t\trevs->topo_order = 1;\ndiff --git a/revision.h b/revision.h\nindex fb74492..9a644ee 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -15,6 +15,9 @@\n #define SYMMETRIC_LEFT\t(1u<<8)\n #define ALL_REV_FLAGS\t((1u<<9)-1)\n\n+#define DECORATE_SHORT_REFS\t1\n+#define DECORATE_FULL_REFS\t2\n+\n struct rev_info;\n struct log_info;\n\n@@ -56,7 +59,6 @@ struct rev_info {\n \t\t\trewrite_parents:1,\n \t\t\tprint_parents:1,\n \t\t\tshow_source:1,\n-\t\t\tshow_decorations:1,\n \t\t\treverse:1,\n \t\t\treverse_output_stage:1,\n \t\t\tcherry_pick:1,\n@@ -96,6 +98,7 @@ struct rev_info {\n \tconst char\t*subject_prefix;\n \tint\t\tno_inline;\n \tint\t\tshow_log_size;\n+\tint\t\tshow_decorations;\n\n \t/* Filter by commit log message */\n \tstruct grep_opt\tgrep_filter;\ndiff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh\nindex 8b33321..8e3694e 100755\n--- a/t/t4013-diff-various.sh\n+++ b/t/t4013-diff-various.sh\n@@ -207,6 +207,7 @@ log --root --cc --patch-with-stat --summary master\n log -SF master\n log -SF -p master\n log --decorate --all\n+log --decorate=full --all\n\n rev-list --parents HEAD\n rev-list --children HEAD\ndiff --git a/t/t4013/diff.log_--decorate_--all\nb/t/t4013/diff.log_--decorate=full_--all\nsimilarity index 72%\ncopy from t/t4013/diff.log_--decorate_--all\ncopy to t/t4013/diff.log_--decorate=full_--all\nindex 954210e..903d9d9 100644\n--- a/t/t4013/diff.log_--decorate_--all\n+++ b/t/t4013/diff.log_--decorate=full_--all\n@@ -1,12 +1,12 @@\n-$ git log --decorate --all\n-commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (master)\n+$ git log --decorate=full --all\n+commit 59d314ad6f356dd08601a4cd5e530381da3e3c64 (refs/heads/master)\n Merge: 9a6d494 c7a2ab9\n Author: A U Thor <author@example.com>\n Date:   Mon Jun 26 00:04:00 2006 +0000\n\n     Merge branch 'side'\n\n-commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (side)\n+commit c7a2ab9e8eac7b117442a607d5a9b3950ae34d5a (refs/heads/side)\n Author: A U Thor <author@example.com>\n Date:   Mon Jun 26 00:03:00 2006 +0000\n\n@@ -26,7 +26,7 @@ Date:   Mon Jun 26 00:01:00 2006 +0000\n\n     This is the second commit.\n\n-commit 444ac553ac7612cc88969031b02b3767fb8a353a (initial)\n+commit 444ac553ac7612cc88969031b02b3767fb8a353a (refs/heads/initial)\n Author: A U Thor <author@example.com>\n Date:   Mon Jun 26 00:00:00 2006 +0000\n\n-- \n1.6.4.135.g4e5b\n"},{"id":"121066","messageId":"20090818093348.GA3550@coredump.intra.peff.net","threadId":"20602","inReplyTo":"8c5c35580908150723h6e4c8fcay43b708969a86ae27@mail.gmail.com","subject":"Re: [PATCH] git-log: allow --decorate[=short|full]","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2009-08-18T09:33:48Z","receivedAt":"2009-08-18T09:33:48Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Aug 15, 2009 at 04:23:12PM +0200, Lars Hjemli wrote:\n\n> This patch introduces an extension to --decorate to allow the caller to\n> specify either the short or the full versions.\n> \n> Signed-off-by: Lars Hjemli <hjemli@gmail.com>\n> ---\n> \n> Thanks for the review. I've adapted the patch to your comments, and\n> modified the documentation of '--decorate' to be more specific.\n\nThanks. Looks good to me.\n\nAcked-by: Jeff King <peff@peff.net>\n\n-Peff\n"},{"id":"121155","messageId":"7viqgkc1v4.fsf@alter.siamese.dyndns.org","threadId":"20602","inReplyTo":"8c5c35580908150723h6e4c8fcay43b708969a86ae27@mail.gmail.com","subject":"Re: [PATCH] git-log: allow --decorate[=short|full]","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-08-18T20:18:23Z","receivedAt":"2009-08-18T20:18:23Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Lars Hjemli <hjemli@gmail.com> writes:\n\n> diff --git a/builtin-log.c b/builtin-log.c\n> index 3817bf1..1ed4c76 100644\n> --- a/builtin-log.c\n> +++ b/builtin-log.c\n> @@ -61,8 +61,15 @@ static void cmd_log_init(int argc, const char\n> **argv, const char *prefix,\n>  \tfor (i = 1; i < argc; i++) {\n>  \t\tconst char *arg = argv[i];\n>  \t\tif (!strcmp(arg, \"--decorate\")) {\n> -\t\t\tload_ref_decorations();\n> -\t\t\trev->show_decorations = 1;\n> +\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n> +\t\t} else if (!prefixcmp(arg, \"--decorate=\")) {\n> +\t\t\tconst char *v = skip_prefix(arg, \"--decorate=\");\n> +\t\t\tif (!strcmp(v, \"full\"))\n> +\t\t\t\trev->show_decorations = DECORATE_FULL_REFS;\n> +\t\t\telse if (!strcmp(v, \"short\"))\n> +\t\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n> +\t\t\telse\n> +\t\t\t\tdie(\"invalid --decorate option: %s\", arg);\n>  \t\t} else if (!strcmp(arg, \"--source\")) {\n>  \t\t\trev->show_source = 1;\n>  \t\t} else if (!strcmp(arg, \"-h\")) {\n> @@ -70,6 +77,8 @@ static void cmd_log_init(int argc, const char\n> **argv, const char *prefix,\n>  \t\t} else\n>  \t\t\tdie(\"unrecognized argument: %s\", arg);\n>  \t}\n> +\tif (rev->show_decorations)\n> +\t\tload_ref_decorations(rev->show_decorations);\n>  }\n\nIf you are deciding whether full refs are given or short ones when you\ncall load_ref_decorations(), I do not think there is any reason for you to\nchange the type of rev->short_decorations from bool to enum.  Shouldn't\nyou maintain a local variable in this function and pass it down to this\ncall instead?\n\nThat is, something like this on top (I had to fix the breakage your MUA\nhas done to your patch, so there might be some fuzz around whitespace).\n\n\n builtin-log.c |   13 ++++++++-----\n log-tree.c    |    2 +-\n revision.h    |    2 +-\n 3 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/builtin-log.c b/builtin-log.c\nindex 2a0f5f7..25e21ed 100644\n--- a/builtin-log.c\n+++ b/builtin-log.c\n@@ -35,6 +35,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \t\t      struct rev_info *rev)\n {\n \tint i;\n+\tint decoration_style = 0;\n \n \trev->abbrev = DEFAULT_ABBREV;\n \trev->commit_format = CMIT_FMT_DEFAULT;\n@@ -61,13 +62,13 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \t\tif (!strcmp(arg, \"--decorate\")) {\n-\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n+\t\t\tdecoration_style = DECORATE_SHORT_REFS;\n \t\t} else if (!prefixcmp(arg, \"--decorate=\")) {\n \t\t\tconst char *v = skip_prefix(arg, \"--decorate=\");\n \t\t\tif (!strcmp(v, \"full\"))\n-\t\t\t\trev->show_decorations = DECORATE_FULL_REFS;\n+\t\t\t\tdecoration_style = DECORATE_FULL_REFS;\n \t\t\telse if (!strcmp(v, \"short\"))\n-\t\t\t\trev->show_decorations = DECORATE_SHORT_REFS;\n+\t\t\t\tdecoration_style = DECORATE_SHORT_REFS;\n \t\t\telse\n \t\t\t\tdie(\"invalid --decorate option: %s\", arg);\n \t\t} else if (!strcmp(arg, \"--source\")) {\n@@ -77,8 +78,10 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,\n \t\t} else\n \t\t\tdie(\"unrecognized argument: %s\", arg);\n \t}\n-\tif (rev->show_decorations)\n-\t\tload_ref_decorations(rev->show_decorations);\n+\tif (decoration_style) {\n+\t\trev->show_decorations = 1;\n+\t\tload_ref_decorations(decoration_style);\n+\t}\n }\n \n /*\ndiff --git a/log-tree.c b/log-tree.c\nindex 1c767c9..1c9eefe 100644\n--- a/log-tree.c\n+++ b/log-tree.c\n@@ -25,7 +25,7 @@ static int add_ref_decoration(const char *refname, const unsigned char *sha1, in\n \tstruct object *obj = parse_object(sha1);\n \tif (!obj)\n \t\treturn 0;\n-\tif (!cb_data || *(int *)cb_data & DECORATE_SHORT_REFS)\n+\tif (!cb_data || *(int *)cb_data == DECORATE_SHORT_REFS)\n \t\trefname = prettify_refname(refname);\n \tadd_name_decoration(\"\", refname, obj);\n \twhile (obj->type == OBJ_TAG) {\ndiff --git a/revision.h b/revision.h\nindex 9a644ee..b10984b 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -59,6 +59,7 @@ struct rev_info {\n \t\t\trewrite_parents:1,\n \t\t\tprint_parents:1,\n \t\t\tshow_source:1,\n+\t\t\tshow_decorations:1,\n \t\t\treverse:1,\n \t\t\treverse_output_stage:1,\n \t\t\tcherry_pick:1,\n@@ -98,7 +99,6 @@ struct rev_info {\n \tconst char\t*subject_prefix;\n \tint\t\tno_inline;\n \tint\t\tshow_log_size;\n-\tint\t\tshow_decorations;\n \n \t/* Filter by commit log message */\n \tstruct grep_opt\tgrep_filter;\n"}]}