# This program is distributable under the terms of the GNU GPL (see
# COPYING).
-# Test rsync handling of the --compare-dest option.
+# Test rsync handling of --compare-dest and similar options.
. "$suitedir/rsync.fns"
alt1dir="$tmpdir/alt1"
alt2dir="$tmpdir/alt2"
+alt3dir="$tmpdir/alt3"
+
+SSH="$scratchdir/src/support/lsh.sh"
# Build some files/dirs/links to copy
$RSYNC -av --include=text --include='*/' --exclude='*' "$fromdir/" "$alt1dir/"
$RSYNC -av --include=etc-ltr-list --include='*/' --exclude='*' "$fromdir/" "$alt2dir/"
+# Create a side dir where there is a candidate destfile of the same name as a sourcefile
+echo "This is a test file" >"$fromdir/likely"
+
+mkdir "$alt3dir"
+echo "This is a test file" >"$alt3dir/likely"
+
sleep 1
-touch "$fromdir/dir/text"
+touch "$fromdir/dir/text" "$fromdir/likely"
$RSYNC -av --exclude=/text --exclude=etc-ltr-list "$fromdir/" "$chkdir/"
checkit "$RSYNC -avv --no-whole-file \
--compare-dest='$alt1dir' --compare-dest='$alt2dir' \
'$fromdir/' '$todir/'" "$chkdir" "$todir"
+
+rm -rf "$todir"
checkit "$RSYNC -avv --no-whole-file \
--copy-dest='$alt1dir' --copy-dest='$alt2dir' \
'$fromdir/' '$todir/'" "$fromdir" "$todir"
+# Test that copy_file() works correctly with tmpfiles
+for maybe_inplace in '' --inplace; do
+ rm -rf "$todir"
+ checkit "$RSYNC -av $maybe_inplace --copy-dest='$alt3dir' \
+ '$fromdir/' '$todir/'" "$fromdir" "$todir"
+
+ for srchost in '' 'localhost:'; do
+ if [ -z "$srchost" ]; then
+ desthost='localhost:'
+ else
+ desthost=''
+ fi
+
+ rm -rf "$todir"
+ checkit "$RSYNC -ave '$SSH' --rsync-path='$RSYNC' $maybe_inplace \
+ --copy-dest='$alt3dir' '$srchost$fromdir/' '$desthost$todir/'" \
+ "$fromdir" "$todir"
+ done
+done
+
# The script would have aborted on error, so getting here means we've won.
exit 0
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2008-2022 Wayne Davison
-
-# This program is distributable under the terms of the GNU GPL (see
-# COPYING).
-
-# Test that copy_file works correctly with tmpfiles
-
-. "$suitedir/rsync.fns"
-
-SSH="$scratchdir/src/support/lsh.sh"
-
-hands_setup
-
-# Create a side dir where there is a candidate destfile of the same name as a sourcefile
-cat >"$scratchdir/from/likely" <<EOF
-This is a test file
-EOF
-
-mkdir "$scratchdir/demo"
-cat >"$scratchdir/demo/likely" <<EOF
-This is a test file
-EOF
-
-# Create a chkdir
-$RSYNC -a "$fromdir/" "$chkdir/"
-
-checkit "$RSYNC -av --inplace --copy-dest='$scratchdir/demo' '$fromdir/' '$todir/'" "$chkdir" "$todir"
-
-for filehost in '' 'localhost:'; do
- for srchost in '' 'localhost:'; do
- if [ -z "$srchost" ]; then
- desthost='localhost:'
- else
- desthost=''
- fi
-
- rm -rf "$todir"
- checkit "$RSYNC -avse '$SSH' --rsync-path='$RSYNC' --inplace --copy-dest='$desthost$scratchdir/demo' '$srchost$fromdir/' '$desthost$todir/'" "$chkdir" "$todir"
- done
-done
-
-# The script would have aborted on error, so getting here means we've won.
-exit 0
+++ /dev/null
-#!/bin/sh
-
-# Copyright (C) 2008-2022 Wayne Davison
-
-# This program is distributable under the terms of the GNU GPL (see
-# COPYING).
-
-# Test that copy_file works correctly with tmpfiles
-
-. "$suitedir/rsync.fns"
-
-SSH="$scratchdir/src/support/lsh.sh"
-
-hands_setup
-
-# Create a side dir where there is a candidate destfile of the same name as a sourcefile
-cat >"$scratchdir/from/likely" <<EOF
-This is a test file
-EOF
-
-mkdir "$scratchdir/demo"
-cat >"$scratchdir/demo/likely" <<EOF
-This is a test file
-EOF
-
-# Create a chkdir
-$RSYNC -a "$fromdir/" "$chkdir/"
-
-checkit "$RSYNC -av --copy-dest='$scratchdir/demo' '$fromdir/' '$todir/'" "$chkdir" "$todir"
-
-for filehost in '' 'localhost:'; do
- for srchost in '' 'localhost:'; do
- if [ -z "$srchost" ]; then
- desthost='localhost:'
- else
- desthost=''
- fi
-
- rm -rf "$todir"
- checkit "$RSYNC -avse '$SSH' --rsync-path='$RSYNC' --copy-dest='$desthost$scratchdir/demo' '$srchost$fromdir/' '$desthost$todir/'" "$chkdir" "$todir"
- done
-done
-
-# The script would have aborted on error, so getting here means we've won.
-exit 0
/* Copy contents of file @source to file @dest with mode @mode.
*
- * If @tmpfilefd is <0, copy_file unlinks @dest and then opens a new
+ * If @tmpfilefd is < 0, copy_file unlinks @dest and then opens a new
* file with name @dest.
*
* Otherwise, copy_file writes to and closes the provided file