aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-10-21 10:49:24 -0700
committerJunio C Hamano <gitster@pobox.com>2011-10-21 10:49:24 -0700
commitdf6840855d24c2f54c0b8a66cbac33d8af43333a (patch)
tree355715d1b644e9fd88307485c424dfadcdae7e81 /t
parent634b29d2705af2e05d593b75ade2be64033468a5 (diff)
parent0a1283bc3955a97557019d077b96669c5c93c551 (diff)
downloadgit-df6840855d24c2f54c0b8a66cbac33d8af43333a.tar.gz
git-df6840855d24c2f54c0b8a66cbac33d8af43333a.tar.xz
Merge branch 'jc/checkout-from-tree-keep-local-changes' into maint
* jc/checkout-from-tree-keep-local-changes: checkout $tree $path: do not clobber local changes in $path not in $tree
Diffstat (limited to 't')
-rwxr-xr-xt/t2022-checkout-paths.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t2022-checkout-paths.sh b/t/t2022-checkout-paths.sh
new file mode 100755
index 000000000..56090d2eb
--- /dev/null
+++ b/t/t2022-checkout-paths.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+test_description='checkout $tree -- $paths'
+. ./test-lib.sh
+
+test_expect_success setup '
+ mkdir dir &&
+ >dir/master &&
+ echo common >dir/common &&
+ git add dir/master dir/common &&
+ test_tick && git commit -m "master has dir/master" &&
+ git checkout -b next &&
+ git mv dir/master dir/next0 &&
+ echo next >dir/next1 &&
+ git add dir &&
+ test_tick && git commit -m "next has dir/next but not dir/master"
+'
+
+test_expect_success 'checking out paths out of a tree does not clobber unrelated paths' '
+ git checkout next &&
+ git reset --hard &&
+ rm dir/next0 &&
+ cat dir/common >expect.common &&
+ echo modified >expect.next1 &&
+ cat expect.next1 >dir/next1 &&
+ echo untracked >expect.next2 &&
+ cat expect.next2 >dir/next2 &&
+
+ git checkout master dir &&
+
+ test_cmp expect.common dir/common &&
+ test_path_is_file dir/master &&
+ git diff --exit-code master dir/master &&
+
+ test_path_is_missing dir/next0 &&
+ test_cmp expect.next1 dir/next1 &&
+ test_path_is_file dir/next2 &&
+ test_must_fail git ls-files --error-unmatch dir/next2 &&
+ test_cmp expect.next2 dir/next2
+'
+
+test_done