{"thread":{"id":"302","subject":"[PATCH] Show which files was changed in the git log output","startedAt":"2005-04-25T01:22:06Z","lastAt":"2005-04-25T01:22:06Z","messageCount":1,"participants":["Jonas Fonseca"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1570","messageId":"20050425012206.GA29069@diku.dk","threadId":"302","inReplyTo":null,"subject":"[PATCH] Show which files was changed in the git log output","fromName":"Jonas Fonseca","fromEmail":"fonseca@diku.dk","sentAt":"2005-04-25T01:22:06Z","receivedAt":"2005-04-25T01:22:06Z","isPatch":true,"sender":{"key":"fonseca@diku.dk","avatar":"https://gravatar.com/avatar/f82f3ad698717c51873b020c750a92438c820a24056dc39fe4d07baa10a92264?d=mp&s=160"},"body":"Hi,\n\nI have attached a patch probe to optionally have the git log command\nlist which files was changed by a commit.\n\nIt would be nice if someone with a more in depth knowledge of which\nsha1s to pass to diff-tree when there are multiple parents could comment\non whether it does the right thing.\n\nRight now it does the following: if there are only one parent it is\ndiffed against the commit tree and if there are two parents they are\ndiffed. I assume the order they are diffed doesn't matter.\n\n-- \nJonas Fonseca\n\n\nIndex: githelp.sh\n===================================================================\n--- 7de71a831508e51e0985cea173f3f7a7012c82b7/githelp.sh  (mode:100755 sha1:e19176d4ef69a2e7c6da6b9893e2c7cdac24760a)\n+++ uncommitted/githelp.sh  (mode:100755)\n@@ -19,7 +19,7 @@\n \tfork\t\tBNAME BRANCH_DIR [COMMIT_ID]\n \thelp\n \tinit\t\tRSYNC_URL\n-\tlog\t\t[-c] [COMMIT_ID | COMMIT_ID:COMMIT_ID]\n+\tlog\t\t[-c] [-f] [COMMIT_ID | COMMIT_ID:COMMIT_ID]\n \tls\t\t[TREE_ID]\n \tlsobj\t\t[OBJTYPE]\n \tlsremote\nIndex: gitlog.sh\n===================================================================\n--- 7de71a831508e51e0985cea173f3f7a7012c82b7/gitlog.sh  (mode:100755 sha1:a09ffda484bd859a3bcb1cffcc8fd6f9c65fa8e7)\n+++ uncommitted/gitlog.sh  (mode:100755)\n@@ -13,8 +13,11 @@\n #\theader\t\tGreen\t\n #\tauthor \t\tCyan\n #\tcommitter\tMagenta\n+#\tfiles\t\tBlue\n #\tsignoff\t\tYellow\n #\n+# Takes an -f option to show which files was changed.\n+#\n # Takes an id resolving to a commit to start from (HEAD by default),\n # or id1:id2 representing an (id1;id2] range of commits to show.\n \n@@ -24,16 +27,25 @@\n \tcolheader=\"$(tput setaf 2)\"    # Green\n \tcolauthor=\"$(tput setaf 6)\"    # Cyan\n \tcolcommitter=\"$(tput setaf 5)\" # Magenta\n+\tcolfiles=\"$(tput setaf 4)\"     # Blue\n \tcolsignoff=\"$(tput setaf 3)\"   # Yellow\n \tcoldefault=\"$(tput op)\"        # Restore default\n else\n \tcolheader=\n \tcolauthor=\n \tcolcommitter=\n+\tcolfiles=\n \tcolsignoff=\n \tcoldefault=\n fi\n \n+if [ \"$1\" = \"-f\" ]; then\n+\tshift\n+\tlist_files=1\n+else\n+\tlist_files=\n+fi\n+\n if echo \"$1\" | grep -q ':'; then\n \tid1=$(commit-id $(echo \"$1\" | cut -d : -f 1)) || exit 1\n \tid2=$(commit-id $(echo \"$1\" | cut -d : -f 2)) || exit 1\n@@ -49,6 +61,8 @@\n \n $revls | $revsort | while read time commit parents; do\n \t[ \"$revfmt\" = \"rev-list\" ] && commit=\"$time\"\n+\ttree1=\n+\ttree2=\n \techo $colheader\"\"commit ${commit%:*} $coldefault;\n \tcat-file commit $commit | \\\n \t\twhile read key rest; do\n@@ -73,11 +87,32 @@\n \t\t\t\tfi\n \t\t\t\t;;\n \t\t\t\"\")\n+\t\t\t\tif [ -n $list_files ]; then\n+\t\t\t\t\tsep=\n+\t\t\t\t\techo\n+\t\t\t\t\techo -n \"    * $colfiles\"\n+\t\t\t\t\tdiff-tree -r $tree1 $tree2 | \\\n+\t\t\t\t\twhile read modes type sha1s file; do\n+\t\t\t\t\t\techo -n \"$sep$file\"\n+\t\t\t\t\t\tsep=\", \"\n+\t\t\t\t\tdone\n+\t\t\t\t\techo \"$coldefault\"\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 \t\t\t\t\ts/^/    /\n \t\t\t\t'\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\telse\n+\t\t\t\t\ttree1=$rest\n+\t\t\t\tfi\n+\t\t\t\techo $colheader$key $rest $coldefault\n+\t\t\t\t;;\n \t\t\t*)\n \t\t\t\techo $colheader$key $rest $coldefault\n \t\t\t\t;;\n"}]}