summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2010-05-09 05:35:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-05-09 05:35:35 (GMT)
commitc58c5129d6f0a35ee62bcc0892209a2400e9f4e6 (patch)
tree17afc52b50aa2f5a28c13afbe0fd0e21e813b22d /t
parentf78eeeaf55a4f60a05d3e6452f29a2214c29b6fd (diff)
parenta347b17f15dd5358ced8d447af144a46b224982d (diff)
downloadgit-c58c5129d6f0a35ee62bcc0892209a2400e9f4e6.zip
git-c58c5129d6f0a35ee62bcc0892209a2400e9f4e6.tar.gz
git-c58c5129d6f0a35ee62bcc0892209a2400e9f4e6.tar.bz2
Merge branch 'cw/ws-indent-with-tab'
* cw/ws-indent-with-tab: whitespace: tests for git-apply --whitespace=fix with tab-in-indent whitespace: add tab-in-indent support for --whitespace=fix whitespace: replumb ws_fix_copy to take a strbuf *dst instead of char *dst whitespace: tests for git-diff --check with tab-in-indent error class whitespace: add tab-in-indent error class whitespace: we cannot "catch all errors known to git" anymore
Diffstat (limited to 't')
-rwxr-xr-xt/t4015-diff-whitespace.sh42
-rwxr-xr-xt/t4124-apply-ws-rule.sh53
2 files changed, 71 insertions, 24 deletions
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 90f3342..e92eab0 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -352,6 +352,48 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:
'
+test_expect_success 'check tabs as indentation (tab-in-indent: off)' '
+
+ git config core.whitespace "-tab-in-indent" &&
+ echo " foo ();" > x &&
+ git diff --check
+
+'
+
+test_expect_success 'check tabs as indentation (tab-in-indent: on)' '
+
+ git config core.whitespace "tab-in-indent" &&
+ echo " foo ();" > x &&
+ test_must_fail git diff --check
+
+'
+
+test_expect_success 'check tabs and spaces as indentation (tab-in-indent: on)' '
+
+ git config core.whitespace "tab-in-indent" &&
+ echo " foo ();" > x &&
+ test_must_fail git diff --check
+
+'
+
+test_expect_success 'check tab-in-indent and indent-with-non-tab conflict' '
+
+ git config core.whitespace "tab-in-indent,indent-with-non-tab" &&
+ echo "foo ();" > x &&
+ test_must_fail git diff --check
+
+'
+
+test_expect_success 'check tab-in-indent excluded from wildcard whitespace attribute' '
+
+ git config --unset core.whitespace &&
+ echo "x whitespace" > .gitattributes &&
+ echo " foo ();" > x &&
+ git diff --check &&
+ rm -f .gitattributes
+
+'
+
test_expect_success 'line numbers in --check output are correct' '
echo "" > x &&
diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh
index fb9ad24..8d46df6 100755
--- a/t/t4124-apply-ws-rule.sh
+++ b/t/t4124-apply-ws-rule.sh
@@ -11,21 +11,22 @@ prepare_test_file () {
# ! trailing-space
# @ space-before-tab
# # indent-with-non-tab
+ # % tab-in-indent
sed -e "s/_/ /g" -e "s/>/ /" <<-\EOF
An_SP in an ordinary line>and a HT.
- >A HT.
- _>A SP and a HT (@).
- _>_A SP, a HT and a SP (@).
+ >A HT (%).
+ _>A SP and a HT (@%).
+ _>_A SP, a HT and a SP (@%).
_______Seven SP.
________Eight SP (#).
- _______>Seven SP and a HT (@).
- ________>Eight SP and a HT (@#).
- _______>_Seven SP, a HT and a SP (@).
- ________>_Eight SP, a HT and a SP (@#).
+ _______>Seven SP and a HT (@%).
+ ________>Eight SP and a HT (@#%).
+ _______>_Seven SP, a HT and a SP (@%).
+ ________>_Eight SP, a HT and a SP (@#%).
_______________Fifteen SP (#).
- _______________>Fifteen SP and a HT (@#).
+ _______________>Fifteen SP and a HT (@#%).
________________Sixteen SP (#).
- ________________>Sixteen SP and a HT (@#).
+ ________________>Sixteen SP and a HT (@#%).
_____a__Five SP, a non WS, two SP.
A line with a (!) trailing SP_
A line with a (!) trailing HT>
@@ -39,7 +40,6 @@ apply_patch () {
}
test_fix () {
-
# fix should not barf
apply_patch --whitespace=fix || return 1
@@ -130,20 +130,25 @@ do
for i in - ''
do
case "$i" in '') ti='#' ;; *) ti= ;; esac
- rule=${t}trailing,${s}space,${i}indent
-
- rm -f .gitattributes
- test_expect_success "rule=$rule" '
- git config core.whitespace "$rule" &&
- test_fix "$tt$ts$ti"
- '
-
- test_expect_success "rule=$rule (attributes)" '
- git config --unset core.whitespace &&
- echo "target whitespace=$rule" >.gitattributes &&
- test_fix "$tt$ts$ti"
- '
-
+ for h in - ''
+ do
+ [ -z "$h$i" ] && continue
+ case "$h" in '') th='%' ;; *) th= ;; esac
+ rule=${t}trailing,${s}space,${i}indent,${h}tab
+
+ rm -f .gitattributes
+ test_expect_success "rule=$rule" '
+ git config core.whitespace "$rule" &&
+ test_fix "$tt$ts$ti$th"
+ '
+
+ test_expect_success "rule=$rule (attributes)" '
+ git config --unset core.whitespace &&
+ echo "target whitespace=$rule" >.gitattributes &&
+ test_fix "$tt$ts$ti$th"
+ '
+
+ done
done
done
done