{"thread":{"id":"10743","subject":"[PATCH] git-checkout: Test for relative path use.","startedAt":"2007-11-09T00:36:06Z","lastAt":"2007-11-09T19:48:34Z","messageCount":15,"participants":["David Symonds","Junio C Hamano","Johannes Sixt","Robin Rosenberg"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58958","messageId":"11945685673280-git-send-email-dsymonds@gmail.com","threadId":"10743","inReplyTo":null,"subject":"[PATCH] git-checkout: Support relative paths containing \"..\".","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T00:36:06Z","receivedAt":"2007-11-09T00:36:06Z","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 git-checkout.sh |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/git-checkout.sh b/git-checkout.sh\nindex c00cedd..aa724ac 100755\n--- a/git-checkout.sh\n+++ b/git-checkout.sh\n@@ -133,9 +133,9 @@ Did you intend to checkout '$@' which can not be resolved as commit?\"\n \tfi\n \n \t# Make sure the request is about existing paths.\n-\tgit ls-files --error-unmatch -- \"$@\" >/dev/null || exit\n-\tgit ls-files -- \"$@\" |\n-\tgit checkout-index -f -u --stdin\n+\tgit ls-files --full-name --error-unmatch -- \"$@\" >/dev/null || exit\n+\tgit ls-files --full-name -- \"$@\" |\n+\t\t(cd_to_toplevel && git checkout-index -f -u --stdin)\n \n \t# Run a post-checkout hook -- the HEAD does not change so the\n \t# current HEAD is passed in for both args\n-- \n1.5.3.1\n"},{"id":"58954","messageId":"11945685732608-git-send-email-dsymonds@gmail.com","threadId":"10743","inReplyTo":"11945685673280-git-send-email-dsymonds@gmail.com","subject":"[PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T00:36:07Z","receivedAt":"2007-11-09T00:36:07Z","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\tTest 5 in this series fails because of a bug in git-ls-files, where\n\t\tgit-ls-files t/../\n\t(with or without --full-name) returns no files.\n\n t/t2008-checkout-subdir.sh |   79 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 79 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..f226511\n--- /dev/null\n+++ b/t/t2008-checkout-subdir.sh\n@@ -0,0 +1,79 @@\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+\tmkdir dir2 &&\n+\techo \"bonjour\" > dir2/file2 &&\n+\tgit add dir2/file2 &&\n+\ttest_tick &&\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 &&\n+\ttest \"base\" = \"$(cat ../file0)\" &&\n+\trm ../dir2/file2 &&\n+\tgit checkout HEAD -- ../dir2/file2 &&\n+\ttest \"bonjour\" = \"$(cat ../dir2/file2)\" &&\n+\trm ../file0 ./file1 &&\n+\tgit checkout HEAD -- .. &&\n+\ttest \"base\" = \"$(cat ../file0)\" &&\n+\ttest \"hello\" = \"$(cat file1)\" &&\n+\tcd -\n+\n+'\n+\n+test_expect_success 'checkout with empty prefix' '\n+\n+\trm file0 &&\n+\tgit checkout HEAD -- file0 &&\n+\ttest \"base\" = \"$(cat file0)\"\n+\n+'\n+\n+test_expect_success 'checkout with simple prefix' '\n+\n+\trm dir1/file1 &&\n+\tgit checkout HEAD -- dir1 &&\n+\ttest \"hello\" = \"$(cat dir1/file1)\" &&\n+\trm dir1/file1 &&\n+\tgit checkout HEAD -- dir1/file1 &&\n+\ttest \"hello\" = \"$(cat dir1/file1)\"\n+\n+'\n+\n+test_expect_success 'checkout with complex relative path' '\n+\n+\trm file1 &&\n+\tgit checkout HEAD -- ../dir1/../dir1/file1 && test -f ./file1\n+\n+'\n+\n+test_expect_failure 'relative path outside tree should fail' \\\n+\t'git checkout HEAD -- ../../Makefile'\n+\n+test_expect_failure 'incorrect relative path to file should fail (1)' \\\n+\t'git checkout HEAD -- ../file0'\n+\n+test_expect_failure 'incorrect relative path should fail (2)' \\\n+\t'cd dir1 && git checkout HEAD -- ./file0'\n+\n+test_expect_failure 'incorrect relative path should fail (3)' \\\n+\t'cd dir1 && git checkout HEAD -- ../../file0'\n+\n+test_done\n-- \n1.5.3.1\n"},{"id":"58972","messageId":"7vtznwxl59.fsf@gitster.siamese.dyndns.org","threadId":"10743","inReplyTo":"11945685732608-git-send-email-dsymonds@gmail.com","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-09T01:28:18Z","receivedAt":"2007-11-09T01:28:18Z","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> \tTest 5 in this series fails because of a bug in git-ls-files, where\n> \t\tgit-ls-files t/../\n> \t(with or without --full-name) returns no files.\n\nHeh, you shouldn't do that ;-)\n\nSeriously, that's a long standing limitation in the code, not to\ndeal with arbitrary combination of ups and downs, but I do not\nthink there is any fundamental reason to disallow something\nlike:\n\n\tcd Documentation && git ls-files --full-name ../t\n\nPatches welcome.\n"},{"id":"58975","messageId":"ee77f5c20711081744p5d7b46fo88a582b9f5dbdab8@mail.gmail.com","threadId":"10743","inReplyTo":"7vtznwxl59.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T01:44:53Z","receivedAt":"2007-11-09T01:44:53Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On Nov 9, 2007 12:28 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> David Symonds <dsymonds@gmail.com> writes:\n>\n> > Signed-off-by: David Symonds <dsymonds@gmail.com>\n> > ---\n> >       Test 5 in this series fails because of a bug in git-ls-files, where\n> >               git-ls-files t/../\n> >       (with or without --full-name) returns no files.\n>\n> Heh, you shouldn't do that ;-)\n>\n> Seriously, that's a long standing limitation in the code, not to\n> deal with arbitrary combination of ups and downs, but I do not\n> think there is any fundamental reason to disallow something\n> like:\n>\n>         cd Documentation && git ls-files --full-name ../t\n>\n> Patches welcome.\n\nSo you're otherwise happy with my tests, despite one of them\ntriggering an (unrelated to git-checkout) bug? Or would you prefer I\nremove that particular failure from the tests and resend?\n\n\nDave.\n"},{"id":"58978","messageId":"7vd4ukxjxn.fsf@gitster.siamese.dyndns.org","threadId":"10743","inReplyTo":"ee77f5c20711081744p5d7b46fo88a582b9f5dbdab8@mail.gmail.com","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-09T01:54:28Z","receivedAt":"2007-11-09T01:54:28Z","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> On Nov 9, 2007 12:28 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n>> Seriously, that's a long standing limitation in the code, not to\n>> deal with arbitrary combination of ups and downs, but I do not\n>> think there is any fundamental reason to disallow something\n>> like:\n>>\n>>         cd Documentation && git ls-files --full-name ../t\n>>\n>> Patches welcome.\n>\n> So you're otherwise happy with my tests, despite one of them\n> triggering an (unrelated to git-checkout) bug? Or would you prefer I\n> remove that particular failure from the tests and resend?\n\nAre you really asking my preference?  A patch to ls-files to\nmake the test pass is my preference, of course ;-).\n\nHaven't read your tests, though, but I see capable people\nalready commented on the initial round so I do not expect it to\nbe problematic.\n"},{"id":"58979","messageId":"ee77f5c20711081757l46527904x2c962f77fa539bc@mail.gmail.com","threadId":"10743","inReplyTo":"7vd4ukxjxn.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T01:57:08Z","receivedAt":"2007-11-09T01:57:08Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On Nov 9, 2007 12:54 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>\n> Are you really asking my preference?  A patch to ls-files to\n> make the test pass is my preference, of course ;-).\n>\n> Haven't read your tests, though, but I see capable people\n> already commented on the initial round so I do not expect it to\n> be problematic.\n\nI'm going after low-hanging fruit whilst I get familiar with Git's\ninternal structure. I can try to tackle this ls-files problem as a\nseparate thing.\n\n\nDave.\n"},{"id":"58997","messageId":"47340895.6000403@viscovery.net","threadId":"10743","inReplyTo":"11945685732608-git-send-email-dsymonds@gmail.com","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2007-11-09T07:13:25Z","receivedAt":"2007-11-09T07:13:25Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"David Symonds schrieb:\n> +test_expect_success 'remove and restore with relative path' '\n> +\n> +\tcd dir1 &&\n> +\trm ../file0 &&\n> +\tgit checkout HEAD -- ../file0 &&\n> +\ttest \"base\" = \"$(cat ../file0)\" &&\n> +\trm ../dir2/file2 &&\n> +\tgit checkout HEAD -- ../dir2/file2 &&\n> +\ttest \"bonjour\" = \"$(cat ../dir2/file2)\" &&\n> +\trm ../file0 ./file1 &&\n> +\tgit checkout HEAD -- .. &&\n> +\ttest \"base\" = \"$(cat ../file0)\" &&\n> +\ttest \"hello\" = \"$(cat file1)\" &&\n> +\tcd -\n\nWhat if this test fails? Then the rest of the tests run from the wrong \ndirectory. You should put the test in parenthesis (and drop the cd -).\n\n-- Hannes\n"},{"id":"58998","messageId":"ee77f5c20711082324s39a9d441tc05c5a27e6d39f3e@mail.gmail.com","threadId":"10743","inReplyTo":"47340895.6000403@viscovery.net","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T07:24:15Z","receivedAt":"2007-11-09T07:24:15Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On Nov 9, 2007 6:13 PM, Johannes Sixt <j.sixt@viscovery.net> wrote:\n> David Symonds schrieb:\n> > +test_expect_success 'remove and restore with relative path' '\n> > +\n> > +     cd dir1 &&\n> > +     rm ../file0 &&\n> > +     git checkout HEAD -- ../file0 &&\n> > +     test \"base\" = \"$(cat ../file0)\" &&\n> > +     rm ../dir2/file2 &&\n> > +     git checkout HEAD -- ../dir2/file2 &&\n> > +     test \"bonjour\" = \"$(cat ../dir2/file2)\" &&\n> > +     rm ../file0 ./file1 &&\n> > +     git checkout HEAD -- .. &&\n> > +     test \"base\" = \"$(cat ../file0)\" &&\n> > +     test \"hello\" = \"$(cat file1)\" &&\n> > +     cd -\n>\n> What if this test fails? Then the rest of the tests run from the wrong\n> directory. You should put the test in parenthesis (and drop the cd -).\n\nLooking at the existing tests which, when they change directories,\ndon't cd back to where they were; they \"cd ..\" at the start of the\nnext test. I'll add a \"cd ..\" to the relevant bits of my tests.\n\n\nDave.\n"},{"id":"59000","messageId":"11945938461226-git-send-email-dsymonds@gmail.com","threadId":"10743","inReplyTo":"ee77f5c20711082324s39a9d441tc05c5a27e6d39f3e@mail.gmail.com","subject":"[PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T07:37:26Z","receivedAt":"2007-11-09T07:37:26Z","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\tTests that change directories now change back at the start of the\n\tnext test. I don't know what to do about that last test, though.\n\n t/t2008-checkout-subdir.sh |   81 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 81 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..41e76c9\n--- /dev/null\n+++ b/t/t2008-checkout-subdir.sh\n@@ -0,0 +1,81 @@\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+\tmkdir dir2 &&\n+\techo \"bonjour\" > dir2/file2 &&\n+\tgit add dir2/file2 &&\n+\ttest_tick &&\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 &&\n+\ttest \"base\" = \"$(cat ../file0)\" &&\n+\trm ../dir2/file2 &&\n+\tgit checkout HEAD -- ../dir2/file2 &&\n+\ttest \"bonjour\" = \"$(cat ../dir2/file2)\" &&\n+\trm ../file0 ./file1 &&\n+\tgit checkout HEAD -- .. &&\n+\ttest \"base\" = \"$(cat ../file0)\" &&\n+\ttest \"hello\" = \"$(cat file1)\"\n+\n+'\n+\n+# currently in dir1/\n+test_expect_success 'checkout with empty prefix' '\n+\n+\tcd .. &&\n+\trm file0 &&\n+\tgit checkout HEAD -- file0 &&\n+\ttest \"base\" = \"$(cat file0)\"\n+\n+'\n+\n+test_expect_success 'checkout with simple prefix' '\n+\n+\trm dir1/file1 &&\n+\tgit checkout HEAD -- dir1 &&\n+\ttest \"hello\" = \"$(cat dir1/file1)\" &&\n+\trm dir1/file1 &&\n+\tgit checkout HEAD -- dir1/file1 &&\n+\ttest \"hello\" = \"$(cat dir1/file1)\"\n+\n+'\n+\n+test_expect_success 'checkout with complex relative path' '\n+\n+\trm file1 &&\n+\tgit checkout HEAD -- ../dir1/../dir1/file1 && test -f ./file1\n+\n+'\n+\n+test_expect_failure 'relative path outside tree should fail' \\\n+\t'git checkout HEAD -- ../../Makefile'\n+\n+test_expect_failure 'incorrect relative path to file should fail (1)' \\\n+\t'git checkout HEAD -- ../file0'\n+\n+test_expect_failure 'incorrect relative path should fail (2)' \\\n+\t'cd dir1 && git checkout HEAD -- ./file0'\n+\n+# currently in dir1/\n+test_expect_failure 'incorrect relative path should fail (3)' \\\n+\t'git checkout HEAD -- ../../file0'\n+\n+test_done\n-- \n1.5.3.1\n"},{"id":"59002","messageId":"7v7ikrx2st.fsf@gitster.siamese.dyndns.org","threadId":"10743","inReplyTo":"ee77f5c20711082324s39a9d441tc05c5a27e6d39f3e@mail.gmail.com","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-09T08:04:34Z","receivedAt":"2007-11-09T08:04:34Z","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> Looking at the existing tests which, when they change directories,\n> don't cd back to where they were; they \"cd ..\" at the start of the\n> next test. I'll add a \"cd ..\" to the relevant bits of my tests.\n\nDo not follow the bad examples, please.\n"},{"id":"59005","messageId":"ee77f5c20711090014qfed56e7y446c014399e47a82@mail.gmail.com","threadId":"10743","inReplyTo":"7v7ikrx2st.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T08:14:44Z","receivedAt":"2007-11-09T08:14:44Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On Nov 9, 2007 7:04 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \"David Symonds\" <dsymonds@gmail.com> writes:\n>\n> > Looking at the existing tests which, when they change directories,\n> > don't cd back to where they were; they \"cd ..\" at the start of the\n> > next test. I'll add a \"cd ..\" to the relevant bits of my tests.\n>\n> Do not follow the bad examples, please.\n\nSo what would you prefer? Bracketing the whole test in parentheses\nlooks ugly, but I can do that if that's the only option. If I look at\nt5510-fetch.sh (one of yours, Junio), there is no directory\nrestoration in the case of test failure, as in my original patch.\n\nPerhaps test_ok_ and test_failure_ in test-lib.sh should restore the directory?\n\n\nDave.\n"},{"id":"59009","messageId":"7vfxzfvlch.fsf@gitster.siamese.dyndns.org","threadId":"10743","inReplyTo":"ee77f5c20711090014qfed56e7y446c014399e47a82@mail.gmail.com","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-11-09T09:06:54Z","receivedAt":"2007-11-09T09:06:54Z","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> So what would you prefer? Bracketing the whole test in parentheses\n> looks ugly, but I can do that if that's the only option. If I look at\n> t5510-fetch.sh (one of yours, Junio), there is no directory\n> restoration in the case of test failure, as in my original patch.\n\nYes, that is what I was referring to as \"bad examples\".  The way\nt4116 goes down to different directory do not look ugly to me.\n"},{"id":"59011","messageId":"ee77f5c20711090110s5d6c533et5e1e016a95fde943@mail.gmail.com","threadId":"10743","inReplyTo":"7vfxzfvlch.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T09:10:17Z","receivedAt":"2007-11-09T09:10:17Z","isPatch":true,"sender":{"key":"dsymonds@gmail.com","avatar":"https://gravatar.com/avatar/b22f5051cbfc11836e36cf7a690e6cde4e225d835e13295ff98d15c7a9ee3c0f?d=mp&s=160"},"body":"On Nov 9, 2007 8:06 PM, Junio C Hamano <gitster@pobox.com> wrote:\n> \"David Symonds\" <dsymonds@gmail.com> writes:\n>\n> > So what would you prefer? Bracketing the whole test in parentheses\n> > looks ugly, but I can do that if that's the only option. If I look at\n> > t5510-fetch.sh (one of yours, Junio), there is no directory\n> > restoration in the case of test failure, as in my original patch.\n>\n> Yes, that is what I was referring to as \"bad examples\".  The way\n> t4116 goes down to different directory do not look ugly to me.\n\nOkay, thanks -- that's a useful example. I'll resend the patch shortly.\n\n\nDave.\n"},{"id":"59013","messageId":"11945995483966-git-send-email-dsymonds@gmail.com","threadId":"10743","inReplyTo":"ee77f5c20711090110s5d6c533et5e1e016a95fde943@mail.gmail.com","subject":"[PATCH] git-checkout: Test for relative path use.","fromName":"David Symonds","fromEmail":"dsymonds@gmail.com","sentAt":"2007-11-09T09:12:28Z","receivedAt":"2007-11-09T09:12:28Z","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 |   80 ++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 80 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..98d8eb3\n--- /dev/null\n+++ b/t/t2008-checkout-subdir.sh\n@@ -0,0 +1,80 @@\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+\tmkdir dir2 &&\n+\techo \"bonjour\" > dir2/file2 &&\n+\tgit add dir2/file2 &&\n+\ttest_tick &&\n+\tgit commit -m \"populate tree\"\n+\n+'\n+\n+test_expect_success 'remove and restore with relative path' '\n+\n+\t(\n+\t\tcd dir1 &&\n+\t\trm ../file0 &&\n+\t\tgit checkout HEAD -- ../file0 &&\n+\t\ttest \"base\" = \"$(cat ../file0)\" &&\n+\t\trm ../dir2/file2 &&\n+\t\tgit checkout HEAD -- ../dir2/file2 &&\n+\t\ttest \"bonjour\" = \"$(cat ../dir2/file2)\" &&\n+\t\trm ../file0 ./file1 &&\n+\t\tgit checkout HEAD -- .. &&\n+\t\ttest \"base\" = \"$(cat ../file0)\" &&\n+\t\ttest \"hello\" = \"$(cat file1)\"\n+\t)\n+\n+'\n+\n+test_expect_success 'checkout with empty prefix' '\n+\n+\trm file0 &&\n+\tgit checkout HEAD -- file0 &&\n+\ttest \"base\" = \"$(cat file0)\"\n+\n+'\n+\n+test_expect_success 'checkout with simple prefix' '\n+\n+\trm dir1/file1 &&\n+\tgit checkout HEAD -- dir1 &&\n+\ttest \"hello\" = \"$(cat dir1/file1)\" &&\n+\trm dir1/file1 &&\n+\tgit checkout HEAD -- dir1/file1 &&\n+\ttest \"hello\" = \"$(cat dir1/file1)\"\n+\n+'\n+\n+test_expect_success 'checkout with complex relative path' '\n+\n+\trm file1 &&\n+\tgit checkout HEAD -- ../dir1/../dir1/file1 && test -f ./file1\n+\n+'\n+\n+test_expect_failure 'relative path outside tree should fail' \\\n+\t'git checkout HEAD -- ../../Makefile'\n+\n+test_expect_failure 'incorrect relative path to file should fail (1)' \\\n+\t'git checkout HEAD -- ../file0'\n+\n+test_expect_failure 'incorrect relative path should fail (2)' \\\n+\t'( cd dir1 && git checkout HEAD -- ./file0 )'\n+\n+test_expect_failure 'incorrect relative path should fail (3)' \\\n+\t'( cd dir1 && git checkout HEAD -- ../../file0 )'\n+\n+test_done\n-- \n1.5.3.1\n"},{"id":"59122","messageId":"200711092048.34868.robin.rosenberg.lists@dewire.com","threadId":"10743","inReplyTo":"7vtznwxl59.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-checkout: Test for relative path use.","fromName":"Robin Rosenberg","fromEmail":"robin.rosenberg.lists@dewire.com","sentAt":"2007-11-09T19:48:34Z","receivedAt":"2007-11-09T19:48:34Z","isPatch":true,"sender":{"key":"robin.rosenberg@dewire.com","avatar":"https://avatars.githubusercontent.com/u/46357?v=4"},"body":"fredag 09 november 2007 skrev Junio C Hamano:\n> David Symonds <dsymonds@gmail.com> writes:\n> \n> > Signed-off-by: David Symonds <dsymonds@gmail.com>\n> > ---\n> > \tTest 5 in this series fails because of a bug in git-ls-files, where\n> > \t\tgit-ls-files t/../\n> > \t(with or without --full-name) returns no files.\n> \n> Heh, you shouldn't do that ;-)\n> \n> Seriously, that's a long standing limitation in the code, not to\n> deal with arbitrary combination of ups and downs, but I do not\n> think there is any fundamental reason to disallow something\n> like:\n> \n> \tcd Documentation && git ls-files --full-name ../t\n> \n> Patches welcome.\n\nI'm for allowing it, but then it should really be all over, not just some arbitrary\ncommand. Everywhere or not at all.\n\n-- robin\n"}]}