{"thread":{"id":"10482","subject":"[PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE","startedAt":"2007-10-27T08:19:54Z","lastAt":"2007-10-28T00:18:59Z","messageCount":4,"participants":["Nguyễn Thái Ngọc Duy","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"57334","messageId":"20071027081954.GA23406@laptop","threadId":"10482","inReplyTo":null,"subject":"[PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-10-27T08:19:54Z","receivedAt":"2007-10-27T08:19:54Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This one is ugly (and not intended to submit to git.git), but\nit shows how to reproduce the issues.  You can run it with\narg \"--normal\" to see it works just fine without GIT_WORK_TREE.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n t/t1502-subworktree.sh |  109 ++++++++++++++++++++++++++++++++++++++++++++++++\n 1 files changed, 109 insertions(+), 0 deletions(-)\n create mode 100755 t/t1502-subworktree.sh\n\ndiff --git a/t/t1502-subworktree.sh b/t/t1502-subworktree.sh\nnew file mode 100755\nindex 0000000..6b8f02f\n--- /dev/null\n+++ b/t/t1502-subworktree.sh\n@@ -0,0 +1,109 @@\n+#!/bin/sh\n+\n+test_description='test commands on separate work tree'\n+. ./test-lib.sh\n+\n+mkdir -p work/sub/dir || exit 1\n+mv .git work\n+if test \"$1\" = --normal; then\n+\tsay \"Normal case\"\n+else\n+\tsay \"Worktree case\"\n+fi\n+test \"$1\" = --normal || mv work/.git repo.git || exit 1\n+\n+test \"$1\" = --normal || export GIT_DIR=$(pwd)/repo.git\n+export GIT_CONFIG=\"$(pwd)\"/$GIT_DIR/config\n+test \"$1\" = --normal || export GIT_WORK_TREE=$(pwd)/work\n+\n+cd work/sub || exit 1\n+\n+cat >expected <<EOF\n+100644 9daeafb9864cf43055ae93beb0afd6c7d144bfa4 0\tdir/untracked\n+EOF\n+\n+test_expect_success 'git-ls-files' 'test expected = \"$(git ls-files --others)\"'\n+\n+test_expect_success 'git-add' '\n+\t ( : > dir/untracked &&\n+\t git add dir/untracked &&\n+\t test dir/untracked = \"$(git ls-files)\")\n+'\n+test_expect_success 'git-update-index' '\n+\t( echo test > dir/untracked &&\n+\tgit update-index dir/untracked &&\n+\tgit ls-files --stage > check &&\n+\tcmp expected check)\n+'\n+\n+test_expect_success 'git-commit' 'git commit -m one'\n+\n+cat >expected <<EOF\n+100644 blob 9daeafb9864cf43055ae93beb0afd6c7d144bfa4\tdir/untracked\n+EOF\n+\n+test_expect_success 'git-ls-tree' '\n+\t(git ls-tree -r HEAD > check &&\n+\tcmp expected check)\n+'\n+test_expect_success 'git-rm' '\n+\t (git rm --cached dir/untracked &&\n+\t test -z \"$(git ls-files)\")\n+'\n+test_expect_success 'git-reset' '\n+\t(git reset HEAD -- dir/untracked &&\n+\ttest dir/untracked = \"$(git ls-files)\")\n+'\n+test_expect_success 'git-annotate' 'git annotate dir/untracked'\n+\n+test_expect_success 'git-blame' 'git blame dir/untracked'\n+\n+cat > patch <<EOF\n+From b774efc5a2199bfc1c9c18db70363c69a5a10c86 Mon Sep 17 00:00:00 2001\n+From: A U Thor <author@example.com>\n+Date: Tue, 23 Oct 2007 21:17:24 +0700\n+Subject: bah\n+\n+---\n+ sub/dir/untracked |    1 +\n+ 1 files changed, 1 insertions(+), 0 deletions(-)\n+\n+diff --git a/sub/dir/untracked b/sub/dir/untracked\n+index 9daeafb..c73d3ff 100644\n+--- a/sub/dir/untracked\n++++ b/sub/dir/untracked\n+@@ -1 +1,2 @@\n+ test\n++test again\n+-- \n+1.5.3.rc4.3.gab089\n+\n+EOF\n+\n+cat > expected <<EOF\n+100644 c73d3ffa5fa32888de8219e49fd45d37dc209677 0\tdir/untracked\n+EOF\n+\n+test_expect_success 'git-apply to index' '\n+\t(git apply --index patch &&\n+\tgit ls-files --stage > check &&\n+\tcmp expected check)'\n+\n+test_expect_failure 'git-apply to worktree' 'test -f sub/dir/untracked'\n+\n+test_expect_success 'git-reset --hard' '( git reset --hard HEAD && test -z \"$(git ls-files -m)\")'\n+\n+test_expect_failure 'git-am must not be run from subdir' 'git-am -k patch'\n+\n+test_expect_success 'git-reset --hard' 'git reset --hard HEAD'\n+\n+test_expect_success 'git-am' '(cd .. && git-am -k sub/patch)'\n+\n+test_expect_success 'git-format-patch' '\n+\t(git format-patch -k HEAD^ &&\n+\tsed \"1d;/^-- /,\\$d\" patch > expected &&\n+\tsed \"1d;/^-- /,\\$d\" 0001-bah.patch > check &&\n+\tcmp expected check)\n+'\n+\n+test_done\n-- \n1.5.3.rc4.3.gab089\n"},{"id":"57352","messageId":"Pine.LNX.4.64.0710271343270.4362@racer.site","threadId":"10482","inReplyTo":"20071027081954.GA23406@laptop","subject":"Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-27T12:45:23Z","receivedAt":"2007-10-27T12:45:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:\n\n> +mkdir -p work/sub/dir || exit 1\n> +mv .git work\n> +if test \"$1\" = --normal; then\n> +\tsay \"Normal case\"\n> +else\n> +\tsay \"Worktree case\"\n> +fi\n> +test \"$1\" = --normal || mv work/.git repo.git || exit 1\n> +\n> +test \"$1\" = --normal || export GIT_DIR=$(pwd)/repo.git\n> +export GIT_CONFIG=\"$(pwd)\"/$GIT_DIR/config\n> +test \"$1\" = --normal || export GIT_WORK_TREE=$(pwd)/work\n> +\n> +cd work/sub || exit 1\n\nWhy don't you put this block into a test_expect_success?  And then just \nmake a\n\n\tfor mode in normal worktree\n\tdo\n\n\t...\n\n\tdone\n\nHmm?  I would like to see this test case in the official git.git.\n\nCiao,\nDscho\n"},{"id":"57356","messageId":"Pine.LNX.4.64.0710271427020.4362@racer.site","threadId":"10482","inReplyTo":"fcaeb9bf0710270557n48a01ba2w3a89f65680b946d@mail.gmail.com","subject":"Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-27T13:27:53Z","receivedAt":"2007-10-27T13:27:53Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 27 Oct 2007, Nguyen Thai Ngoc Duy wrote:\n\n> On 10/27/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > Hi,\n> >\n> > On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:\n> >\n> > > +mkdir -p work/sub/dir || exit 1\n> > > +mv .git work\n> > > +if test \"$1\" = --normal; then\n> > > +     say \"Normal case\"\n> > > +else\n> > > +     say \"Worktree case\"\n> > > +fi\n> > > +test \"$1\" = --normal || mv work/.git repo.git || exit 1\n> > > +\n> > > +test \"$1\" = --normal || export GIT_DIR=$(pwd)/repo.git\n> > > +export GIT_CONFIG=\"$(pwd)\"/$GIT_DIR/config\n> > > +test \"$1\" = --normal || export GIT_WORK_TREE=$(pwd)/work\n> > > +\n> > > +cd work/sub || exit 1\n> >\n> > Why don't you put this block into a test_expect_success?  And then just\n> > make a\n> >\n> >         for mode in normal worktree\n> >         do\n> >\n> >         ...\n> >\n> >         done\n> >\n> > Hmm?  I would like to see this test case in the official git.git.\n> \n> Because after normal iteration, the test repository is no longer in\n> clean state that the second iteration needs. Maybe I should just\n> create another repo then set parameters properly in test_expect_*\n\nYes, you can do that:\n\n\ttest_create_repo other-repo\n\nAnother option would be that you clean up at the end of the loop.\n\nCiao,\nDscho\n"},{"id":"57381","messageId":"7vodek147g.fsf@gitster.siamese.dyndns.org","threadId":"10482","inReplyTo":"Pine.LNX.4.64.0710271343270.4362@racer.site","subject":"Re: [PATCH] Add test case for running from a subdirectory with GIT_WORK_TREE","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-10-28T00:18:59Z","receivedAt":"2007-10-28T00:18:59Z","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> On Sat, 27 Oct 2007, Nguyễn Thái Ngọc Duy wrote:\n>\n>> +mkdir -p work/sub/dir || exit 1\n>> +mv .git work\n>> +if test \"$1\" = --normal; then\n>> +\tsay \"Normal case\"\n>> +else\n>> +\tsay \"Worktree case\"\n>> +fi\n>> +test \"$1\" = --normal || mv work/.git repo.git || exit 1\n>> +\n>> +test \"$1\" = --normal || export GIT_DIR=$(pwd)/repo.git\n>> +export GIT_CONFIG=\"$(pwd)\"/$GIT_DIR/config\n>> +test \"$1\" = --normal || export GIT_WORK_TREE=$(pwd)/work\n>> +\n>> +cd work/sub || exit 1\n> ...\n> Hmm?  I would like to see this test case in the official git.git.\n\nMe too ;-)  It would help people fix the issues.\n"}]}