commit - b7ba71f0ee2562b0d5877b72d4de351a8e78a119
commit + 11d9f2f72df165e4dbfdabac9708d307aa61cab3
blob - 649271a8542372b95f89e82a2a59f8814c6a24f6
blob + 715e8c6ecb06cac5859a9514a294598e33a63288
--- lib/diff_output_unidiff.c
+++ lib/diff_output_unidiff.c
}
left_len = cc->left.end - cc->left.start;
- if (left_len == 0 && cc->left.start > 0)
+ if (result->left.atoms.len == 0)
+ left_start = 0;
+ else if (left_len == 0 && cc->left.start > 0)
left_start = cc->left.start;
else
left_start = cc->left.start + 1;
right_len = cc->right.end - cc->right.start;
- if (right_len == 0 && cc->right.start > 0)
+ if (result->right.atoms.len == 0)
+ right_start = 0;
+ else if (right_len == 0 && cc->right.start > 0)
right_start = cc->right.start;
else
right_start = cc->right.start + 1;
blob - /dev/null
blob + fd5d0482ba389723d64e902b2f26af9b623bbadd (mode 644)
--- /dev/null
+++ test/expect015.diff
+--- test015.left.txt
++++ test015.right.txt
+@@ -1 +0,0 @@
+-A
blob - 9cd69d81128309347f230ac1951e7c0fdeb4683d
blob + ced2e4ff605ec81e767901fde530bc1b5f36cdf4
--- test/verify_all.sh
+++ test/verify_all.sh
diff_prog="../diff/diff"
+# At present, test015 only passes with GNU patch.
+# Larry's patch has a bug with empty files in combination with -R...
+if which gpatch > /dev/null; then
+ patch_prog="gpatch"
+else
+ patch_prog="patch"
+fi
+
diff_type=unidiff
verify_diff_script() {
fi
if [ -z "$ignore_whitespace" -a "x$diff_type" = "xunidiff" ]; then
cp "$orig_left" "$verify_right"
- patch --quiet -u "$verify_right" "$the_diff"
+ $patch_prog --quiet -u "$verify_right" "$the_diff"
if ! cmp "$orig_right" "$verify_right" ; then
echo "FAIL: $orig_right != $verify_right"
return 1
fi
cp "$orig_right" "$verify_left"
- patch --quiet -u -R "$verify_left" "$the_diff"
+ $patch_prog --quiet -u -R "$verify_left" "$the_diff"
if ! cmp "$orig_left" "$verify_left" ; then
echo "FAIL: $orig_left != $verify_left"
return 1