commit - 63ba1a3a6f40953d1636e718c0e0000a3d626159
commit + dbc68eedb1de26bf5a444ecad5150b0a243d422b
blob - 9209e54ce7111b54b69980a44a48a92a333e5888
blob + 1fc82c6604c60d1e3961f7d6670b26b781db97cc
--- lib/patch.c
+++ lib/patch.c
/* don't run the diff3 merge on creations/deletions */
if (*p->blob != '\0' && p->old != NULL && p->new != NULL) {
err = open_blob(&apath, &afile, p->blob, repo);
- if (err && err->code != GOT_ERR_NOT_REF)
+ /*
+ * ignore failures to open this blob, we might have
+ * parsed gibberish.
+ */
+ if (err && !(err->code == GOT_ERR_ERRNO && errno == ENOENT))
return err;
else if (err == NULL)
do_merge = 1;
blob - 20e899eab3a352dc9e8636b15e894c186595d20a
blob + 5d79b58c66cb3e7160cfdb8ce13e13901219e70e
--- regress/cmdline/patch.sh
+++ regress/cmdline/patch.sh
cat <<EOF > $testroot/wt/patch
I've got a
+diff aaaabbbbccccddddeeeeffff0000111122223333 foo/bar
+with a
blob - aaaabbbbccccddddeeeeffff0000111122223333
and also a
-blob + 0000111122223333444455556666888899990000
+blob + 0000111122223333444455556666777788889999
for this dummy diff
--- alpha
+++ alpha
ret=$?
if [ $ret -ne 0 ]; then
diff -u $testroot/stdout.expected $testroot/stdout
+ test_done $testroot $ret
+ return 1
fi
+
+ # try again without a `diff' header
+
+ cat <<EOF > $testroot/wt/patch
+I've got a
+blob - aaaabbbbccccddddeeeeffff0000111122223333
+and also a
+blob + 0000111122223333444455556666777788889999
+for this dummy diff
+--- alpha
++++ alpha
+@@ -1 +1 @@
+-alpha
++ALPHA
+will it work?
+EOF
+
+ (cd $testroot/wt && got revert alpha > /dev/null && got patch patch) \
+ > $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done $testroot $ret
+ return 1
+ fi
+
+ echo 'M alpha' > $testroot/stdout.expected
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ fi
test_done $testroot $ret
}