{"thread":{"id":"13744","subject":"[PATCH] t/test-lib.sh: resolve symlinks in working directory, for pathname comparisons","startedAt":"2008-05-31T21:11:21Z","lastAt":"2008-05-31T21:11:21Z","messageCount":1,"participants":["Lea Wiemann"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"78245","messageId":"1212268281-16797-1-git-send-email-LeWiemann@gmail.com","threadId":"13744","inReplyTo":null,"subject":"[PATCH] t/test-lib.sh: resolve symlinks in working directory, for pathname comparisons","fromName":"Lea Wiemann","fromEmail":"lewiemann@gmail.com","sentAt":"2008-05-31T21:11:21Z","receivedAt":"2008-05-31T21:11:21Z","isPatch":true,"sender":{"key":"lewiemann@gmail.com","avatar":null},"body":"Without this, some tests will fail because they compare command output\nof subprocesses (such as git) with $PWD -- but subprocesses have the\nphysical path as their working directory, whereas $PWD contains the\nsymlinked path.  This fixes it.\n\nSigned-off-by: Lea Wiemann <LeWiemann@gmail.com>\n---\nHere is how to reproduce it:\n\n$ ln -s /path/to/git git-symlink\n$ cd git-symlink/t\n$ ./t0001-init.sh \n*   ok 1: plain\n*   ok 2: plain with GIT_WORK_TREE\n*   ok 3: plain bare\n*   ok 4: plain bare with GIT_WORK_TREE\n*   ok 5: GIT_DIR bare\n*   ok 6: GIT_DIR non-bare\n* FAIL 7: GIT_DIR & GIT_WORK_TREE (1)\n\t\n\t\n\t\t(\n\t\t\tunset GIT_CONFIG\n\t\t\tmkdir git-dir-wt-1.git &&\n\t\t\tGIT_WORK_TREE=$(pwd) GIT_DIR=git-dir-wt-1.git git init\n\t\t) &&\n\t\tcheck_config git-dir-wt-1.git false \"$(pwd)\"\n\t\n*   ok 8: GIT_DIR & GIT_WORK_TREE (2)\n*   ok 9: reinit\n* failed 1 among 9 test(s)\n\nWith this patch applied, all tests work fine in symlinked working\ndirectories.\n\n t/test-lib.sh |    4 +++-\n 1 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 3bf570b..7a8bd27 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -419,7 +419,9 @@ rm -fr \"$test\" || {\n }\n \n test_create_repo \"$test\"\n-cd \"$test\" || exit 1\n+# Use -P to resolve symlinks in our working directory so that the cwd\n+# in subprocesses like git equals our $PWD (for pathname comparisons).\n+cd -P \"$test\" || exit 1\n \n this_test=$(expr \"./$0\" : '.*/\\(t[0-9]*\\)-[^/]*$')\n for skp in $GIT_SKIP_TESTS\n-- \n1.5.5.GIT\n"}]}