From 41a457e4f814a0e514548b3178e7692129f0fcfe Mon Sep 17 00:00:00 2001 From: Jeff King Date: Wed, 30 Dec 2009 06:01:09 -0500 Subject: textconv: use shell to run helper Currently textconv helpers are run directly. Running through the shell is useful because the user can provide a program with command line arguments, like "antiword -f". It also makes textconv more consistent with other parts of git, most of which run their helpers using the shell. The downside is that textconv helpers with shell metacharacters (like space) in the filename will be broken. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t4031-diff-rewrite-binary.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t4031-diff-rewrite-binary.sh') diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh index a894c60622..27fb31b401 100755 --- a/t/t4031-diff-rewrite-binary.sh +++ b/t/t4031-diff-rewrite-binary.sh @@ -54,7 +54,7 @@ chmod +x dump test_expect_success 'setup textconv' ' echo file diff=foo >.gitattributes && - git config diff.foo.textconv "$PWD"/dump + git config diff.foo.textconv "\"$PWD\""/dump ' test_expect_success 'rewrite diff respects textconv' ' -- cgit v1.2.3 From 6396258368b76d432090c81096755dc1fbc89551 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Fri, 1 Jan 2010 23:15:18 +0100 Subject: t4030, t4031: work around bogus MSYS bash path conversion Recall that MSYS bash converts POSIX style absolute paths to Windows style absolute paths. Unfortunately, it converts a program argument that begins with a double-quote and otherwise looks like an absolute POSIX path, but in doing so, it strips everything past the second double-quote[*]. This case is triggered in the two test scripts. The work-around is to place the Windows style path returned by $(pwd) between the quotes to avoid the path conversion. [*] It is already bogus that a conversion is even considered when a program argument begins with a double-quote because it cannot be an absolute POSIX path. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- t/t4031-diff-rewrite-binary.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t4031-diff-rewrite-binary.sh') diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh index 27fb31b401..7e7b307a24 100755 --- a/t/t4031-diff-rewrite-binary.sh +++ b/t/t4031-diff-rewrite-binary.sh @@ -54,7 +54,7 @@ chmod +x dump test_expect_success 'setup textconv' ' echo file diff=foo >.gitattributes && - git config diff.foo.textconv "\"$PWD\""/dump + git config diff.foo.textconv "\"$(pwd)\""/dump ' test_expect_success 'rewrite diff respects textconv' ' -- cgit v1.2.3 From ded0abc73c67c6a9b9dbc2a22755fab01ae17e41 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Sat, 19 Feb 2011 03:04:56 -0500 Subject: diff: handle diffstat of rewritten binary files The logic in builtin_diffstat assumes that a complete_rewrite pair should have its lines counted. This is nonsensical for binary files and leads to confusing things like: $ git diff --stat --summary HEAD^ HEAD foo.rand | Bin 4096 -> 4096 bytes 1 files changed, 0 insertions(+), 0 deletions(-) $ git diff --stat --summary -B HEAD^ HEAD foo.rand | 34 +++++++++++++++------------------- 1 files changed, 15 insertions(+), 19 deletions(-) rewrite foo.rand (100%) So let's reorder the function to handle binary files first (which from diffstat's perspective look like complete rewrites anyway), then rewrites, then actual diffstats. There are two bonus prizes to this reorder: 1. It gets rid of a now-superfluous goto. 2. The binary case is at the top, which means we can further optimize it in the next patch. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t4031-diff-rewrite-binary.sh | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 't/t4031-diff-rewrite-binary.sh') diff --git a/t/t4031-diff-rewrite-binary.sh b/t/t4031-diff-rewrite-binary.sh index 7e7b307a24..7d7470f21b 100755 --- a/t/t4031-diff-rewrite-binary.sh +++ b/t/t4031-diff-rewrite-binary.sh @@ -44,6 +44,13 @@ test_expect_success 'rewrite diff can show binary patch' ' grep "GIT binary patch" diff ' +test_expect_success 'rewrite diff --stat shows binary changes' ' + git diff -B --stat --summary >diff && + grep "Bin" diff && + grep "0 insertions.*0 deletions" diff && + grep " rewrite file" diff +' + { echo "#!$SHELL_PATH" cat <<'EOF' -- cgit v1.2.3