test `got patch' vs path-prefixes, relative paths and strip reminded by and 'looks fine' to stsp@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
diff --git a/regress/cmdline/patch.sh b/regress/cmdline/patch.sh
index eb9d554..5b848e8 100755
--- a/regress/cmdline/patch.sh
+++ b/regress/cmdline/patch.sh
@@ -1313,6 +1313,92 @@ EOF
test_done $testroot $ret
}
+test_patch_with_path_prefix() {
+ local testroot=`test_init patch_with_path_prefix`
+
+ got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done $testroot $ret
+ return 1
+ fi
+
+ cat <<EOF > $testroot/wt/patch
+--- delta
++++ delta
+@@ -1 +1 @@
+-delta
++DELTA
+--- /dev/null
++++ eta
+@@ -0,0 +1 @@
++eta
+EOF
+
+ (cd $testroot/wt && got patch patch) > $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done $testroot $ret
+ return 1
+ fi
+
+ echo 'M delta' > $testroot/stdout.expected
+ echo 'A eta' >> $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
+}
+
+test_patch_relpath_with_path_prefix() {
+ local testroot=`test_init patch_relpaths_with_path_prefix`
+
+ got checkout -p gamma $testroot/repo $testroot/wt > /dev/null
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done $testroot $ret
+ return 1
+ fi
+
+ mkdir -p $testroot/wt/epsilon/zeta/
+
+ cat <<EOF > $testroot/wt/patch
+--- /dev/null
++++ zeta/theta
+@@ -0,0 +1 @@
++theta
+EOF
+
+ (cd $testroot/wt/epsilon/zeta && got patch -p1 $testroot/wt/patch) \
+ > $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ test_done $testroot $ret
+ return 1
+ fi
+
+ echo 'A epsilon/zeta/theta' >> $testroot/stdout.expected
+
+ cmp -s $testroot/stdout.expected $testroot/stdout
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done $testroot $ret
+ return 1
+ fi
+
+ echo 'theta' > $testroot/theta.expected
+ cmp -s $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ diff -u $testroot/wt/epsilon/zeta/theta $testroot/theta.expected
+ fi
+ test_done $testroot $ret
+}
+
test_parseargs "$@"
run_test test_patch_simple_add_file
run_test test_patch_simple_rm_file
@@ -1335,3 +1421,5 @@ run_test test_patch_prefer_new_path
run_test test_patch_no_newline
run_test test_patch_strip
run_test test_patch_relative_paths
+run_test test_patch_with_path_prefix
+run_test test_patch_relpath_with_path_prefix