{"thread":{"id":"29948","subject":"[PATCH 0/5 v2] contrib/diffall: improvements","startedAt":"2012-03-14T16:38:01Z","lastAt":"2012-03-14T16:38:06Z","messageCount":6,"participants":["Tim Henigan"],"isPatch":true,"patchVersion":2,"patchTotal":5},"messages":[{"id":"186957","messageId":"1331743086-32304-1-git-send-email-tim.henigan@gmail.com","threadId":"29948","inReplyTo":null,"subject":"[PATCH 0/5 v2] contrib/diffall: improvements","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-14T16:38:01Z","receivedAt":"2012-03-14T16:38:01Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"This series implements a number of changes to make the script more\nrobust.\n\nChanges in v2:\n  - Fixed a bug in patch 3/5 that copied modified working copy files\n    to the wrong tmp directory location. This affected any modified\n    working copy file not located at the repo root.\n  - Added patch 5/5 to insure that the tmp dir is actually deleted\n    when the script is run on Windows.\n  - Shortened the commit message summary line for each patch.\n\n\nTim Henigan (5):\n  contrib/diffall: comment actual reason for 'cdup'\n  contrib/diffall: create tmp dirs without mktemp\n  contrib/diffall: eliminate use of tar\n  contrib/diffall: eliminate duplicate while loops\n  contrib/diffall: fix cleanup trap on Windows\n\n contrib/diffall/git-diffall |   52 ++++++++++++++++++++-----------------------\n 1 file changed, 24 insertions(+), 28 deletions(-)\n\n-- \n1.7.10.rc0\n"},{"id":"186958","messageId":"1331743086-32304-2-git-send-email-tim.henigan@gmail.com","threadId":"29948","inReplyTo":"1331743086-32304-1-git-send-email-tim.henigan@gmail.com","subject":"[PATCH 1/5 v2] contrib/diffall: comment actual reason for 'cdup'","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-14T16:38:02Z","receivedAt":"2012-03-14T16:38:02Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"The comment from an earlier commit did not reflect the actual reason this\noperation is needed.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nv2 did not affect this patch.\n\n\n contrib/diffall/git-diffall |    4 +++-\n 1 file changed, 3 insertions(+), 1 deletion(-)\n\ndiff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall\nindex 9bbd27f..d706a6d 100755\n--- a/contrib/diffall/git-diffall\n+++ b/contrib/diffall/git-diffall\n@@ -36,7 +36,9 @@ fi\n \n start_dir=$(pwd)\n \n-# needed to access tar utility\n+# All the file paths returned by the diff command are relative to the root\n+# of the working copy. So if the script is called from a subdirectory, it\n+# must switch to the root of working copy before trying to use those paths.\n cdup=$(git rev-parse --show-cdup) &&\n cd \"$cdup\" || {\n \techo >&2 \"Cannot chdir to $cdup, the toplevel of the working tree\"\n-- \n1.7.10.rc0\n"},{"id":"186960","messageId":"1331743086-32304-3-git-send-email-tim.henigan@gmail.com","threadId":"29948","inReplyTo":"1331743086-32304-1-git-send-email-tim.henigan@gmail.com","subject":"[PATCH 2/5 v2] contrib/diffall: create tmp dirs without mktemp","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-14T16:38:03Z","receivedAt":"2012-03-14T16:38:03Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"mktemp is not available on all platforms.  Instead of littering the code\nwith a work-around, this commit replaces mktemp with a one-line Perl\nscript.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nv2 did not affect this patch.\n\n\n contrib/diffall/git-diffall |   11 ++++-------\n 1 file changed, 4 insertions(+), 7 deletions(-)\n\ndiff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall\nindex d706a6d..443f646 100755\n--- a/contrib/diffall/git-diffall\n+++ b/contrib/diffall/git-diffall\n@@ -45,13 +45,10 @@ cd \"$cdup\" || {\n \texit 1\n }\n \n-# mktemp is not available on all platforms (missing from msysgit)\n-# Use a hard-coded tmp dir if it is not available\n-tmp=\"$(mktemp -d -t tmp.XXXXXX 2>/dev/null)\" || {\n-\ttmp=/tmp/git-diffall-tmp.$$\n-\tmkdir \"$tmp\" || exit 1\n-}\n-\n+# set up temp dir\n+tmp=$(perl -e 'use File::Temp qw(tempdir);\n+\t$t=tempdir(\"/tmp/git-diffall.XXXXX\") or exit(1);\n+\tprint $t') || exit 1\n trap 'rm -rf \"$tmp\" 2>/dev/null' EXIT\n \n left=\n-- \n1.7.10.rc0\n"},{"id":"186961","messageId":"1331743086-32304-4-git-send-email-tim.henigan@gmail.com","threadId":"29948","inReplyTo":"1331743086-32304-1-git-send-email-tim.henigan@gmail.com","subject":"[PATCH 3/5 v2] contrib/diffall: eliminate use of tar","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-14T16:38:04Z","receivedAt":"2012-03-14T16:38:04Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"The 'tar' utility is not available on all platforms (some only support\n'gnutar').  An earlier commit created a work-around for this problem,\nbut a better solution is to eliminate the use of 'tar' completely.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nChanges in v2:\n  - Added missing '$name' component to the 'cp' target.  This bug\n    resulted in modified working copy files being copied to the wrong\n    location in the tmp directory.  It only affected files in sub-\n    directories of the repo root.\n\n\n contrib/diffall/git-diffall |   12 ++++++++----\n 1 file changed, 8 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall\nindex 443f646..f981ac1 100755\n--- a/contrib/diffall/git-diffall\n+++ b/contrib/diffall/git-diffall\n@@ -202,10 +202,14 @@ then\n \t\tfi\n \tdone < \"$tmp/filelist\"\n else\n-\t# Mac users have gnutar rather than tar\n-\t(tar --ignore-failed-read -c -T \"$tmp/filelist\" | (cd \"$tmp/$right_dir\" && tar -x)) || {\n-\t\tgnutar --ignore-failed-read -c -T \"$tmp/filelist\" | (cd \"$tmp/$right_dir\" && gnutar -x)\n-\t}\n+\twhile read name\n+\tdo\n+\t\tif test -e \"$name\"\n+\t\tthen\n+\t\t\tmkdir -p \"$tmp/$right_dir/$(dirname \"$name\")\"\n+\t\t\tcp \"$name\" \"$tmp/$right_dir/$name\"\n+\t\tfi\n+\tdone < \"$tmp/filelist\"\n fi\n \n # Populate the tmp/left_dir directory with the files to be compared\n-- \n1.7.10.rc0\n"},{"id":"186962","messageId":"1331743086-32304-5-git-send-email-tim.henigan@gmail.com","threadId":"29948","inReplyTo":"1331743086-32304-1-git-send-email-tim.henigan@gmail.com","subject":"[PATCH 4/5 v2] contrib/diffall: eliminate duplicate while loops","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-14T16:38:05Z","receivedAt":"2012-03-14T16:38:05Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"There were 3 instances of a 'while read; do' that used identical logic\nto populate '/tmp/right_dir'. This commit groups them into a single loop.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nv2 did not affect this patch.\n\n\n contrib/diffall/git-diffall |   24 +++++++++---------------\n 1 file changed, 9 insertions(+), 15 deletions(-)\n\ndiff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall\nindex f981ac1..91a31c8 100755\n--- a/contrib/diffall/git-diffall\n+++ b/contrib/diffall/git-diffall\n@@ -179,38 +179,32 @@ fi\n mkdir -p \"$tmp/$left_dir\" \"$tmp/$right_dir\"\n \n # Populate the tmp/right_dir directory with the files to be compared\n-if test -n \"$right\"\n-then\n-\twhile read name\n-\tdo\n+while read name\n+do\n+\tif test -n \"$right\"\n+\tthen\n \t\tls_list=$(git ls-tree $right \"$name\")\n \t\tif test -n \"$ls_list\"\n \t\tthen\n \t\t\tmkdir -p \"$tmp/$right_dir/$(dirname \"$name\")\"\n \t\t\tgit show \"$right\":\"$name\" >\"$tmp/$right_dir/$name\" || true\n \t\tfi\n-\tdone < \"$tmp/filelist\"\n-elif test -n \"$compare_staged\"\n-then\n-\twhile read name\n-\tdo\n+\telif test -n \"$compare_staged\"\n+\tthen\n \t\tls_list=$(git ls-files -- \"$name\")\n \t\tif test -n \"$ls_list\"\n \t\tthen\n \t\t\tmkdir -p \"$tmp/$right_dir/$(dirname \"$name\")\"\n \t\t\tgit show :\"$name\" >\"$tmp/$right_dir/$name\"\n \t\tfi\n-\tdone < \"$tmp/filelist\"\n-else\n-\twhile read name\n-\tdo\n+\telse\n \t\tif test -e \"$name\"\n \t\tthen\n \t\t\tmkdir -p \"$tmp/$right_dir/$(dirname \"$name\")\"\n \t\t\tcp \"$name\" \"$tmp/$right_dir/$name\"\n \t\tfi\n-\tdone < \"$tmp/filelist\"\n-fi\n+\tfi\n+done < \"$tmp/filelist\"\n \n # Populate the tmp/left_dir directory with the files to be compared\n while read name\n-- \n1.7.10.rc0\n"},{"id":"186963","messageId":"1331743086-32304-6-git-send-email-tim.henigan@gmail.com","threadId":"29948","inReplyTo":"1331743086-32304-1-git-send-email-tim.henigan@gmail.com","subject":"[PATCH 5/5 v2] contrib/diffall: fix cleanup trap on Windows","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2012-03-14T16:38:06Z","receivedAt":"2012-03-14T16:38:06Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"Prior to this commit, the cleanup trap that removes the tmp dir\ncreated by the script would fail on Windows. The error was silently\nignored by the script.\n\nOn Windows, a directory cannot be removed while it is the working\ndirectory of the process (thanks to Johannes Sixt on the Git list\nfor this info [1]).\n\nThis commit eliminates the 'cd' into the tmp directory that caused\nthe error.\n\n[1]: http://article.gmane.org/gmane.comp.version-control.git/193086\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nThis patch was added in v2 of the series.\n\n\n contrib/diffall/git-diffall |    7 +++----\n 1 file changed, 3 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/diffall/git-diffall b/contrib/diffall/git-diffall\nindex 91a31c8..84f2b65 100755\n--- a/contrib/diffall/git-diffall\n+++ b/contrib/diffall/git-diffall\n@@ -49,7 +49,7 @@ cd \"$cdup\" || {\n tmp=$(perl -e 'use File::Temp qw(tempdir);\n \t$t=tempdir(\"/tmp/git-diffall.XXXXX\") or exit(1);\n \tprint $t') || exit 1\n-trap 'rm -rf \"$tmp\" 2>/dev/null' EXIT\n+trap 'rm -rf \"$tmp\"' EXIT\n \n left=\n right=\n@@ -233,9 +233,8 @@ do\n \tfi\n done < \"$tmp/filelist\"\n \n-cd \"$tmp\"\n-LOCAL=\"$left_dir\"\n-REMOTE=\"$right_dir\"\n+LOCAL=\"$tmp/$left_dir\"\n+REMOTE=\"$tmp/$right_dir\"\n \n if test -n \"$diff_tool\"\n then\n-- \n1.7.10.rc0\n"}]}