[PATCH 1/1] "bup rm /some/SAVE" even if SAVE/.bupm is missing

3 views
Skip to first unread message

Rob Browning

unread,
Aug 20, 2025, 1:58:04 PMAug 20
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---

(Discovered while testing operations on damaged repositories.)

Proposed for main and possibly 0.33.x.

lib/bup/rm.py | 2 +-
note/main.md | 4 ++++
test/ext/test-rm | 19 ++++++++++++++++++-
3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/bup/rm.py b/lib/bup/rm.py
index 0a9ed275..4227ed73 100644
--- a/lib/bup/rm.py
+++ b/lib/bup/rm.py
@@ -66,7 +66,7 @@ def dead_items(repo, paths):
# Scan for bad requests, and opportunities to optimize
for path in paths:
try:
- resolved = vfs.resolve(repo, path, follow=False)
+ resolved = vfs.resolve(repo, path, follow=False, want_meta=False)
except vfs.IOError as e:
add_error(e)
continue
diff --git a/note/main.md b/note/main.md
index bd597f6c..84b0265b 100644
--- a/note/main.md
+++ b/note/main.md
@@ -179,6 +179,10 @@ Bugs
notes](0.33.4-from-0.33.3.md) for additional information. `bup` now
uses hardlinks instead.

+* `bup rm some/SAVE` should now succeed even if the root metadata (the
+ `some/SAVE/.bupm` file) is missing. Previously it failed with
+ "EOFError('encountered EOF while reading vuint')".
+
Build system
------------

diff --git a/test/ext/test-rm b/test/ext/test-rm
index 6b2914dd..3c20764a 100755
--- a/test/ext/test-rm
+++ b/test/ext/test-rm
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
. ./wvtest-bup.sh || exit $?
. ./dev/lib.sh || exit $?
+. ./test/lib/btl.sh || exit $?

top="$(WVPASS pwd)" || exit $?
tmpdir="$(WVPASS wvmktempdir)" || exit $?
@@ -204,11 +205,12 @@ WVPASS bup save -n src src
WVPASS echo twisty-maze > src/2
WVPASS bup index src
WVPASS bup tick
-WVPASS bup save -n src src
+middle_commit="$(WVPASS bup save -cn src src)" || exit $?
WVPASS echo twisty-maze > src/3
WVPASS bup index src
WVPASS bup tick
WVPASS bup save -n src src
+save_names=( $(WVPASS bup ls src) ) || exit $?
WVPASS mv bup bup-baseline
WVPASS bup tick # Make sure we always get the timestamp changes below

@@ -251,6 +253,21 @@ WVPASSEQ "$(commit-hash-n 1 bup src)" "$(commit-hash-n 1 bup-baseline src)"
WVPASSEQ "$(commit-hash-n 2 bup src)" "$(commit-hash-n 2 bup-baseline src)"


+WVSTART 'rm /foo/SAVE with missing /foo/SAVE/.bupm'
+# Primarily a regression test that that rm doesn't just crash. We
+# don't try verify-changes-caused-by-rewriting-save for now because
+# the perforation rearranges objects/pack.
+WVPASS "$top"/dev/sync-tree bup-baseline/ bup/
+WVPASS git ls-tree "$middle_commit": | WVPASS grep -E $'\t\.bupm$' \
+ | WVPASS btl-ent-oid > bupm-oid
+WVPASS "$top/dev/perforate-repo" --drop-oids "$BUP_DIR" < bupm-oid
+WVPASS bup rm --unsafe /src/"${save_names[1]}"
+observed=$(git rev-list src | wc -l) || exit $?
+WVPASSEQ 2 $observed
+WVPASSEQ "$(commit-hash-n 1 bup src)" "$(commit-hash-n 1 bup-baseline src)"
+WVPASSEQ "$(rm-safe-cinfo 2 bup src)" "$(rm-safe-cinfo 3 bup-baseline src)"
+
+
# FIXME: test that committer changes when rewriting, when appropriate

WVPASS cd "$top"
--
2.47.2

Reply all
Reply to author
Forward
0 new messages