aboutsummaryrefslogtreecommitdiff
path: root/t/t4100-apply-stat.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <Johannes.Schindelin@gmx.de>2008-06-27 18:43:09 +0100
committerJunio C Hamano <gitster@pobox.com>2008-06-28 01:19:42 -0700
commitc14b9d1e330a7f68ffd0ad7e22d6148c6097c122 (patch)
tree2d25c5e478182d4677e6f21f5592a425f138858d /t/t4100-apply-stat.sh
parentd54467b8c319571b5dc433b1f7e471c4b0f21caf (diff)
downloadgit-c14b9d1e330a7f68ffd0ad7e22d6148c6097c122.tar.gz
git-c14b9d1e330a7f68ffd0ad7e22d6148c6097c122.tar.xz
Allow git-apply to recount the lines in a hunk (AKA recountdiff)
Sometimes, the easiest way to fix up a patch is to edit it directly, even adding or deleting lines. Now, many people are not as divine as certain benevolent dictators as to update the hunk headers correctly at the first try. So teach the tool to do it for us. [jc: with tests] Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4100-apply-stat.sh')
-rwxr-xr-xt/t4100-apply-stat.sh62
1 files changed, 27 insertions, 35 deletions
diff --git a/t/t4100-apply-stat.sh b/t/t4100-apply-stat.sh
index 8073a5a1f..be837bb98 100755
--- a/t/t4100-apply-stat.sh
+++ b/t/t4100-apply-stat.sh
@@ -3,44 +3,36 @@
# Copyright (c) 2005 Junio C Hamano
#
-test_description='git apply --stat --summary test.
+test_description='git apply --stat --summary test, with --recount
'
. ./test-lib.sh
-test_expect_success \
- 'rename' \
- 'git apply --stat --summary <../t4100/t-apply-1.patch >current &&
- test_cmp ../t4100/t-apply-1.expect current'
-
-test_expect_success \
- 'copy' \
- 'git apply --stat --summary <../t4100/t-apply-2.patch >current &&
- test_cmp ../t4100/t-apply-2.expect current'
-
-test_expect_success \
- 'rewrite' \
- 'git apply --stat --summary <../t4100/t-apply-3.patch >current &&
- test_cmp ../t4100/t-apply-3.expect current'
-
-test_expect_success \
- 'mode' \
- 'git apply --stat --summary <../t4100/t-apply-4.patch >current &&
- test_cmp ../t4100/t-apply-4.expect current'
-
-test_expect_success \
- 'non git' \
- 'git apply --stat --summary <../t4100/t-apply-5.patch >current &&
- test_cmp ../t4100/t-apply-5.expect current'
-
-test_expect_success \
- 'non git' \
- 'git apply --stat --summary <../t4100/t-apply-6.patch >current &&
- test_cmp ../t4100/t-apply-6.expect current'
-
-test_expect_success \
- 'non git' \
- 'git apply --stat --summary <../t4100/t-apply-7.patch >current &&
- test_cmp ../t4100/t-apply-7.expect current'
+UNC='s/^\(@@ -[1-9][0-9]*\),[0-9]* \(+[1-9][0-9]*\),[0-9]* @@/\1,999 \2,999 @@/'
+
+num=0
+while read title
+do
+ num=$(( $num + 1 ))
+ test_expect_success "$title" '
+ git apply --stat --summary \
+ <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" >current &&
+ test_cmp ../t4100/t-apply-$num.expect current
+ '
+
+ test_expect_success "$title with recount" '
+ sed -e "$UNC" <"$TEST_DIRECTORY/t4100/t-apply-$num.patch" |
+ git apply --recount --stat --summary >current &&
+ test_cmp ../t4100/t-apply-$num.expect current
+ '
+done <<\EOF
+rename
+copy
+rewrite
+mode
+non git (1)
+non git (2)
+non git (3)
+EOF
test_done