When finishing up (leaving) a directory and preparing to store its
related tree in the repository, don't write the pending .bupm (which
is still incomplete) to the pack if we know the directory already
exists in the repository (i.e. when we're not going to write it
either).
This problem was discovered when Zoran noticed that two consecutive
saves without an intervening index could produce a repository with an
unreferenced blob (according to git fsck).
Reported-by: Zoran Zaric <zz@zoranzaric.de>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
part = parts.pop()
shalist = shalists.pop()
metalist = metalists.pop()
- if metalist:
+ if metalist and not force_tree:
if dir_metadata: # Override the original metadata pushed for this dir.
metalist = [('', dir_metadata)] + metalist[1:]
sorted_metalist = sorted(metalist, key = lambda x : x[0])
--- /dev/null
+#!/usr/bin/env bash
+. ./wvtest-bup.sh
+
+set -eo pipefail
+
+WVSTART 'all'
+
+top="$(pwd)"
+tmpdir="$(wvmktempdir)"
+export BUP_DIR="$tmpdir/bup"
+export GIT_DIR="$BUP_DIR"
+
+bup() { "$top/bup" "$@"; }
+
+mkdir -p "$tmpdir/src"
+touch "$tmpdir/src/foo"
+bup init
+bup index "$tmpdir/src"
+bup save -n src "$tmpdir/src"
+WVPASSEQ "$(git fsck --unreachable)" ""
+bup save -n src "$tmpdir/src"
+WVPASSEQ "$(git fsck --unreachable)" ""
+
+rm -rf "$tmpdir"