| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# Test for GitHub Issue #59: File permissions ignored |
| 4 |
# This test ensures that mode-only changes are handled correctly |
| 5 |
|
| 6 |
. ${top_srcdir-.}/tests/common.sh |
| 7 |
|
| 8 |
cat << EOF > git-mode.patch |
| 9 |
diff --git a/script.sh b/script.sh |
| 10 |
old mode 100755 |
| 11 |
new mode 100644 |
| 12 |
index abcdefg..1234567 100644 |
| 13 |
--- a/script.sh |
| 14 |
+++ b/script.sh |
| 15 |
@@ -1,3 +1,3 @@ |
| 16 |
#!/bin/bash |
| 17 |
-echo "old" |
| 18 |
+echo "new" |
| 19 |
exit 0 |
| 20 |
diff --git a/mode-only.sh b/mode-only.sh |
| 21 |
old mode 100755 |
| 22 |
new mode 100644 |
| 23 |
EOF |
| 24 |
|
| 25 |
# Test that filterdiff includes mode-only changes when they match |
| 26 |
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i mode-only.sh git-mode.patch 2>errors >result || exit 1 |
| 27 |
[ -s errors ] && exit 1 |
| 28 |
|
| 29 |
cat << EOF | cmp - result || exit 1 |
| 30 |
diff --git a/mode-only.sh b/mode-only.sh |
| 31 |
old mode 100755 |
| 32 |
new mode 100644 |
| 33 |
EOF |
| 34 |
|
| 35 |
# Test that lsdiff shows both files (one with content, one mode-only) |
| 36 |
${LSDIFF} --git-extended-diffs=include --git-extended-diffs=include --git-prefixes=strip git-mode.patch 2>errors2 >result2 || exit 1 |
| 37 |
[ -s errors2 ] && exit 1 |
| 38 |
|
| 39 |
cat << EOF | cmp - result2 || exit 1 |
| 40 |
script.sh |
| 41 |
mode-only.sh |
| 42 |
EOF |
| 43 |
|
| 44 |
# Test including files with content changes |
| 45 |
${FILTERDIFF} --git-extended-diffs=include --git-prefixes=strip -i script.sh git-mode.patch 2>errors3 >result3 || exit 1 |
| 46 |
[ -s errors3 ] && exit 1 |
| 47 |
|
| 48 |
cat << EOF | cmp - result3 || exit 1 |
| 49 |
diff --git a/script.sh b/script.sh |
| 50 |
old mode 100755 |
| 51 |
new mode 100644 |
| 52 |
index abcdefg..1234567 100644 |
| 53 |
--- a/script.sh |
| 54 |
+++ b/script.sh |
| 55 |
@@ -1,3 +1,3 @@ |
| 56 |
#!/bin/bash |
| 57 |
-echo "old" |
| 58 |
+echo "new" |
| 59 |
exit 0 |
| 60 |
EOF |
| 61 |
|
| 62 |
exit 0 |