{"thread":{"id":"10732","subject":"[NEW REPLACEMENT PATCH] git-checkout: Add a test case for relative paths use.","startedAt":"2007-11-08T13:13:52Z","lastAt":"2007-11-08T23:04:52Z","messageCount":4,"participants":["David Symonds","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58879","messageId":"11945276321726-git-send-email-dsymonds@gmail.com","threadId":"10732","inReplyTo":null,"subject":"[NEW REPLACEMENT PATCH] git-checkout: Add a test case for relative paths use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-08T13:13:52Z","receivedAt":"2007-11-08T13:13: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 |   47 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 47 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..45b9e13\n--- /dev/null\n+++ b/t/t2008-checkout-subdir.sh\n@@ -0,0 +1,47 @@\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+\trm file1 &&\n+\tgit checkout HEAD -- ../dir1/../dir1/file1 && test -f ./file1\n+\n+'\n+\n+test_expect_failure 'checkout with relative path outside tree should fail (1)' \\\n+\t'git checkout HEAD -- ../file0'\n+\n+test_expect_failure 'checkout with relative path outside tree should fail (2)' \\\n+\t'cd dir1 && git checkout HEAD -- ./file0'\n+\n+test_expect_failure 'checkout with relative path outside tree should fail (2)' \\\n+\t'cd dir1 && git checkout HEAD -- ../../file0'\n+\n+test_done\n-- \n1.5.3.1\n"},{"id":"58893","messageId":"Pine.LNX.4.64.0711081427450.4362@racer.site","threadId":"10732","inReplyTo":"11945276321726-git-send-email-dsymonds@gmail.com","subject":"Re: [NEW REPLACEMENT PATCH] git-checkout: Add a test case for relative paths use.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-08T14:32:52Z","receivedAt":"2007-11-08T14:32:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\njust a few nitpicks:\n\nOn Fri, 9 Nov 2007, David Symonds wrote:\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\nplease move the test_tick directly in front of the commit.  Readers might \nassume that it has an effect on mkdir otherwise.\n\n> +\tmkdir dir2 &&\n> +\techo bonjour > dir2/file2 &&\n> +\tgit add dir2/file2 &&\n> +\tgit commit -m \"populate tree\"\n> +\n> +'\n\nPlease lose the empty line before the closing quote.  (This applies to all \ntests.)\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> +\trm file1 &&\n> +\tgit checkout HEAD -- ../dir1/../dir1/file1 && test -f ./file1\n> +\n> +'\n> +\n> +test_expect_failure 'checkout with relative path outside tree should fail (1)' \\\n> +\t'git checkout HEAD -- ../file0'\n\nMaybe do that with an existing file?  Since the test script lives in t/, \nand the test is run in t/trash/, we can test for \"../Makefile\".\n\nAlso, I would shorten the message to \"relative path outside tree should \nfail\".\n\n> +test_expect_failure 'checkout with relative path outside tree should fail (2)' \\\n> +\t'cd dir1 && git checkout HEAD -- ./file0'\n\nI am not convinced that this should fail.\n\n> +test_expect_failure 'checkout with relative path outside tree should fail (2)' \\\n> +\t'cd dir1 && git checkout HEAD -- ../../file0'\n\nPlease add some other test like\n\ntest_expect_success 'checkout with empty prefix' '\n\trm file0 &&\n\tgit checkout HEAD -- file0 &&\n\ttest base = \"$(cat file0)\"\n'\n\nThanks,\nDscho\n"},{"id":"58935","messageId":"7v7iks31lm.fsf@gitster.siamese.dyndns.org","threadId":"10732","inReplyTo":"Pine.LNX.4.64.0711081427450.4362@racer.site","subject":"Re: [NEW REPLACEMENT PATCH] git-checkout: Add a test case for relative paths use.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-08T20:48:37Z","receivedAt":"2007-11-08T20:48:37Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> +\tmkdir dir2 &&\n>> +\techo bonjour > dir2/file2 &&\n>> +\tgit add dir2/file2 &&\n>> +\tgit commit -m \"populate tree\"\n>> +\n>> +'\n>\n> Please lose the empty line before the closing quote.  (This applies to all \n> tests.)\n\nI personaly find the extra blank lines before and after the\nindented test body easier to read.  That is..\n\n\n\ttest_expect_sucess 'test description comes here' '\n\n\t\ttest command 1 &&\n\t\ttest command 2 &&\n                ...\n                test command N\n\n\t'\n\nI agree with all other suggestions from your message.\n"},{"id":"58949","messageId":"Pine.LNX.4.64.0711082304310.4362@racer.site","threadId":"10732","inReplyTo":"7v7iks31lm.fsf@gitster.siamese.dyndns.org","subject":"Re: [NEW REPLACEMENT PATCH] git-checkout: Add a test case for relative paths use.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-11-08T23:04:52Z","receivedAt":"2007-11-08T23:04:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 8 Nov 2007, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> >> +\tmkdir dir2 &&\n> >> +\techo bonjour > dir2/file2 &&\n> >> +\tgit add dir2/file2 &&\n> >> +\tgit commit -m \"populate tree\"\n> >> +\n> >> +'\n> >\n> > Please lose the empty line before the closing quote.  (This applies to all \n> > tests.)\n> \n> I personaly find the extra blank lines before and after the\n> indented test body easier to read. \n\nPersonally, I don't.  But you are the maintainer.\n\nCiao,\nDscho\n"}]}