+ tmpdir="$(WVPASS wvmktempdir)" || exit $?
+ export BUP_DIR="$tmpdir/bup"
+ WVPASS setup-test-tree
+ WVPASS cd "$tmpdir"
+ WVPASS test-src-save-restore
+
+ # Test a deeper subdir/ to make sure top-level non-dir metadata is
+ # restored correctly. We need at least one dir and one non-dir at
+ # the "top-level".
+ WVPASS test -d src/bin
+ WVPASS test -f src/bin/bup
+ WVPASS rm -rf "$BUP_DIR"
+ WVPASS bup init
+ WVPASS touch -t 201111111111 src-restore # Make sure the top won't match.
+ WVPASS bup index src
+ WVPASS bup save -t -n src src
+ WVPASS force-delete src-restore
+ WVPASS bup restore -C src-restore "/src/latest$(pwd)/src/lib/"
+ WVPASS touch -t 201211111111 src-restore # Make sure the top won't match.
+ # Check that the only difference is the top dir.
+ WVFAIL $TOP/t/compare-trees -c src/lib/ src-restore/ > tmp-compare-trees
+ WVPASSEQ $(cat tmp-compare-trees | wc -l) 2
+ WVPASS tail -n +2 tmp-compare-trees | WVPASS grep -qE '^\.d[^ ]+ \./$'
+ WVPASS rm -r "$tmpdir"
+) || exit $?
+
+# Test that we pull the index (not filesystem) metadata for any
+# unchanged files whenever we're saving other files in a given
+# directory.
+WVSTART 'metadata save/restore (using index metadata)'
+(
+ tmpdir="$(WVPASS wvmktempdir)" || exit $?
+ export BUP_DIR="$tmpdir/bup"
+ WVPASS setup-test-tree
+ WVPASS cd "$tmpdir"
+
+ # ...for now -- might be a problem with hardlink restores that was
+ # causing noise wrt this test.
+ WVPASS rm -rf src/hardlink*
+
+ # Pause here to keep the filesystem changes far enough away from
+ # the first index run that bup won't cap their index timestamps
+ # (see "bup help index" for more information). Without this
+ # sleep, the compare-trees test below "Bup should *not* pick up
+ # these metadata..." may fail.
+ WVPASS sleep 1
+
+ WVPASS rm -rf "$BUP_DIR"
+ WVPASS bup init
+ WVPASS bup index src
+ WVPASS bup save -t -n src src
+
+ WVPASS force-delete src-restore-1
+ WVPASS mkdir src-restore-1
+ WVPASS bup restore -C src-restore-1 "/src/latest$(pwd)/"
+ WVPASS test -d src-restore-1/src
+ WVPASS "$TOP/t/compare-trees" -c src/ src-restore-1/src/
+
+ WVPASS echo "blarg" > src/volatile/1
+ WVPASS cp -a src/volatile/1 src-restore-1/src/volatile/
+ WVPASS bup index src
+
+ # Bup should *not* pick up these metadata changes.
+ WVPASS touch src/volatile/2
+
+ WVPASS bup save -t -n src src
+
+ WVPASS force-delete src-restore-2
+ WVPASS mkdir src-restore-2
+ WVPASS bup restore -C src-restore-2 "/src/latest$(pwd)/"
+ WVPASS test -d src-restore-2/src
+ WVPASS "$TOP/t/compare-trees" -c src-restore-1/src/ src-restore-2/src/
+
+ WVPASS rm -r "$tmpdir"
+
+) || exit $?
+