summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Orgis <thomas@orgis.org>2018-01-22 16:46:38 +0100
committerAndreas Gruenbacher <agruen@gnu.org>2018-01-23 10:56:27 +0100
commit592e1f9163d6261359aa87c2c99d411c0dacf6f3 (patch)
tree26ca154b053abee6b6b0a07a7629bc2a91f04e28
parent15cc7d44d4b942ba8d414159db05fb398c267163 (diff)
downloadpatch-592e1f9163d6261359aa87c2c99d411c0dacf6f3.tar.gz
Create git diff files with indicated mode
* src/patch.c (main): Create git diff files with indicated mode. * tests/file-create-modes: New test case. * tests/Makefile.am (TESTS): Add test case. This fixes building current Linux 4.14.x from the signed tarball and patch file, where the patch creates a script with the executable bit set.
-rw-r--r--src/patch.c8
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/file-create-modes51
3 files changed, 58 insertions, 2 deletions
diff --git a/src/patch.c b/src/patch.c
index bba7e0e..0fe6d72 100644
--- a/src/patch.c
+++ b/src/patch.c
@@ -590,8 +590,12 @@ main (int argc, char **argv)
}
if (inerrno)
- set_file_attributes (TMPOUTNAME, attr, NULL, NULL,
- mode, &new_time);
+ {
+ if (set_mode)
+ attr |= FA_MODE;
+ set_file_attributes (TMPOUTNAME, attr, NULL, NULL,
+ mode, &new_time);
+ }
else
{
attr |= FA_IDS | FA_MODE | FA_XATTRS;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9ae6916..6b6df63 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -35,6 +35,7 @@ TESTS = \
empty-files \
false-match \
fifo \
+ file-create-modes \
file-modes \
filename-choice \
git-binary-diff \
diff --git a/tests/file-create-modes b/tests/file-create-modes
new file mode 100644
index 0000000..d1dc7b7
--- /dev/null
+++ b/tests/file-create-modes
@@ -0,0 +1,51 @@
+# Copyright (C) 2010-2018 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 create files with proper modes
+
+. $srcdir/test-lib.sh
+
+require cat
+require sed
+use_local_patch
+use_tmpdir
+
+# ==============================================================
+
+cat > f.diff <<EOF
+diff --git a/f b/f
+new file mode 100710
+index 0000000..3e75765
+--- /dev/null
++++ b/f
+@@ -0,0 +1 @@
++new
+
+diff --git a/g b/g
+new file mode 100654
+index 0000000..3e75765
+--- /dev/null
++++ b/g
+@@ -0,0 +1 @@
++new
+EOF
+
+check 'patch -p1 < f.diff' <<EOF
+patching file f
+patching file g
+EOF
+
+check 'ls -l f g | sed "s,\(..........\).*,\1,"' <<EOF
+-rwx--x---
+-rw-r-xr--
+EOF
+
+check 'patch -p1 -R < f.diff' <<EOF
+patching file f
+patching file g
+EOF
+
+ncheck '! test -e f -o -e g || echo fail'