patch/tests/file-modes
Quentin Casasnovas c80b1a06a9 test-lib.sh: factorize require_* functions
Since the code is identical when just checking if a utility is present on
the system or not, we can factorize it.

Signed-off-by: Quentin Casasnovas <quentin.casasnovas@oracle.com>
2015-01-31 22:14:01 +01:00

87 lines
1.3 KiB
Plaintext

# Copyright (C) 2010-2012 Free Software Foundation, Inc.
#
# Copying and distribution of this file, with or without modification,
# in any medium, are permitted without royalty provided the copyright
# notice and this notice are preserved.
# Test if git diffs can change file modes
. $srcdir/test-lib.sh
require cat
require sed
use_local_patch
use_tmpdir
# ==============================================================
cat > f.diff <<EOF
diff --git a/f b/f
old mode 100644
new mode 100600
index 3367afd..3e75765
--- a/f
+++ a/f
@@ -1 +1 @@
-old
+new
diff --git a/g b/g
old mode 100644
new mode 100600
index 3367afd..3e75765
--- a/g
+++ a/g
@@ -1 +1 @@
-old
+new
EOF
echo old > f
echo old > g
chmod 644 f g
check 'patch -p1 < f.diff' <<EOF
patching file f
patching file g
EOF
check 'ls -l f g | sed "s,\(..........\).*,\1,"' <<EOF
-rw-------
-rw-------
EOF
check 'patch -p1 -R < f.diff' <<EOF
patching file f
patching file g
EOF
check 'ls -l f g | sed "s,\(..........\).*,\1,"' <<EOF
-rw-r--r--
-rw-r--r--
EOF
cat > g.diff <<EOF
diff --git a/f b/f
old mode 100644
new mode 100600
diff --git a/g b/g
old mode 100644
new mode 100600
EOF
chmod 600 f
chmod 644 g
check 'patch -p1 < g.diff || echo "Status: $?"' <<EOF
patching file f
patching file g
EOF
check 'ls -l f g | sed "s,\(..........\).*,\1,"' <<EOF
-rw-------
-rw-------
EOF