summaryrefslogtreecommitdiff
path: root/t/t4030-diff-textconv.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-10-28 11:40:00 (GMT)
committerJeff King <peff@peff.net>2012-10-28 11:59:44 (GMT)
commitb1c2f57db326c43ec286855b396fb16b4890cf2d (patch)
tree072f9b8a85cea0166e4fafd3df7cd1968d81dea7 /t/t4030-diff-textconv.sh
parent7e2010537e96d0a1144520222f20ba1dc3d61441 (diff)
downloadgit-b1c2f57db326c43ec286855b396fb16b4890cf2d.zip
git-b1c2f57db326c43ec286855b396fb16b4890cf2d.tar.gz
git-b1c2f57db326c43ec286855b396fb16b4890cf2d.tar.bz2
diff_grep: use textconv buffers for add/deleted files
If you use "-G" to grep a diff, we will apply a configured textconv filter to the data before generating the diff. However, if the diff is an addition or deletion, we do not bother running the diff at all, and just look for the token in the added (or removed) content. This works because we know that the diff must contain every line of content. However, while we used the textconv-derived buffers in the regular diff, we accidentally passed the original unmodified buffers to regexec when checking the added or removed content. This could lead to an incorrect answer. Worse, in some cases we might have a textconv buffer but no original buffer (e.g., if we pulled the textconv data from cache, or if we reused a working tree file when generating it). In that case, we could actually feed NULL to regexec and segfault. Reported-by: Peter Oberndorfer <kumbayo84@arcor.de> Signed-off-by: Jeff King <peff@peff.net>
Diffstat (limited to 't/t4030-diff-textconv.sh')
-rwxr-xr-xt/t4030-diff-textconv.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
index eebb1ee..461d27a 100755
--- a/t/t4030-diff-textconv.sh
+++ b/t/t4030-diff-textconv.sh
@@ -84,6 +84,18 @@ test_expect_success 'status -v produces text' '
git reset --soft HEAD@{1}
'
+test_expect_success 'grep-diff (-G) operates on textconv data (add)' '
+ echo one >expect &&
+ git log --root --format=%s -G0 >actual &&
+ test_cmp expect actual
+'
+
+test_expect_success 'grep-diff (-G) operates on textconv data (modification)' '
+ echo two >expect &&
+ git log --root --format=%s -G1 >actual &&
+ test_cmp expect actual
+'
+
cat >expect.stat <<'EOF'
file | Bin 2 -> 4 bytes
1 file changed, 0 insertions(+), 0 deletions(-)