{"id":122,"date":"2016-10-17T22:07:00","date_gmt":"2016-10-17T20:07:00","guid":{"rendered":"http:\/\/www.ncodenicer.com\/?p=122"},"modified":"2026-05-11T06:33:21","modified_gmt":"2026-05-11T04:33:21","slug":"useful-one-liner-for-building-template-git-comment","status":"publish","type":"post","link":"https:\/\/www.codenicer.com\/?p=122","title":{"rendered":"Useful one-liner for building template git comment"},"content":{"rendered":"\n<p>Goes like this:<code><br>git status | grep modified: | awk 'BEGIN {FS=\"[ \\t]+modified:[ \\t]+\";print \"Change summary\\n\";} {print \"* \" $2 \"\\t\\n\";}'<br><\/code><\/p>\n\n\n\n<p>Sample output:<br><\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Change summary<\/p>\n\n\n\n<p>* include\/Application.hpp<\/p>\n\n\n\n<p>* include\/fengine.hpp<\/p>\n\n\n\n<p>* nginx.sh<\/p>\n\n\n\n<p>* samples\/if.ftx<\/p>\n\n\n\n<p>* src\/fEngine\/compiling\/Compiler.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/compiling\/Compiling.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Alt.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/BuiltInTag.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Case.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/CodeGenerator.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Default.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/ElIf.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Else.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Footer.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Foreach.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Header.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/If.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Item.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Link.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/List.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Placeholder.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Row.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Separator.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Switch.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Table.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/When.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/http\/HttpRequest.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/http\/HttpResponse.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/parser\/Print.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/parser\/TemplateDeclaration.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/parser\/TemplateDeclaration.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/pch.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/settings\/ConfigFile.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/settings\/ConfigSettings.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/templates\/Application.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/templates\/CustomTag.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/templates\/Lambda.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/templates\/Template.cpp<\/p>\n<\/blockquote>\n\n\n\n<p><a href=\"https:\/\/www.codenicer.com\/comment\/6#comment-6\">The other one sorting according to filename<\/a><br><code>git status | \\<br>grep modified: | \\<br>awk 'BEGIN {FS=\"[ \\t]+modified:[ \\t]+\"} {split($2, path, \"\/\"); rev_str = \"\"; path_len = length(path); for (i = 0; i &lt; path_len; i++) rev_str = rev_str path[path_len - i]; files[rev_str] = $2; } END {for (f in files) print f \"\\t\" files[f];}' | \\<br>sort -f | \\<br>awk 'BEGIN { FS=\"\\t+\"; print \"Change Summary\\n\"; } {print \"* \" $2 \"\\n\";}'<br><\/code><\/p>\n\n\n\n<p>Output similar to:<\/p>\n\n\n\n<p>Change Summary<\/p>\n\n\n\n<p>* include\/f\/Default.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Alt.cpp<\/p>\n\n\n\n<p>* include\/f\/Alt.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/templates\/Application.cpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Case.cpp<\/p>\n\n\n\n<p>* include\/f\/Case.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/compiling\/Compiling.cpp<\/p>\n\n\n\n<p>* include\/Compiling.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/templates\/CustomTag.cpp<\/p>\n\n\n\n<p>* include\/CustomTag.hpp<\/p>\n\n\n\n<p>* src\/fEngine\/f\/Default.cpp<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><a href=\"https:\/\/www.codenicer.com\/comment\/7#comment-7\">One more capturing other modification statuses as well<\/a><\/h3>\n\n\n\n<p>Since previous versions did not capture other modification statuses (renamed, new etc.).<br><code><br>git status | \\<br>grep -E \"(modified|new file|copied|renamed):\" | \\<br>awk 'BEGIN {FS=\"[ \\t]+(modified|new file|copied|renamed):[ \\t]+\"} {split($2, path, \"\/\"); rev_str = \"\"; path_len = length(path); for (i = 0; i &lt; path_len; i++) rev_str = rev_str path[path_len - i]; files[rev_str] = $2; } END {for (f in files) print f \"\\t\" files[f];}' | \\<br>sort -f | \\<br>awk 'BEGIN { FS=\"\\t+\"; print \"Change Summary\\n\"; } {print \"* \" $2 \"\\n\";}'<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Goes like this:git status | grep modified: | awk &#8216;BEGIN {FS=&#8221;[ \\t]+modified:[ \\t]+&#8221;;print &#8220;Change summary\\n&#8221;;} {print &#8220;* &#8221; $2 &#8220;\\t\\n&#8221;;}&#8217; Sample output: Change summary * include\/Application.hpp * include\/fengine.hpp * nginx.sh * samples\/if.ftx * src\/fEngine\/compiling\/Compiler.cpp * src\/fEngine\/compiling\/Compiling.cpp * src\/fEngine\/f\/Alt.cpp * src\/fEngine\/f\/BuiltInTag.cpp * src\/fEngine\/f\/Case.cpp * src\/fEngine\/f\/CodeGenerator.cpp * src\/fEngine\/f\/Default.cpp * src\/fEngine\/f\/ElIf.cpp * src\/fEngine\/f\/Else.cpp * src\/fEngine\/f\/Footer.cpp * src\/fEngine\/f\/Foreach.cpp * [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[84],"class_list":["post-122","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-git"],"_links":{"self":[{"href":"https:\/\/www.codenicer.com\/index.php?rest_route=\/wp\/v2\/posts\/122","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codenicer.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codenicer.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codenicer.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codenicer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=122"}],"version-history":[{"count":1,"href":"https:\/\/www.codenicer.com\/index.php?rest_route=\/wp\/v2\/posts\/122\/revisions"}],"predecessor-version":[{"id":123,"href":"https:\/\/www.codenicer.com\/index.php?rest_route=\/wp\/v2\/posts\/122\/revisions\/123"}],"wp:attachment":[{"href":"https:\/\/www.codenicer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=122"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codenicer.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=122"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codenicer.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=122"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}