add two more tests for update
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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
diff --git a/regress/cmdline/update.sh b/regress/cmdline/update.sh
index e28a356..2967505 100755
--- a/regress/cmdline/update.sh
+++ b/regress/cmdline/update.sh
@@ -359,6 +359,111 @@ function test_update_dir_with_dot_sibling {
test_done "$testroot" "0"
}
+function test_update_moves_files_upwards {
+ local testroot=`test_init update_moves_files_upwards`
+
+ mkdir $testroot/repo/epsilon/psi
+ echo mu > $testroot/repo/epsilon/psi/mu
+ mkdir $testroot/repo/epsilon/psi/chi
+ echo tau > $testroot/repo/epsilon/psi/chi/tau
+ (cd $testroot/repo && git add .)
+ git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ if [ "$?" != "0" ]; then
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ (cd $testroot/repo && git mv epsilon/psi/mu epsilon/mu)
+ (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon/psi/tau)
+ git_commit $testroot/repo -m "moving files upwards"
+
+ echo "A epsilon/mu" > $testroot/stdout.expected
+ echo "A epsilon/psi/tau" >> $testroot/stdout.expected
+ echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
+ echo "D epsilon/psi/mu" >> $testroot/stdout.expected
+ echo -n "Updated to commit " >> $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp $testroot/stdout.expected $testroot/stdout
+ if [ "$?" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ if [ -e $testroot/wt/epsilon/psi/chi ]; then
+ echo "removed dir epsilon/psi/chi still exists on disk" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ if [ -e $testroot/wt/epsilon/psi/mu ]; then
+ echo "removed file epsilon/psi/mu still exists on disk" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ test_done "$testroot" "0"
+}
+
+function test_update_moves_files_to_new_dir {
+ local testroot=`test_init update_moves_files_to_new_dir`
+
+ mkdir $testroot/repo/epsilon/psi
+ echo mu > $testroot/repo/epsilon/psi/mu
+ mkdir $testroot/repo/epsilon/psi/chi
+ echo tau > $testroot/repo/epsilon/psi/chi/tau
+ (cd $testroot/repo && git add .)
+ git_commit $testroot/repo -m "adding a sub-directory beneath epsilon"
+
+ got checkout $testroot/repo $testroot/wt > /dev/null
+ if [ "$?" != "0" ]; then
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ mkdir -p $testroot/repo/epsilon-new/psi
+ (cd $testroot/repo && git mv epsilon/psi/mu epsilon-new/mu)
+ (cd $testroot/repo && git mv epsilon/psi/chi/tau epsilon-new/psi/tau)
+ git_commit $testroot/repo -m "moving files upwards"
+
+ echo "A epsilon-new/mu" > $testroot/stdout.expected
+ echo "A epsilon-new/psi/tau" >> $testroot/stdout.expected
+ echo "D epsilon/psi/chi/tau" >> $testroot/stdout.expected
+ echo "D epsilon/psi/mu" >> $testroot/stdout.expected
+ echo -n "Updated to commit " >> $testroot/stdout.expected
+ git_show_head $testroot/repo >> $testroot/stdout.expected
+ echo >> $testroot/stdout.expected
+
+ (cd $testroot/wt && got update > $testroot/stdout)
+
+ cmp $testroot/stdout.expected $testroot/stdout
+ if [ "$?" != "0" ]; then
+ diff -u $testroot/stdout.expected $testroot/stdout
+ test_done "$testroot" "$?"
+ return 1
+ fi
+
+ if [ -e $testroot/wt/epsilon/psi/chi ]; then
+ echo "removed dir epsilon/psi/chi still exists on disk" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ if [ -e $testroot/wt/epsilon/psi/mu ]; then
+ echo "removed file epsilon/psi/mu still exists on disk" >&2
+ test_done "$testroot" "1"
+ return 1
+ fi
+
+ test_done "$testroot" "0"
+}
+
run_test test_update_basic
run_test test_update_adds_file
run_test test_update_deletes_file
@@ -367,3 +472,5 @@ run_test test_update_deletes_dir_with_path_prefix
run_test test_update_deletes_dir_recursively
run_test test_update_sibling_dirs_with_common_prefix
run_test test_update_dir_with_dot_sibling
+run_test test_update_moves_files_upwards
+#run_test test_update_moves_files_to_new_dir # test is failing