Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 bup (0.29-3) unstable; urgency=medium
 .
   [ Tim Riemenschneider ]
   * Safeguard against deleting new pack-file (f.e. with threshold=0)
     (Closes: #859295)
Author: Robert Edmonds <edmonds@debian.org>
Bug-Debian: https://bugs.debian.org/859295

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: 2017-04-01

--- bup-0.29.orig/Makefile
+++ bup-0.29/Makefile
@@ -25,7 +25,7 @@ current_sampledata := t/sampledata/var/r
 os := $(shell ($(pf); uname | sed 's/[-_].*//') $(isok))
 os := $(call shout,$(os),Unable to determine OS)
 
-CFLAGS := -Wall -O2 -Werror -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS)
+CFLAGS := -Wall -O2 -Wno-unknown-pragmas $(PYINCLUDE) $(CFLAGS)
 CFLAGS := -D_FILE_OFFSET_BITS=64 $(CFLAGS)
 SOEXT:=.so
 
@@ -52,7 +52,7 @@ bup_cmds := cmd/bup-python\
 
 bup_deps := bup lib/bup/_checkout.py lib/bup/_helpers$(SOEXT) $(bup_cmds)
 
-all: $(bup_deps) Documentation/all $(current_sampledata)
+all: $(bup_deps) $(current_sampledata)
 
 bup:
 	ln -s main.py bup
--- bup-0.29.orig/cmd/version-cmd.py
+++ bup-0.29/cmd/version-cmd.py
@@ -49,7 +49,7 @@ def version_tag():
     names = names[1:-1]
     l = [n.strip() for n in names.split(',')]
     for n in l:
-        if n.startswith('tag: ') and version_rx.match(n[5:]):
+        if n.startswith('tag: '):
             return n[5:]
     return 'unknown-%s' % version.COMMIT[:7]
 
--- /dev/null
+++ bup-0.29/config/config.h.tmp
@@ -0,0 +1,27 @@
+/*
+ * configuration for bup, generated Sat Apr  1 18:42:19 UTC 2017
+ * by pbuilder@chase
+ */
+#ifndef __AC_BUP_D
+#define __AC_BUP_D 1
+
+
+#define OS_LINUX 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_UNISTD_H 1
+#define HAVE_SYS_MMAN_H 1
+#define HAVE_LINUX_FS_H 1
+#define HAVE_SYS_IOCTL_H 1
+#define HAVE_UTIMENSAT 1
+#define HAVE_UTIMES 1
+#define HAVE_LUTIMES 1
+#define HAVE_MINCORE 1
+#define BUP_MINCORE_BUF_TYPE unsigned char
+#define HAVE_STAT_ST_ATIM 1
+#define HAVE_STAT_ST_MTIM 1
+#define HAVE_STAT_ST_CTIM 1
+#define HAVE_TM_TM_GMTOFF 1
+#define PATH_SED "/bin/sed"
+
+#endif/* __AC_BUP_D */
--- bup-0.29.orig/lib/bup/_release.py
+++ bup-0.29/lib/bup/_release.py
@@ -2,6 +2,6 @@
 # This will be automatically populated by git via export-subst.
 # cf. ./.gitattributes
 
-COMMIT='$Format:%H$'
-NAMES='$Format:%d$'
-DATE='$Format:%ci$'
+COMMIT='3cf1801c6937bd0b07cd42eadf14dcb684a6f788'
+NAMES=' (HEAD -> branches/0.29, tag: debian/0.29-3)'
+DATE='2017-04-01 14:39:51 -0400'
--- bup-0.29.orig/lib/bup/gc.py
+++ bup-0.29/lib/bup/gc.py
@@ -135,6 +135,8 @@ def sweep(live_objects, existing_count,
         if verbosity and new_pack_prefix:
             log('created ' + basename(new_pack_prefix) + '\n')
         for p in ns.stale_files:
+            if new_pack_prefix and p.startswith(new_pack_prefix):
+                continue  # Don't remove the new pack file
             if verbosity:
                 log('removing ' + basename(p) + '\n')
             os.unlink(p)
--- bup-0.29.orig/t/test-gc.sh
+++ bup-0.29/t/test-gc.sh
@@ -219,4 +219,23 @@ WVPASSEQ 1 $(echo "$only_in_before" | wc
 WVPASSEQ 1 $(echo "$only_in_after" | wc -l)
 WVPASSEQ 1 $(echo "$in_both" | wc -l)
 
+WVSTART "gc (threshold 0)"
+
+WVPASS rm -rf "$BUP_DIR"
+WVPASS bup init
+WVPASS rm -rf src && mkdir src
+WVPASS echo 0 > src/0
+WVPASS echo 1 > src/1
+
+WVPASS bup index src
+WVPASS bup save -n src-1 src
+
+packs_before="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $?
+WVPASS bup gc -v $GC_OPTS --threshold 0 2>&1 | tee gc.log
+packs_after="$(ls "$BUP_DIR/objects/pack/"*.pack)" || exit $?
+# Check that the pack was rewritten, but not removed (since the
+# result-pack is equal to the source pack)
+WVPASSEQ 1 "$(grep -cE '^rewriting ' gc.log)"
+WVPASSEQ "$packs_before" "$packs_after"
+
 WVPASS rm -rf "$tmpdir"
