commit cfbf55314def56a649722267c3ced6d7a2217cc5 from: Omar Polo via: Thomas Adam date: Sat Apr 23 20:32:50 2022 UTC test `got patch' vs path-prefixes, relative paths and strip reminded by and 'looks fine' to stsp@ commit - 9a49df7402bb9c06590d96ac3cf93e397ae6ce46 commit + cfbf55314def56a649722267c3ced6d7a2217cc5 blob - eb9d554aba1a23d607aa13c394b8b001ea4100cb blob + 5b848e84d9952da492bc0fefbca5dc76593b0ef5 --- regress/cmdline/patch.sh +++ regress/cmdline/patch.sh @@ -1304,12 +1304,98 @@ EOF echo 'M gamma/delta' > $testroot/stdout.expected echo 'A gamma/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_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 < $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 < $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 } @@ -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