1#!/usr/bin/env bash 2 3# Test that running save more than once with no other changes produces 4# the exact same tree. 5 6# Note: we can't compare the top-level hash (i.e. the output of "save 7# -t" because that currently pulls the metadata for unindexed parent 8# directories directly from the filesystem, and the relevant atimes 9# may change between runs. So instead we extract the roots of the 10# indexed trees for comparison via t/subtree-hash. 11 12. ./wvtest-bup.sh || exit $? 13 14set -o pipefail 15 16WVSTART 'all' 17 18top="$(pwd)" 19tmpdir="$(WVPASS wvmktempdir)" || exit $? 20 21export BUP_DIR="$tmpdir/bup" 22export GIT_DIR="$BUP_DIR" 23 24bup() { "$top/bup" "$@"; } 25 26WVPASS mkdir -p "$tmpdir/src" 27WVPASS mkdir -p "$tmpdir/src/d" 28WVPASS mkdir -p "$tmpdir/src/d/e" 29WVPASS touch "$tmpdir/src/"{f,b,a,d} 30WVPASS touch "$tmpdir/src/d/z" 31 32WVPASS bup init 33WVPASS bup index -u "$tmpdir/src" 34 35declare -a indexed_top 36IFS=/ 37indexed_top="${tmpdir##/}" 38indexed_top=(${indexed_top%%/}) 39unset IFS 40 41tree1=$(WVPASS bup save -t "$tmpdir/src") || exit $? 42indexed_tree1="$(WVPASS t/subtree-hash "$tree1" "${indexed_top[@]}" src)" \ 43 || exit $? 44 45result="$(WVPASS cd "$tmpdir/src"; WVPASS bup index -m)" || exit $? 46WVPASSEQ "$result" "" 47 48tree2=$(WVPASS bup save -t "$tmpdir/src") || exit $? 49indexed_tree2="$(WVPASS t/subtree-hash "$tree2" "${indexed_top[@]}" src)" \ 50 || exit $? 51 52WVPASSEQ "$indexed_tree1" "$indexed_tree2" 53 54result="$(WVPASS bup index -s / | WVFAIL grep ^D)" || exit $? 55WVPASSEQ "$result" "" 56 57tree3=$(WVPASS bup save -t /) || exit $? 58indexed_tree3="$(WVPASS t/subtree-hash "$tree3" "${indexed_top[@]}" src)" || exit $? 59WVPASSEQ "$indexed_tree1" "$indexed_tree3" 60 61WVPASS rm -rf "$tmpdir" 62