{"thread":{"id":"832","subject":"[PATCHSET] cg-log cleanups and enhancements","startedAt":"2005-06-04T14:38:31Z","lastAt":"2005-06-04T14:43:34Z","messageCount":11,"participants":["Jonas Fonseca"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"4536","messageId":"20050604143831.GD12615@diku.dk","threadId":"832","inReplyTo":null,"subject":"[PATCHSET] cg-log cleanups and enhancements","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:38:31Z","receivedAt":"2005-06-04T14:38:31Z","isPatch":false,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"The patchset contains the following 10 patches:\n\n  [PATCH 1/10] Cleanup conversion to human readable date\n  [PATCH 2/10] Separate handling of tree and parent in commit headers\n  [PATCH 3/10] Separate handling of author and committer in commit headers\n  [PATCH 4/10] First parse all commit header entries then print them\n  [PATCH 5/10] Move printing of the commit info line inside the loop\n  [PATCH 6/10] Remove the catch all rule\n  [PATCH 7/10] Move log printing to separate function\n  [PATCH 8/10] Move the username matching inside the loop\n  [PATCH 9/10] Move file matching inside the loop.\n  [PATCH 10/10] Add -s option to show log summary\n\n-- \nJonas Fonseca\n"},{"id":"4537","messageId":"20050604143906.GE12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 1/10] Cleanup conversion to human readable date","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:39:06Z","receivedAt":"2005-06-04T14:39:06Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Simplify the date substitution to reduce code duplication.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log     |    8 ++------\n cg-mkpatch |    7 ++-----\n 2 files changed, 4 insertions(+), 11 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -188,12 +188,8 @@ $revls | $revsort | while read time comm\n \n \t\t\t\tdate=(${rest#*> })\n \t\t\t\tpdate=\"$(showdate $date)\"\n-\t\t\t\tif [ \"$pdate\" ]; then\n-\t\t\t\t\techo -n $color$key $rest | sed \"s/>.*/> $pdate/\"\n-\t\t\t\t\techo $coldefault\n-\t\t\t\telse\n-\t\t\t\t\techo $color$key $rest $coldefault\n-\t\t\t\tfi\n+\t\t\t\t[ \"$pdate\" ] && rest=\"${rest%> *}> $pdate\"\n+\t\t\t\techo $color$key $rest $coldefault\n \t\t\t\t;;\n \t\t\t\"tree\"|\"parent\")\n \t\t\t\tif [ -z $tree1 ]; then\ndiff --git a/cg-mkpatch b/cg-mkpatch\n--- a/cg-mkpatch\n+++ b/cg-mkpatch\n@@ -53,11 +53,8 @@ showpatch () {\n \t\t\"author\"|\"committer\")\n \t\t\tdate=(${rest#*> })\n \t\t\tpdate=\"$(showdate $date)\"\n-\t\t\tif [ \"$pdate\" ]; then\n-\t\t\t\techo $key $rest | sed \"s/>.*/> $pdate/\" >>$header\n-\t\t\telse\n-\t\t\t\techo $key $rest >>$header\n-\t\t\tfi\n+\t\t\t[ \"$pdate\" ] && rest=\"${rest%> *}> $pdate\"\n+\t\t\techo $key $rest >>$header\n \t\t\t;;\n \t\t\"\")\n \t\t\tcat\n\n-- \nJonas Fonseca\n"},{"id":"4538","messageId":"20050604143937.GF12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 2/10] Separate handling of tree and parent in commit headers","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:39:37Z","receivedAt":"2005-06-04T14:39:37Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Parse tree and parent commit header entries separately so the logic for\ndeciding where to save the IDs can be removed. Save all parents in an array.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |   18 +++++++++---------\n 1 files changed, 9 insertions(+), 9 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -162,8 +162,8 @@ fi\n \n $revls | $revsort | while read time commit parents; do\n \ttrap exit SIGPIPE\n-\ttree1=\n-\ttree2=\n+\ttree=\n+\tparents=()\n \t[ \"$revfmt\" = \"git-rev-list\" ] && commit=\"$time\"\n \tif [ $# -ne 0 ]; then\n \t\tparent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')\n@@ -191,17 +191,17 @@ $revls | $revsort | while read time comm\n \t\t\t\t[ \"$pdate\" ] && rest=\"${rest%> *}> $pdate\"\n \t\t\t\techo $color$key $rest $coldefault\n \t\t\t\t;;\n-\t\t\t\"tree\"|\"parent\")\n-\t\t\t\tif [ -z $tree1 ]; then\n-\t\t\t\t\ttree1=$rest\n-\t\t\t\telif [ -z $tree2 ]; then\n-\t\t\t\t\ttree2=$rest\n-\t\t\t\tfi\n+\t\t\t\"tree\")\n+\t\t\t\ttree=\"$rest\"\n+\t\t\t\techo $colheader$key $tree $coldefault\n+\t\t\t\t;;\n+\t\t\t\"parent\")\n+\t\t\t\tparents[${#parents[@]}]=\"$rest\"\n \t\t\t\techo $colheader$key $rest $coldefault\n \t\t\t\t;;\n \t\t\t\"\")\n \t\t\t\tif [ -n \"$list_files\" ]; then\n-\t\t\t\t\tlist_commit_files \"$tree1\" \"$tree2\"\n+\t\t\t\t\tlist_commit_files \"$tree\" \"${parents[0]}\"\n \t\t\t\tfi\n \t\t\t\techo; sed -re '\n \t\t\t\t\t/ *Signed-off-by:.*/Is//'$colsignoff'&'$coldefault'/\n\n-- \nJonas Fonseca\n"},{"id":"4539","messageId":"20050604144002.GG12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 3/10] Separate handling of author and committer in commit headers","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:40:02Z","receivedAt":"2005-06-04T14:40:02Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Parse and print the author and committer header entries so the color logic\ncan be removed.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |   24 ++++++++++++++----------\n 1 files changed, 14 insertions(+), 10 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -162,6 +162,8 @@ fi\n \n $revls | $revsort | while read time commit parents; do\n \ttrap exit SIGPIPE\n+\tauthor=\n+\tcommitter=\n \ttree=\n \tparents=()\n \t[ \"$revfmt\" = \"git-rev-list\" ] && commit=\"$time\"\n@@ -179,17 +181,19 @@ $revls | $revsort | while read time comm\n \t\twhile read key rest; do\n \t\t\ttrap exit SIGPIPE\n \t\t\tcase \"$key\" in\n-\t\t\t\"author\"|\"committer\")\n-\t\t\t\tif [ \"$key\" = \"author\" ]; then\n-\t\t\t\t\tcolor=\"$colauthor\"\n-\t\t\t\telse\n-\t\t\t\t\tcolor=\"$colcommitter\"\n-\t\t\t\tfi\n-\n-\t\t\t\tdate=(${rest#*> })\n+\t\t\t\"author\")\n+\t\t\t\tauthor=\"$rest\"\n+\t\t\t\tdate=(${author#*> })\n+\t\t\t\tpdate=\"$(showdate $date)\"\n+\t\t\t\t[ \"$pdate\" ] && author=\"${author%> *}> $pdate\"\n+\t\t\t\techo $colauthor$key $author $coldefault\n+\t\t\t\t;;\n+\t\t\t\"committer\")\n+\t\t\t\tcommitter=\"$rest\"\n+\t\t\t\tdate=(${committer#*> })\n \t\t\t\tpdate=\"$(showdate $date)\"\n-\t\t\t\t[ \"$pdate\" ] && rest=\"${rest%> *}> $pdate\"\n-\t\t\t\techo $color$key $rest $coldefault\n+\t\t\t\t[ \"$pdate\" ] && committer=\"${committer%> *}> $pdate\"\n+\t\t\t\techo $colcommitter$key $committer $coldefault\n \t\t\t\t;;\n \t\t\t\"tree\")\n \t\t\t\ttree=\"$rest\"\n\n-- \nJonas Fonseca\n"},{"id":"4540","messageId":"20050604144035.GH12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 4/10] First parse all commit header entries then print them","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:40:35Z","receivedAt":"2005-06-04T14:40:35Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Change the main loop to first parse all header entries before printing\nthem. Makes the cg-log output more independent of the order of the git\ncommit header.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |   26 ++++++++++++++++----------\n 1 files changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -183,27 +183,33 @@ $revls | $revsort | while read time comm\n \t\t\tcase \"$key\" in\n \t\t\t\"author\")\n \t\t\t\tauthor=\"$rest\"\n-\t\t\t\tdate=(${author#*> })\n-\t\t\t\tpdate=\"$(showdate $date)\"\n-\t\t\t\t[ \"$pdate\" ] && author=\"${author%> *}> $pdate\"\n-\t\t\t\techo $colauthor$key $author $coldefault\n \t\t\t\t;;\n \t\t\t\"committer\")\n \t\t\t\tcommitter=\"$rest\"\n-\t\t\t\tdate=(${committer#*> })\n-\t\t\t\tpdate=\"$(showdate $date)\"\n-\t\t\t\t[ \"$pdate\" ] && committer=\"${committer%> *}> $pdate\"\n-\t\t\t\techo $colcommitter$key $committer $coldefault\n \t\t\t\t;;\n \t\t\t\"tree\")\n \t\t\t\ttree=\"$rest\"\n-\t\t\t\techo $colheader$key $tree $coldefault\n \t\t\t\t;;\n \t\t\t\"parent\")\n \t\t\t\tparents[${#parents[@]}]=\"$rest\"\n-\t\t\t\techo $colheader$key $rest $coldefault\n \t\t\t\t;;\n \t\t\t\"\")\n+\t\t\t\techo ${colheader}tree $tree $coldefault\n+\n+\t\t\t\tfor parent in \"${parents[@]}\"; do\n+\t\t\t\t\techo ${colheader}parent $parent $coldefault\n+\t\t\t\tdone\n+\n+\t\t\t\tdate=(${author#*> })\n+\t\t\t\tpdate=\"$(showdate $date)\"\n+\t\t\t\t[ \"$pdate\" ] && author=\"${author%> *}> $pdate\"\n+\t\t\t\techo ${colauthor}author $author $coldefault\n+\n+\t\t\t\tdate=(${committer#*> })\n+\t\t\t\tpdate=\"$(showdate $date)\"\n+\t\t\t\t[ \"$pdate\" ] && committer=\"${committer%> *}> $pdate\"\n+\t\t\t\techo ${colcommitter}committer $committer $coldefault\n+\n \t\t\t\tif [ -n \"$list_files\" ]; then\n \t\t\t\t\tlist_commit_files \"$tree\" \"${parents[0]}\"\n \t\t\t\tfi\n\n-- \nJonas Fonseca\n"},{"id":"4541","messageId":"20050604144105.GI12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 5/10] Move printing of the commit info line inside the loop","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:41:05Z","receivedAt":"2005-06-04T14:41:05Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Printing of all the log headers are now handled the same place.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -176,7 +176,6 @@ $revls | $revsort | while read time comm\n \tif [ \"$user\" ]; then\n \t\tgit-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi \"$user\" || continue\n \tfi\n-\techo $colheader\"\"commit ${commit%:*} $coldefault;\n \tgit-cat-file commit $commit | \\\n \t\twhile read key rest; do\n \t\t\ttrap exit SIGPIPE\n@@ -194,6 +193,7 @@ $revls | $revsort | while read time comm\n \t\t\t\tparents[${#parents[@]}]=\"$rest\"\n \t\t\t\t;;\n \t\t\t\"\")\n+\t\t\t\techo ${colheader}commit ${commit%:*} $coldefault\n \t\t\t\techo ${colheader}tree $tree $coldefault\n \n \t\t\t\tfor parent in \"${parents[@]}\"; do\n-- \nJonas Fonseca\n"},{"id":"4542","messageId":"20050604144131.GJ12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 6/10] Remove the catch all rule","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:41:31Z","receivedAt":"2005-06-04T14:41:31Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"All commit header entries are already be handled so no need for a default\ncase pattern.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |    4 ----\n 1 files changed, 0 insertions(+), 4 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -219,11 +219,7 @@ $revls | $revsort | while read time comm\n \t\t\t\t\ts/./    &/\n \t\t\t\t'\n \t\t\t\t;;\n-\t\t\t*)\n-\t\t\t\techo $colheader$key $rest $coldefault\n-\t\t\t\t;;\n \t\t\tesac\n-\n \t\tdone\n \techo\n done | pager\n-- \nJonas Fonseca\n"},{"id":"4543","messageId":"20050604144203.GK12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 7/10] Move log printing to separate function","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:42:03Z","receivedAt":"2005-06-04T14:42:03Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Each commit log is now handled in the new print_commit_log() function.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |   30 ++++++++++++++++++------------\n 1 files changed, 18 insertions(+), 12 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -160,22 +160,13 @@ else\n \trevfmt=\"git-rev-list\"\n fi\n \n-$revls | $revsort | while read time commit parents; do\n-\ttrap exit SIGPIPE\n+print_commit_log() {\n+\tcommit=\"$1\"\n \tauthor=\n \tcommitter=\n \ttree=\n \tparents=()\n-\t[ \"$revfmt\" = \"git-rev-list\" ] && commit=\"$time\"\n-\tif [ $# -ne 0 ]; then\n-\t\tparent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')\n-\t\tdiff_ops=\n-\t\t[ \"$parent\" ] || diff_ops=--root\n-\t\t[ \"$(git-diff-tree -r $diff_ops $commit $parent \"$@\")\" ] || continue\n-\tfi\n-\tif [ \"$user\" ]; then\n-\t\tgit-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi \"$user\" || continue\n-\tfi\n+\n \tgit-cat-file commit $commit | \\\n \t\twhile read key rest; do\n \t\t\ttrap exit SIGPIPE\n@@ -221,5 +212,20 @@ $revls | $revsort | while read time comm\n \t\t\t\t;;\n \t\t\tesac\n \t\tdone\n+}\n+\n+$revls | $revsort | while read time commit parents; do\n+\ttrap exit SIGPIPE\n+\t[ \"$revfmt\" = \"git-rev-list\" ] && commit=\"$time\"\n+\tif [ $# -ne 0 ]; then\n+\t\tparent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')\n+\t\tdiff_ops=\n+\t\t[ \"$parent\" ] || diff_ops=--root\n+\t\t[ \"$(git-diff-tree -r $diff_ops $commit $parent \"$@\")\" ] || continue\n+\tfi\n+\tif [ \"$user\" ]; then\n+\t\tgit-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi \"$user\" || continue\n+\tfi\n+\tprint_commit_log $commit\n \techo\n done | pager\n-- \nJonas Fonseca\n"},{"id":"4544","messageId":"20050604144242.GL12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 8/10] Move the username matching inside the loop","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:42:42Z","receivedAt":"2005-06-04T14:42:42Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"By handling -u in the commit parsing loop no extra git-cat-file call is\nnecessary. Keep the line-based matching scheme so that it is still possible\nto restrict searches by using prefixing the search string with either\n'author' or 'committer' (e.g. -u'author.*miciah').\n\nThis change also magically removes trailing empty lines from commit logs.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |   12 ++++++++----\n 1 files changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -184,6 +184,10 @@ print_commit_log() {\n \t\t\t\tparents[${#parents[@]}]=\"$rest\"\n \t\t\t\t;;\n \t\t\t\"\")\n+\t\t\t\tif [ \"$user\" ]; then\n+\t\t\t\t\techo -e \"author $author\\ncommitter $committer\" \\\n+\t\t\t\t\t\t| grep -qi \"$user\" || return\n+\t\t\t\tfi\n \t\t\t\techo ${colheader}commit ${commit%:*} $coldefault\n \t\t\t\techo ${colheader}tree $tree $coldefault\n \n@@ -223,9 +227,9 @@ $revls | $revsort | while read time comm\n \t\t[ \"$parent\" ] || diff_ops=--root\n \t\t[ \"$(git-diff-tree -r $diff_ops $commit $parent \"$@\")\" ] || continue\n \tfi\n-\tif [ \"$user\" ]; then\n-\t\tgit-cat-file commit $commit | grep -e '^author ' -e '^committer ' | grep -qi \"$user\" || continue\n+\tlog=\"$(print_commit_log $commit)\"\n+\tif [ \"$log\" ]; then\n+\t\techo \"$log\"\n+\t\techo\n \tfi\n-\tprint_commit_log $commit\n-\techo\n done | pager\n-- \nJonas Fonseca\n"},{"id":"4545","messageId":"20050604144306.GM12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 9/10] Move file matching inside the loop.","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:43:06Z","receivedAt":"2005-06-04T14:43:06Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Handling of -f is done inide the loop so no extra git-cat-file call is\nnecessary. Store file arguments to cg-log in an array to make them easier\nto access from print_commit_log().\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-log |   14 ++++++++------\n 1 files changed, 8 insertions(+), 6 deletions(-)\n\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -73,6 +73,7 @@ log_start=\n log_end=\n user=\n mergebase=\n+files=()\n \n while [ \"$1\" ]; do\n \tcase \"$1\" in\n@@ -107,6 +108,7 @@ while [ \"$1\" ]; do\n \t\tmergebase=1\n \t\t;;\n \t*)\n+\t\tfiles=(\"$@\")\n \t\tbreak\n \t\t;;\n \tesac\n@@ -184,6 +186,12 @@ print_commit_log() {\n \t\t\t\tparents[${#parents[@]}]=\"$rest\"\n \t\t\t\t;;\n \t\t\t\"\")\n+\t\t\t\tif [ \"$files\" ]; then\n+\t\t\t\t\tparent=\"${parents[0]}\"\n+\t\t\t\t\tdiff_ops=\n+\t\t\t\t\t[ \"$parent\" ] || diff_ops=--root\n+\t\t\t\t\t[ \"$(git-diff-tree -r $diff_ops $commit $parent \"${files[@]}\")\" ] || return 1\n+\t\t\t\tfi\n \t\t\t\tif [ \"$user\" ]; then\n \t\t\t\t\techo -e \"author $author\\ncommitter $committer\" \\\n \t\t\t\t\t\t| grep -qi \"$user\" || return\n@@ -221,12 +229,6 @@ print_commit_log() {\n $revls | $revsort | while read time commit parents; do\n \ttrap exit SIGPIPE\n \t[ \"$revfmt\" = \"git-rev-list\" ] && commit=\"$time\"\n-\tif [ $# -ne 0 ]; then\n-\t\tparent=$(git-cat-file commit $commit | sed -n '2s/parent //p;2Q')\n-\t\tdiff_ops=\n-\t\t[ \"$parent\" ] || diff_ops=--root\n-\t\t[ \"$(git-diff-tree -r $diff_ops $commit $parent \"$@\")\" ] || continue\n-\tfi\n \tlog=\"$(print_commit_log $commit)\"\n \tif [ \"$log\" ]; then\n \t\techo \"$log\"\n-- \nJonas Fonseca\n"},{"id":"4546","messageId":"20050604144334.GN12615@diku.dk","threadId":"832","inReplyTo":"20050604143831.GD12615@diku.dk","subject":"[PATCH 10/10] Add -s option to show log summary","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-06-04T14:43:34Z","receivedAt":"2005-06-04T14:43:34Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"When passing -s to cg-log each log entry is summarized in one line. The line\ncarries info about commit date, author, first log line and the commit id. It\nwill look something like the following (with only:\n\n  2005-05-20 11:46 Linus Torvalds   sparse cleanup   e99d59ff0bff349ef20...\n\nThe result ends up being 130 chars wide however the commit id is placed so\nthat it can easily be hidden if line wrapping in the pager is enabled.\n\nSigned-off-by: Jonas Fonseca <fonseca@diku.dk>\n---\n\n cg-Xlib |    4 +++-\n cg-log  |   53 ++++++++++++++++++++++++++++++++++++++++++++---------\n 2 files changed, 47 insertions(+), 10 deletions(-)\n\ndiff --git a/cg-Xlib b/cg-Xlib\n--- a/cg-Xlib\n+++ b/cg-Xlib\n@@ -47,10 +47,12 @@ mktemp () {\n \n showdate () {\n \tdate=\"$1\"\n+\tformat=\"$2\"\n+\t[ \"$format\" ] || format=-R\n \tsec=${date[0]}; tz=${date[1]}\n \tdtz=${tz/+/}\n \tlsec=$(expr $dtz / 100 \\* 3600 + $dtz % 100 \\* 60 + $sec)\n-\tpdate=\"$(date -Rud \"1970-01-01 UTC + $lsec sec\" 2>/dev/null)\"\n+\tpdate=\"$(date -ud \"1970-01-01 UTC + $lsec sec\" \"$format\" 2>/dev/null)\"\n \n \techo \"${pdate/+0000/$tz}\"\n }\ndiff --git a/cg-log b/cg-log\n--- a/cg-log\n+++ b/cg-log\n@@ -14,15 +14,21 @@\n # cg-log then displays only changes in those files.\n #\n # -c::\n-#\tAdd color to the output. Currently, the colors are:\n-#\t- `author`:\t'cyan'\n-#\t- `committer`:\t'magenta'\n-#\t- `header`:\t'green'\n-#\t- `files`:\t'blue'\n-#\t- `signoff`:\t'yellow'\n+#\tColorize to the output. When getting log summary the `date` is\n+#\tcolored 'green', the `author` is colored 'cyan', the `commit ID`\n+#\tis colored 'blue' and the special line trimming character (~) is\n+#\tcolored 'magenta'. +\n+#\t+\n+#\tWhen getting the full log the colors are:\n+#\t\t- `author`:\t'cyan'\n+#\t\t- `committer`:\t'magenta'\n+#\t\t- `header`:\t'green'\n+#\t\t- `files`:\t'blue'\n+#\t\t- `signoff`:\t'yellow'\n #\n # -f::\n-#\tList affected files.\n+#\tList affected files. This option does not make sense when using\n+#\t`-s` to get a log summary.\n #\n # -r FROM_ID[:TO_ID]::\n #\tLimit the log information to a set of revisions using either\n@@ -36,6 +42,12 @@\n #\tEnd the log listing at the merge base of the -r arguments\n #\t(defaulting to master and origin).\n #\n+# -s::\n+#\tShow a one line summary for each log entry. The summary contains\n+#\tinformation about the commit date, the author, the first line\n+#\tof the commit log and the commit ID. Long author and commit log\n+#\ttitles are trimmed but marked with an ending tilde (~).\n+#\n # -uUSERNAME::\n #\tList only commits where author or committer contains 'USERNAME'.\n #\tThe search for 'USERNAME' is case-insensitive.\n@@ -55,7 +67,7 @@\n #\n #\t$ cg-log -r releasetag-0.9:releasetag-0.10\n \n-USAGE=\"cg-log [-c] [-f] [m] [-uUSERNAME] [-r FROM_ID[:TO_ID] FILE...\"\n+USAGE=\"cg-log [-c] [-f] [-m] [-s] [-uUSERNAME] [-r FROM_ID[:TO_ID] FILE...\"\n \n . ${COGITO_LIB}cg-Xlib\n # Try to fix the annoying \"Broken pipe\" output. May not help, but apparently\n@@ -71,6 +83,7 @@ coldefault=\n list_files=\n log_start=\n log_end=\n+summary=\n user=\n mergebase=\n files=()\n@@ -107,6 +120,9 @@ while [ \"$1\" ]; do\n \t-m)\n \t\tmergebase=1\n \t\t;;\n+\t-s)\n+\t\tsummary=1\n+\t\t;;\n \t*)\n \t\tfiles=(\"$@\")\n \t\tbreak\n@@ -196,6 +212,8 @@ print_commit_log() {\n \t\t\t\t\techo -e \"author $author\\ncommitter $committer\" \\\n \t\t\t\t\t\t| grep -qi \"$user\" || return\n \t\t\t\tfi\n+\t\t\t\t[ \"$summary\" ] && continue\n+\n \t\t\t\techo ${colheader}commit ${commit%:*} $coldefault\n \t\t\t\techo ${colheader}tree $tree $coldefault\n \n@@ -222,6 +240,23 @@ print_commit_log() {\n \t\t\t\t\ts/./    &/\n \t\t\t\t'\n \t\t\t\t;;\n+\t\t\t*)\n+\t\t\t\t# Print summary\n+\t\t\t\tauthor=\"${author% <*}\"\n+\t\t\t\tdate=(${committer#*> })\n+\t\t\t\tdate=\"$(showdate $date '+%F %H:%M')\"\n+\t\t\t\ttitle=\"$key $rest\"\n+\t\t\t\tif [ \"${#title}\" -gt 51 ]; then\n+\t\t\t\t\ttitle=\"${title:0:50}$colcommitter~\"\n+\t\t\t\tfi\n+\t\t\t\tif [ \"${#author}\" -gt 20 ]; then\n+\t\t\t\t\tauthor=\"${author:0:19}$colcommitter~\"\n+\t\t\t\tfi\n+\n+\t\t\t\tprintf \"$colheader$date $colauthor%-20s $coldefault%-51s $colfiles${commit%:*}$coldefault\\n\" \\\n+\t\t\t\t\t\"$author\" \"$title\"\n+\t\t\t\treturn\n+\t\t\t\t;;\n \t\t\tesac\n \t\tdone\n }\n@@ -232,6 +267,6 @@ $revls | $revsort | while read time comm\n \tlog=\"$(print_commit_log $commit)\"\n \tif [ \"$log\" ]; then\n \t\techo \"$log\"\n-\t\techo\n+\t\t[ \"$summary\" ] || echo\n \tfi\n done | pager\n-- \nJonas Fonseca\n"}]}