{"thread":{"id":"10717","subject":"[PATCH] git-checkout: Add a test case for relative paths use.","startedAt":"2007-11-08T03:40:52Z","lastAt":"2007-11-08T05:03:04Z","messageCount":2,"participants":["David Symonds","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58794","messageId":"11944932524072-git-send-email-dsymonds@gmail.com","threadId":"10717","inReplyTo":null,"subject":"[PATCH] git-checkout: Add a test case for relative paths use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-08T03:40:52Z","receivedAt":"2007-11-08T03:40:52Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"Signed-off-by: David Symonds <dsymonds@gmail.com>\n---\n t/t2008-checkout-subdir.sh |   36 ++++++++++++++++++++++++++++++++++++\n 1 files changed, 36 insertions(+), 0 deletions(-)\n create mode 100755 t/t2008-checkout-subdir.sh\n\ndiff --git a/t/t2008-checkout-subdir.sh b/t/t2008-checkout-subdir.sh\nnew file mode 100755\nindex 0000000..cb9c9eb\n--- /dev/null\n+++ b/t/t2008-checkout-subdir.sh\n@@ -0,0 +1,36 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 David Symonds\n+\n+test_description='git checkout from subdirectories'\n+\n+. ./test-lib.sh\n+\n+test_expect_success setup '\n+\n+\techo base > file0 &&\n+\tgit add file0 &&\n+\tmkdir dir1 &&\n+\techo hello > dir1/file1 &&\n+\tgit add dir1/file1 &&\n+\ttest_tick &&\n+\tmkdir dir2 &&\n+\techo bonjour > dir2/file2 &&\n+\tgit add dir2/file2 &&\n+\tgit commit -m \"populate tree\"\n+\n+'\n+\n+test_expect_success 'remove and restore with relative path' '\n+\n+\tcd dir1 &&\n+\trm ../file0 &&\n+\tgit checkout HEAD -- ../file0 && test -f ../file0 &&\n+\trm ../dir2/file2 &&\n+\tgit checkout HEAD -- ../dir2/file2 && test -f ../dir2/file2 &&\n+\trm ../file0 ./file1 &&\n+\tgit checkout HEAD -- .. && test -f ../file0 && test -f ./file1\n+\n+'\n+\n+test_done\n-- \n1.5.3.1\n"},{"id":"58796","messageId":"7v8x5972if.fsf@gitster.siamese.dyndns.org","threadId":"10717","inReplyTo":"11944932524072-git-send-email-dsymonds@gmail.com","subject":"Re: [PATCH] git-checkout: Add a test case for relative paths use.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-08T05:03:04Z","receivedAt":"2007-11-08T05:03:04Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Symonds <dsymonds@gmail.com> writes:\n\n> Signed-off-by: David Symonds <dsymonds@gmail.com>\n> ---\n>  t/t2008-checkout-subdir.sh |   36 ++++++++++++++++++++++++++++++++++++\n>  1 files changed, 36 insertions(+), 0 deletions(-)\n>  create mode 100755 t/t2008-checkout-subdir.sh\n>\n> diff --git a/t/t2008-checkout-subdir.sh b/t/t2008-checkout-subdir.sh\n> new file mode 100755\n> index 0000000..cb9c9eb\n> --- /dev/null\n> +++ b/t/t2008-checkout-subdir.sh\n> @@ -0,0 +1,36 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2007 David Symonds\n> +\n> +test_description='git checkout from subdirectories'\n> +\n> +. ./test-lib.sh\n> +\n> +test_expect_success setup '\n> +\n> +\techo base > file0 &&\n> +\tgit add file0 &&\n> +\tmkdir dir1 &&\n> +\techo hello > dir1/file1 &&\n> +\tgit add dir1/file1 &&\n> +\ttest_tick &&\n> +\tmkdir dir2 &&\n> +\techo bonjour > dir2/file2 &&\n> +\tgit add dir2/file2 &&\n> +\tgit commit -m \"populate tree\"\n> +\n> +'\n> +\n> +test_expect_success 'remove and restore with relative path' '\n> +\n> +\tcd dir1 &&\n> +\trm ../file0 &&\n> +\tgit checkout HEAD -- ../file0 && test -f ../file0 &&\n> +\trm ../dir2/file2 &&\n> +\tgit checkout HEAD -- ../dir2/file2 && test -f ../dir2/file2 &&\n> +\trm ../file0 ./file1 &&\n> +\tgit checkout HEAD -- .. && test -f ../file0 && test -f ./file1\n> +\n> +'\n\nThis is better than not having any test, but we would also want\na negative test.  Things like trying to check out \"../file\"\nwithout going down into a subdirectory, check out \"../../file\"\nin a subdirectory that is only one level deep.\n"}]}