Merge branch 'racecommittee_integrated' of

ssh://armin@sapsailing.com/home/trac/git into racecommittee_integrated

Conflicts:
	java/com.sap.sailing.domain/src/com/sap/sailing/domain/leaderboard/impl/AbstractSimpleLeaderboardImpl.java
This commit is contained in:
Armin Zamani
2013-04-11 00:28:12 +02:00
2382 changed files with 1283491 additions and 1283408 deletions
@@ -1,372 +1,372 @@
#!/bin/sh
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
#!/bin/sh
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
@@ -1,381 +1,381 @@
#!/bin/sh
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
git diff -b --ignore-space-at-eol > out
test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
#!/bin/sh
#
# Copyright (c) 2006 Johannes E. Schindelin
#
test_description='Test special whitespace in diff engine.
'
. ./test-lib.sh
. ../diff-lib.sh
# Ray Lehtiniemi's example
cat << EOF > x
do {
nothing;
} while (0);
EOF
git update-index --add x
cat << EOF > x
do
{
nothing;
}
while (0);
EOF
cat << EOF > expect
diff --git a/x b/x
index adf3937..6edc172 100644
--- a/x
+++ b/x
@@ -1,3 +1,5 @@
-do {
+do
+{
nothing;
-} while (0);
+}
+while (0);
EOF
git diff > out
test_expect_success "Ray's example without options" 'test_cmp expect out'
git diff -w > out
test_expect_success "Ray's example with -w" 'test_cmp expect out'
git diff -b > out
test_expect_success "Ray's example with -b" 'test_cmp expect out'
tr 'Q' '\015' << EOF > x
whitespace at beginning
whitespace change
whitespace in the middle
whitespace at end
unchanged line
CR at endQ
EOF
git update-index x
tr '_' ' ' << EOF > x
whitespace at beginning
whitespace change
white space in the middle
whitespace at end__
unchanged line
CR at end
EOF
tr 'Q_' '\015 ' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
-whitespace change
-whitespace in the middle
-whitespace at end
+ whitespace at beginning
+whitespace change
+white space in the middle
+whitespace at end__
unchanged line
-CR at endQ
+CR at end
EOF
git diff > out
test_expect_success 'another test, without options' 'test_cmp expect out'
cat << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
EOF
git diff -w > out
test_expect_success 'another test, with -w' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
@@ -1,6 +1,6 @@
-whitespace at beginning
+ whitespace at beginning
whitespace change
-whitespace in the middle
+white space in the middle
whitespace at end
unchanged line
CR at endQ
git diff -b --ignore-space-at-eol > out
test_expect_failure 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
tr 'Q' '\015' << EOF > expect
diff --git a/x b/x
index d99af23..8b32fb5 100644
--- a/x
+++ b/x
EOF
git diff -b > out
test_expect_success 'another test, with -b' 'test_cmp expect out'
test_expect_success 'check mixed spaces and tabs in indent' '
# This is indented with SP HT SP.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check mixed tabs and spaces in indent' '
# This is indented with HT SP HT.
echo " foo();" > x &&
git diff --check | grep "space before tab in indent"
'
test_expect_success 'check with no whitespace errors' '
git commit -m "snapshot" &&
echo "foo();" > x &&
git diff --check
'
test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
test_must_fail git diff --check
'
test_expect_success '--check and --exit-code are not exclusive' '
git checkout x &&
git diff --check --exit-code
'
test_expect_success '--check and --quiet are not exclusive' '
git diff --check --quiet
'
test_expect_success 'check staged with no whitespace errors' '
echo "foo();" > x &&
git add x &&
git diff --cached --check
'
test_expect_success 'check staged with trailing whitespace' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check staged with space before tab in indent' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff --cached --check
'
test_expect_success 'check with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --check HEAD
'
test_expect_success 'check with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --check HEAD
'
test_expect_success 'check staged with no whitespace errors (diff-index)' '
echo "foo();" > x &&
git add x &&
git diff-index --cached --check HEAD
'
test_expect_success 'check staged with trailing whitespace (diff-index)' '
echo "foo(); " > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check staged with space before tab in indent (diff-index)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
test_must_fail git diff-index --cached --check HEAD
'
test_expect_success 'check with no whitespace errors (diff-tree)' '
echo "foo();" > x &&
git commit -m "new commit" x &&
git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with trailing whitespace (diff-tree)' '
echo "foo(); " > x &&
git commit -m "another commit" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check with space before tab in indent (diff-tree)' '
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
test_must_fail git diff-tree --check HEAD^ HEAD
'
test_expect_success 'check trailing whitespace (trailing-space: off)' '
git config core.whitespace "-trailing-space" &&
echo "foo (); " > x &&
git diff --check
'
test_expect_success 'check trailing whitespace (trailing-space: on)' '
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: off)' '
# indent contains space followed by HT
git config core.whitespace "-space-before-tab" &&
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check space before tab in indent (space-before-tab: on)' '
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
test_must_fail git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: off)' '
git config core.whitespace "-indent-with-non-tab"
echo " foo ();" > x &&
git diff --check
'
test_expect_success 'check spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab: on)' '
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
test_must_fail git diff --check
'
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
echo "foo(); " >> x &&
git diff --check | grep "x:2:"
'
test_expect_success 'checkdiff detects trailing blank lines' '
echo "foo();" >x &&
echo "" >>x &&
git diff --check | grep "ends with blank"
'
test_expect_success 'checkdiff allows new blank lines' '
git checkout x &&
mv x y &&
(
echo "/* This is new */" &&
echo "" &&
cat y
) >x &&
git diff --check
'
test_expect_success 'combined diff with autocrlf conversion' '
git reset --hard &&
echo >x hello &&
git commit -m "one side" x &&
git checkout HEAD^ &&
echo >x goodbye &&
git commit -m "the other side" x &&
git config core.autocrlf true &&
test_must_fail git merge master &&
git diff | sed -e "1,/^@@@/d" >actual &&
! grep "^-" actual
'
test_done
@@ -1,46 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="Python 2.7 (C:/Python27/python.exe)" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 2.7 (C:/Python27/python.exe) interpreter library" level="application" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/java-diff-utils-1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jython.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="Python" name="Python">
<configuration sdkName="Python 2.7 (C:/Python27/python.exe)" />
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Python 2.7 (C:/Python27/python.exe) interpreter library" level="application" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/java-diff-utils-1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jython.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
@@ -1,10 +1,10 @@
--- /bonobo/bonobo.iml
+++ /bonobo/bonobo.iml
@@ -41,6 +40,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="library" name="Python 2.6.6 (/usr/bin/python2.6) interpreter library" level="application" />
</component>
</module>
--- /bonobo/bonobo.iml
+++ /bonobo/bonobo.iml
@@ -41,6 +40,7 @@
<SOURCES />
</library>
</orderEntry>
+ <orderEntry type="library" name="Python 2.6.6 (/usr/bin/python2.6) interpreter library" level="application" />
</component>
</module>
@@ -1 +1 @@
svn: '77954' path not found
svn: '77954' path not found
@@ -1 +1 @@
svn: '77954' path not found
svn: '77954' path not found
@@ -1,54 +1,54 @@
<p>Esta &eacute; uma obra Online.</p>
<p>&nbsp;</p>
<p><strong>Este texto &eacute; negrito</strong></p>
<p><em>Este texto &eacute; it&aacute;lico</em></p>
<p><span style="text-decoration:underline;">Este texto est&aacute; sublinhado</span></p>
<p><span style="text-decoration: line-through;">Este texto est&aacute; riscado</span></p>
<p style="text-align: center;">Este texto est&aacute; centralizado</p>
<p style="text-align: right;">Este texto est&aacute; alinhado a direita</p>
<ol>
<li>Este texto est&aacute; em uma lista num&eacute;rica<ol>
<li>Este texto est&aacute; identado</li>
</ol></li>
</ol>
<p><a title="uol" href="http://www.uol.com.br" target="_blank">Este
aqui &eacute; um link</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>,
<p>&nbsp;</p>
<p>P&aacute;gina 1</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 2</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 3</p>
<p>Esta &eacute; uma obra Online.</p>
<p>&nbsp;</p>
<p><strong>Este texto &eacute; negrito</strong></p>
<p><em>Este texto &eacute; it&aacute;lico</em></p>
<p><span style="text-decoration:underline;">Este texto est&aacute; sublinhado</span></p>
<p><span style="text-decoration: line-through;">Este texto est&aacute; riscado</span></p>
<p style="text-align: center;">Este texto est&aacute; centralizado</p>
<p style="text-align: right;">Este texto est&aacute; alinhado a direita</p>
<ol>
<li>Este texto est&aacute; em uma lista num&eacute;rica<ol>
<li>Este texto est&aacute; identado</li>
</ol></li>
</ol>
<p><a title="uol" href="http://www.uol.com.br" target="_blank">Este
aqui &eacute; um link</a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>,
<p>&nbsp;</p>
<p>P&aacute;gina 1</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 2</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>P&aacute;gina 3</p>
<p>&nbsp;</p>
@@ -1,11 +1,11 @@
<p>Revis&atilde;o 3</p><p>&nbsp;</p><p>Esta &eacute; uma obra
Online.</p><p>&nbsp;</p><p><strong>Este texto &eacute;
negrit</strong></p><p>Este texto &eacute; it&aacute;lico/p><p><span
style="text-decoration: undeline;">Este texto est&aacute;
sublinhado</span></p><p>Este texto est&aacute; riscado agora n&atilde;o
est&aacute; mais</p>p style="text-align: left;">Este texto est&aacute;
centralizado nem este</p><p style="text-align: right;">Este texto
est&aacute; alinhado a direita</p><ol><li>Este texto est&aacute; em uma
lista num&eacute;rica</li></ol><p><a title="uol"
href="http://www.uol.com.br" target="_blank">Este aqui &eacute; um
<p>Revis&atilde;o 3</p><p>&nbsp;</p><p>Esta &eacute; uma obra
Online.</p><p>&nbsp;</p><p><strong>Este texto &eacute;
negrit</strong></p><p>Este texto &eacute; it&aacute;lico/p><p><span
style="text-decoration: undeline;">Este texto est&aacute;
sublinhado</span></p><p>Este texto est&aacute; riscado agora n&atilde;o
est&aacute; mais</p>p style="text-align: left;">Este texto est&aacute;
centralizado nem este</p><p style="text-align: right;">Este texto
est&aacute; alinhado a direita</p><ol><li>Este texto est&aacute; em uma
lista num&eacute;rica</li></ol><p><a title="uol"
href="http://www.uol.com.br" target="_blank">Este aqui &eacute; um
link</a></p>
@@ -1,174 +1,174 @@
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utills Library.
Java Diff Utills Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utills Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utills Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised);
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
}
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utills Library.
Java Diff Utills Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utills Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utills Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised);
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
}
@@ -1,308 +1,308 @@
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utils Library.
Java Diff Utils Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utils Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utils Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised); // bla-bla-bla
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk)
{
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-"))
{
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+"))
{
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
/**
* generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
* @author Bill James (tankerbay@gmail.com)
*
* @param fname1 - Filename of the original (unrevised file)
* @param fname2 - Filename of the revised file
* @param originalLines - Lines of the original file
* @param patch - Patch created by the diff() function
* @param contextSize - number of lines of context output around each difference in the file.
* @return List of strings representing the Unified Diff representation of the Patch argument.
*/
public static List<String> generateUnifiedDiff(String fname1, String fname2, List<String> originalLines, Patch patch, int contextSize ) {
List<String> ret = new ArrayList<String>();
ret.add( "--- " + fname1 );
ret.add( "+++ " + fname2 );
List<Delta> cur = new ArrayList<Delta>(); // current list of Delta's to process
int deltact = patch.getDeltas().size();
// if there's more than 1 Delta, we may need to output them together
if ( deltact > 1 ) {
Delta curDelta = patch.getDelta(0);
cur.add( curDelta ); // add the first Delta to the current set
for ( int i = 1; i < deltact; i++ ) {
int curpos = curDelta.getOriginal().getPosition(); // store the current position of the first Delta
Delta nextDelta = patch.getDelta(i); // Check if the next Delta is too close to the current position
if ( (curpos + curDelta.getOriginal().getSize() + contextSize) >= ( nextDelta.getOriginal().getPosition()-contextSize ) ) {
cur.add( nextDelta ); // if it is, add it to the current set
} else {
List<String> curBlock = processDeltas( originalLines, cur, contextSize );
ret.addAll( curBlock ); // if it isn't, output the current set, then create a new
cur.clear(); // set and add the current Delta to it.
cur.add( nextDelta );
}
curDelta = nextDelta;
}
List<String> curBlock = processDeltas( originalLines, cur, contextSize ); // don't forget to process the last set of Deltas
ret.addAll( curBlock );
}
return ret;
}
/**
* processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.
* @author Bill James (tankerbay@gmail.com)
*
* @param origLines - the lines of the original file
* @param deltas - the Deltas to be output as a single block
* @param contextSize - the number of lines of context to place around block
* @return
*/
private static List<String> processDeltas( List<String> origLines, List<Delta> deltas, int contextSize ) {
List<String> buffer = new ArrayList<String>();
int origTotal = 0; // counter for total lines output from Original
int revTotal = 0; // counter for total lines output from Original
int line;
Delta curDelta = deltas.get(0); // start with the first Delta
int origStart = curDelta.getOriginal().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( origStart < 1 ) origStart = 1; // clamp to the start of the file
int revStart = curDelta.getRevised().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( revStart < 1 ) revStart = 1; // clamp to the start of the file
int contextStart = curDelta.getOriginal().getPosition() - contextSize; // find the start of the wrapper context code
if ( contextStart < 0 ) contextStart = 0; // clamp to the start of the file
for ( line = contextStart; line < curDelta.getOriginal().getPosition(); line++ ) { // output the context before the first Delta
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( curDelta ) ); // output the first Delta
origTotal += curDelta.getOriginal().getLines().size();
revTotal += curDelta.getRevised().getLines().size();
int deltaIndex = 1;
while ( deltaIndex < deltas.size() ) { // for each of the other Deltas
Delta nextDelta = deltas.get( deltaIndex );
int intermediateStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = intermediateStart; line < nextDelta.getOriginal().getPosition(); line++ ) {
buffer.add( " " + origLines.get( line ) ); // output the code between the last Delta and this one
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( nextDelta ) ); // output the Delta
origTotal += nextDelta.getOriginal().getLines().size();
revTotal += nextDelta.getRevised().getLines().size();
curDelta = nextDelta;
deltaIndex++; // increment the iterator
}
// Now output the post-Delta context code, clamping the end of the file
contextStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = contextStart; ( line < (contextStart + contextSize )) && ( line < origLines.size() ); line++ ) {
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
// Create and insert the block header, conforming to the Unified Diff standard
StringBuffer header = new StringBuffer();
header.append( "@@ -" );
header.append( origStart );
header.append( "," );
header.append( origTotal );
header.append( " +" );
header.append( revStart );
header.append( "," );
header.append( revTotal );
header.append( " @@" );
buffer.add( 0, header.toString() );
return buffer;
}
/**
* getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter
* @author Bill James (tankerbay@gmail.com)
*
* @param delta - the Delta to output
* @return list of String lines of code.
*/
private static List<String> getDeltaText( Delta delta ) {
List<String> buffer = new ArrayList<String>();
for ( Object line: delta.getOriginal().getLines() ) {
buffer.add( "-" + line );
}
for ( Object line: delta.getRevised().getLines() ) {
buffer.add( "+" + line );
}
return buffer;
}
}
/*
Copyright 2009 Dmitry Naumenko (dm.naumenko@gmail.com)
This file is part of Java Diff Utils Library.
Java Diff Utils Library is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Java Diff Utils Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Java Diff Utils Library. If not, see <http://www.gnu.org/licenses/>.
*/
package difflib;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import difflib.myers.*;
/**
* Implements the difference and patching engine
*
* @author <a href="dm.naumenko@gmail.com">Dmitry Naumenko</a>
* @version 0.4.1
*/
public class DiffUtils {
private static DiffAlgorithm defaultDiffAlgorithm = new MyersDiff();
private static Pattern unifiedDiffChunkRe =
Pattern.compile("@@\\s+-(?:(\\d+)(?:,(\\d+))?)\\s+\\+(?:(\\d+)(?:,(\\d+))?)\\s+@@");
/**
* Compute the difference between the original and revised texts with default diff algorithm
*
* @param original the original text
* @param revised the revised text
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised) {
return DiffUtils.diff(original, revised, defaultDiffAlgorithm);
}
/**
* Compute the difference between the original and revised texts with given diff algorithm
*
* @param original the original text
* @param revised the revised text
* @param algorithm the given algorithm
* @return the patch describing the difference between the original and revised texts
*/
public static Patch diff(List<?> original, List<?> revised, DiffAlgorithm algorithm) {
return algorithm.diff(original, revised);
}
/**
* Patch the original text with given patch
*
* @param original the original text
* @param patch the given patch
* @return the revised text
* @throws PatchFailedException if can't apply patch
*/
public static List<?> patch(List<?> original, Patch patch) throws PatchFailedException {
return patch.applyTo(original);
}
/**
* Unpatch the revised text for a given patch
*
* @param revised the revised text
* @param patch the given patch
* @return the original text
*/
public static List<?> unpatch(List<?> revised, Patch patch) {
return patch.restore(revised); // bla-bla-bla
}
/**
* Parse the given text in unified format and creates the list of deltas for it.
*
* @param diff the text in unified format
* @return the patch with deltas.
*/
public static Patch parseUnifiedDiff(List<String> diff) {
boolean inPrelude = true;
List<Object[]> rawChunk = new ArrayList<Object[]>();
Patch patch = new Patch();
int old_ln = 0, old_n = 0, new_ln = 0, new_n = 0;
String tag = "", rest = "";
for (String line: diff) {
// Skip leading lines until after we've seen one starting with '+++'
if (inPrelude) {
if (line.startsWith("+++")) {
inPrelude = false;
}
continue;
}
Matcher m = unifiedDiffChunkRe.matcher(line);
if (m.find()) {
// Process the lines in the previous chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk) {
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-")) {
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+")) {
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
// Parse the @@ header
old_ln = m.group(1) == null ? 1 : Integer.parseInt(m.group(1));
old_n = m.group(2) == null ? 1 : Integer.parseInt(m.group(2));
new_ln = m.group(3) == null ? 1 : Integer.parseInt(m.group(3));
new_n = m.group(4) == null ? 1 : Integer.parseInt(m.group(4));
old_ln = Integer.parseInt(m.group(1));
if (old_ln == 0) {
old_ln += 1;
}
if (new_ln == 0) {
new_ln += 1;
}
} else {
if (line.length() > 0) {
tag = line.substring(0, 1);
rest = line.substring(1);
if (tag.equals(" ") || tag.equals("+") || tag.equals("-")) {
rawChunk.add(new Object[] {tag, rest});
}
}
}
}
// Process the lines in the last chunk
if (rawChunk.size() != 0) {
List<String> oldChunkLines = new ArrayList<String>();
List<String> newChunkLines = new ArrayList<String>();
for (Object[] raw_line: rawChunk)
{
tag = (String)raw_line[0];
rest = (String)raw_line[1];
if (tag.equals(" ") || tag.equals("-"))
{
oldChunkLines.add(rest);
}
if (tag.equals(" ") || tag.equals("+"))
{
newChunkLines.add(rest);
}
}
patch.addDelta(new ChangeDelta(new Chunk(old_ln - 1, old_n, oldChunkLines),
new Chunk(new_ln - 1, new_n, newChunkLines)));
rawChunk.clear();
}
return patch;
}
/**
* generateUnifiedDiff takes a Patch and some other arguments, returning the Unified Diff format text representing the Patch.
* @author Bill James (tankerbay@gmail.com)
*
* @param fname1 - Filename of the original (unrevised file)
* @param fname2 - Filename of the revised file
* @param originalLines - Lines of the original file
* @param patch - Patch created by the diff() function
* @param contextSize - number of lines of context output around each difference in the file.
* @return List of strings representing the Unified Diff representation of the Patch argument.
*/
public static List<String> generateUnifiedDiff(String fname1, String fname2, List<String> originalLines, Patch patch, int contextSize ) {
List<String> ret = new ArrayList<String>();
ret.add( "--- " + fname1 );
ret.add( "+++ " + fname2 );
List<Delta> cur = new ArrayList<Delta>(); // current list of Delta's to process
int deltact = patch.getDeltas().size();
// if there's more than 1 Delta, we may need to output them together
if ( deltact > 1 ) {
Delta curDelta = patch.getDelta(0);
cur.add( curDelta ); // add the first Delta to the current set
for ( int i = 1; i < deltact; i++ ) {
int curpos = curDelta.getOriginal().getPosition(); // store the current position of the first Delta
Delta nextDelta = patch.getDelta(i); // Check if the next Delta is too close to the current position
if ( (curpos + curDelta.getOriginal().getSize() + contextSize) >= ( nextDelta.getOriginal().getPosition()-contextSize ) ) {
cur.add( nextDelta ); // if it is, add it to the current set
} else {
List<String> curBlock = processDeltas( originalLines, cur, contextSize );
ret.addAll( curBlock ); // if it isn't, output the current set, then create a new
cur.clear(); // set and add the current Delta to it.
cur.add( nextDelta );
}
curDelta = nextDelta;
}
List<String> curBlock = processDeltas( originalLines, cur, contextSize ); // don't forget to process the last set of Deltas
ret.addAll( curBlock );
}
return ret;
}
/**
* processDeltas takes a list of Deltas and outputs them together in a single block of Unified-Diff-format text.
* @author Bill James (tankerbay@gmail.com)
*
* @param origLines - the lines of the original file
* @param deltas - the Deltas to be output as a single block
* @param contextSize - the number of lines of context to place around block
* @return
*/
private static List<String> processDeltas( List<String> origLines, List<Delta> deltas, int contextSize ) {
List<String> buffer = new ArrayList<String>();
int origTotal = 0; // counter for total lines output from Original
int revTotal = 0; // counter for total lines output from Original
int line;
Delta curDelta = deltas.get(0); // start with the first Delta
int origStart = curDelta.getOriginal().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( origStart < 1 ) origStart = 1; // clamp to the start of the file
int revStart = curDelta.getRevised().getPosition()+1 - contextSize; // note the +1 to overcome the 0-offset Position
if ( revStart < 1 ) revStart = 1; // clamp to the start of the file
int contextStart = curDelta.getOriginal().getPosition() - contextSize; // find the start of the wrapper context code
if ( contextStart < 0 ) contextStart = 0; // clamp to the start of the file
for ( line = contextStart; line < curDelta.getOriginal().getPosition(); line++ ) { // output the context before the first Delta
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( curDelta ) ); // output the first Delta
origTotal += curDelta.getOriginal().getLines().size();
revTotal += curDelta.getRevised().getLines().size();
int deltaIndex = 1;
while ( deltaIndex < deltas.size() ) { // for each of the other Deltas
Delta nextDelta = deltas.get( deltaIndex );
int intermediateStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = intermediateStart; line < nextDelta.getOriginal().getPosition(); line++ ) {
buffer.add( " " + origLines.get( line ) ); // output the code between the last Delta and this one
origTotal++;
revTotal++;
}
buffer.addAll( getDeltaText( nextDelta ) ); // output the Delta
origTotal += nextDelta.getOriginal().getLines().size();
revTotal += nextDelta.getRevised().getLines().size();
curDelta = nextDelta;
deltaIndex++; // increment the iterator
}
// Now output the post-Delta context code, clamping the end of the file
contextStart = curDelta.getOriginal().getPosition() + curDelta.getOriginal().getLines().size();
for ( line = contextStart; ( line < (contextStart + contextSize )) && ( line < origLines.size() ); line++ ) {
buffer.add( " " + origLines.get( line ) );
origTotal++;
revTotal++;
}
// Create and insert the block header, conforming to the Unified Diff standard
StringBuffer header = new StringBuffer();
header.append( "@@ -" );
header.append( origStart );
header.append( "," );
header.append( origTotal );
header.append( " +" );
header.append( revStart );
header.append( "," );
header.append( revTotal );
header.append( " @@" );
buffer.add( 0, header.toString() );
return buffer;
}
/**
* getDeltaText returns the lines to be added to the Unified Diff text from the Delta parameter
* @author Bill James (tankerbay@gmail.com)
*
* @param delta - the Delta to output
* @return list of String lines of code.
*/
private static List<String> getDeltaText( Delta delta ) {
List<String> buffer = new ArrayList<String>();
for ( Object line: delta.getOriginal().getLines() ) {
buffer.add( "-" + line );
}
for ( Object line: delta.getRevised().getLines() ) {
buffer.add( "+" + line );
}
return buffer;
}
}