// Determine what file we must process at last
var fd *os.File
+ var chmod fs.FileMode
if tmpExists {
fd, err = os.Open(tmpPath)
if err != nil {
err = ErrLine(err)
goto Finish
}
+ if fi, rerr := fd.Stat(); rerr == nil {
+ chmod = fi.Mode()
+ } else {
+ err = rerr
+ }
defer fd.Close()
} else if fiStdout.Size() > 0 {
fd = fdStdout
if err != nil {
goto Finish
}
+ if chmod != 0 {
+ err = ErrLine(os.Chmod(tgt.a, chmod))
+ if err != nil {
+ goto Finish
+ }
+ }
err = ErrLine(os.Chtimes(tgt.a, finished, finished))
if err != nil {
goto Finish
--- /dev/null
+#!/bin/sh
+
+testname=`basename "$0"`
+test_description="Check that non-renamed target copies mode from temporary target"
+. $SHARNESS_TEST_SRCDIR/sharness.sh
+export REDO_TOP_DIR="`pwd`" REDO_NO_PROGRESS=1
+
+echo echo ok > foo.do
+redo foo
+test_expect_success "foo is non executable" '[ ! -x foo ]'
+inode0=`stat -f %i foo`
+
+cat > foo.do <<EOF
+echo ok > \$3
+chmod +x \$3
+EOF
+redo foo
+test_expect_success "foo is executable" '[ -x foo ]'
+inode1=`stat -f %i foo`
+test_expect_success "foo was not renamed" '[ $inode0 = $inode1 ]'
+
+test_done