{"thread":{"id":"616","subject":"[PATCH] Test GIT environment use.","startedAt":"2005-05-14T08:45:42Z","lastAt":"2005-05-14T08:45:42Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"3292","messageId":"7vekca42mh.fsf@assigned-by-dhcp.cox.net","threadId":"616","inReplyTo":null,"subject":"[PATCH] Test GIT environment use.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-14T08:45:42Z","receivedAt":"2005-05-14T08:45:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This test makes sure that use of deprecated environment variables still\nworks, using both new and old names makes new one take\nprecedence, and GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES mechanisms\nwork.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\nt/t0110-environment-names.sh |  134 +++++++++++++++++++++++++++++++++++++++++++\n1 files changed, 134 insertions(+)\nt/t0110-environment-names.sh (. --> 100755)\n\n--- a/t/t0110-environment-names.sh\n+++ b/t/t0110-environment-names.sh\n@@ -0,0 +1,134 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2005 Junio C Hamano\n+#\n+\n+test_description='Using new and old environment names.\n+\n+This test makes sure that use of deprecated environment variables\n+still works, using both new and old names makes new one take precedence,\n+and GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES mechanism works.'\n+\n+env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE\n+GIT_AUTHOR_EMAIL:AUTHOR_EMAIL\n+GIT_AUTHOR_NAME:AUTHOR_NAME\n+GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL\n+GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME\n+GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES\n+GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY\n+'\n+\n+. ./test-lib.sh\n+\n+export_them () {\n+\tfor ev in $env_vars\n+\tdo\n+\t\tnew=$(expr \"$ev\" : '\\(.*\\):')\n+\t\told=$(expr \"$ev\" : '.*:\\(.*\\)')\n+\t\t# Build and eval the following:\n+\t\t# case \"${VAR+set}\" in set) export VAR;; esac\n+\t\tevstr='case \"${'$new'+set}\" in set) export '$new';; esac'\n+\t\teval \"$evstr\"\n+\t\tevstr='case \"${'$old'+set}\" in set) export '$old';; esac'\n+\t\teval \"$evstr\"\n+\tdone\n+}\n+\n+SHA1_FILE_DIRECTORY=.svn/objects ;# whoa\n+export SHA1_FILE_DIRECTORY\n+\n+rm -fr .git\n+mkdir .svn\n+test_expect_success \\\n+    'using SHA1_FILE_DIRECTORY in git-init-db' \\\n+    'git-init-db && test -d .svn/objects/cb'\n+\n+unset SHA1_FILE_DIRECTORY\n+GIT_DIR=.svn\n+export GIT_DIR\n+rm -fr .git .svn\n+mkdir .svn\n+test_expect_success \\\n+    'using GIT_DIR in git-init-db' \\\n+    'git-init-db && test -d .svn/objects/cb'\n+\n+date >path0\n+test_expect_success \\\n+    'using GIT_DIR in git-update-cache' \\\n+    'git-update-cache --add path0 && test -f .svn/index'\n+\n+sedScript='s|\\(..\\)|.svn/objects/\\1/|'\n+\n+test_expect_success \\\n+    'using GIT_DIR in git-write-tree' \\\n+    'tree=$(git-write-tree) &&\n+     test -f $(echo \"$tree\" | sed -e \"$sedScript\")'\n+\n+AUTHOR_DATE='Sat May 14 00:00:00 2005 -0000'\n+AUTHOR_EMAIL='author@example.xz'\n+AUTHOR_NAME='A U Thor'\n+COMMIT_AUTHOR_EMAIL='author@example.xz'\n+COMMIT_AUTHOR_NAME='A U Thor'\n+export_them\n+\n+test_expect_success \\\n+    'using GIT_DIR and old variable names in git-commit-tree' \\\n+    'commit=$(echo foo | git-commit-tree $tree) &&\n+     test -f $(echo \"$commit\" | sed -e \"$sedScript\")'\n+\n+test_expect_success \\\n+    'using GIT_DIR in git-cat-file' \\\n+    'git-cat-file commit $commit >current'\n+\n+cat >expected <<\\EOF\n+author A U Thor <author@example.xz>\n+committer A U Thor <author@example.xz>\n+EOF\n+test_expect_success \\\n+    'verify old AUTHOR variables were used correctly in commit' \\\n+    'sed -ne '\\''/^\\(author\\|committer\\)/s|>.*|>|p'\\'' current |\n+     cmp - expected'\n+\n+unset GIT_DIR\n+test_expect_success \\\n+    'git-init-db without GIT_DIR' \\\n+    'git-init-db && test -d .git && test -d .git/objects/ef'\n+\n+SHA1_FILE_DIRECTORIES=.svn/objects\n+export SHA1_FILE_DIRECTORIES\n+\n+test_expect_success \\\n+    'using SHA1_FILE_DIRECTORIES with git-ls-tree' \\\n+    'git-ls-tree $commit && git-ls-tree $tree'\n+\n+GIT_AUTHOR_DATE='Sat May 14 12:00:00 2005 -0000'\n+GIT_AUTHOR_EMAIL='rohtua@example.xz'\n+GIT_AUTHOR_NAME='R O Htua'\n+GIT_COMMITTER_EMAIL='rohtua@example.xz'\n+GIT_COMMITTER_NAME='R O Htua'\n+export_them\n+\n+sedScript='s|\\(..\\)|.git/objects/\\1/|'\n+test_expect_success \\\n+    'using new author variables with git-commit-tree' \\\n+    'commit2=$(echo foo | git-commit-tree $tree) &&\n+     test -f $(echo \"$commit2\" | sed -e \"$sedScript\")'\n+\n+GIT_ALTERNATE_OBJECT_DIRECTORIES=.git/objects\n+GIT_DIR=nowhere\n+export GIT_DIR GIT_ALTERNATE_OBJECT_DIRECTORIES\n+\n+test_expect_success \\\n+    'git-cat-file with GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES' \\\n+    'git-cat-file commit $commit2 >current'\n+\n+cat >expected <<\\EOF\n+author R O Htua <rohtua@example.xz>\n+committer R O Htua <rohtua@example.xz>\n+EOF\n+test_expect_success \\\n+    'verify new AUTHOR variables were used correctly in commit.' \\\n+    'sed -ne '\\''/^\\(author\\|committer\\)/s|>.*|>|p'\\'' current |\n+     cmp - expected'\n+\n+test_done\n------------------------------------------------\n\n"}]}