The test of the basic diff functionality
[git/gitweb.git] / t / t0110-environment-names-old.sh
blob9389796f84414be6c786cf0ce667c1eebdda98e0
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Using new and old environment names.
8 This test makes sure that use of deprecated environment variables
9 still works, using both new and old names makes new one take precedence,
10 and GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES mechanism works.'
12 env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE
13 GIT_AUTHOR_EMAIL:AUTHOR_EMAIL
14 GIT_AUTHOR_NAME:AUTHOR_NAME
15 GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL
16 GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME
17 GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES
18 GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY
21 . ./test-lib.sh
23 export_them () {
24 for ev in $env_vars
26 new=$(expr "$ev" : '\(.*\):')
27 old=$(expr "$ev" : '.*:\(.*\)')
28 # Build and eval the following:
29 # case "${VAR+set}" in set) export VAR;; esac
30 evstr='case "${'$new'+set}" in set) export '$new';; esac'
31 eval "$evstr"
32 evstr='case "${'$old'+set}" in set) export '$old';; esac'
33 eval "$evstr"
34 done
37 SHA1_FILE_DIRECTORY=.svn/objects ;# whoa
38 export SHA1_FILE_DIRECTORY
40 rm -fr .git
41 mkdir .svn
42 test_expect_success \
43 'using SHA1_FILE_DIRECTORY in git-init-db' \
44 'git-init-db && test -d .svn/objects/cb'
46 unset SHA1_FILE_DIRECTORY
47 GIT_DIR=.svn
48 export GIT_DIR
49 rm -fr .git .svn
50 mkdir .svn
51 test_expect_success \
52 'using GIT_DIR in git-init-db' \
53 'git-init-db && test -d .svn/objects/cb'
55 date >path0
56 test_expect_success \
57 'using GIT_DIR in git-update-cache' \
58 'git-update-cache --add path0 && test -f .svn/index'
60 sedScript='s|\(..\)|.svn/objects/\1/|'
62 test_expect_success \
63 'using GIT_DIR in git-write-tree' \
64 'tree=$(git-write-tree) &&
65 test -f $(echo "$tree" | sed -e "$sedScript")'
67 AUTHOR_DATE='Sat May 14 00:00:00 2005 -0000'
68 AUTHOR_EMAIL='author@example.xz'
69 AUTHOR_NAME='A U Thor'
70 COMMIT_AUTHOR_EMAIL='author@example.xz'
71 COMMIT_AUTHOR_NAME='A U Thor'
72 export_them
74 test_expect_success \
75 'using GIT_DIR and old variable names in git-commit-tree' \
76 'commit=$(echo foo | git-commit-tree $tree) &&
77 test -f $(echo "$commit" | sed -e "$sedScript")'
79 test_expect_success \
80 'using GIT_DIR in git-cat-file' \
81 'git-cat-file commit $commit >current'
83 cat >expected <<\EOF
84 author A U Thor <author@example.xz>
85 committer A U Thor <author@example.xz>
86 EOF
87 test_expect_success \
88 'verify old AUTHOR variables were used correctly in commit' \
89 'sed -ne '\''/^\(author\|committer\)/s|>.*|>|p'\'' current |
90 cmp - expected'
92 unset GIT_DIR
93 test_expect_success \
94 'git-init-db without GIT_DIR' \
95 'git-init-db && test -d .git && test -d .git/objects/ef'
97 SHA1_FILE_DIRECTORIES=.svn/objects
98 export SHA1_FILE_DIRECTORIES
100 test_expect_success \
101 'using SHA1_FILE_DIRECTORIES with git-ls-tree' \
102 'git-ls-tree $commit && git-ls-tree $tree'
104 GIT_AUTHOR_DATE='Sat May 14 12:00:00 2005 -0000'
105 GIT_AUTHOR_EMAIL='rohtua@example.xz'
106 GIT_AUTHOR_NAME='R O Htua'
107 GIT_COMMITTER_EMAIL='rohtua@example.xz'
108 GIT_COMMITTER_NAME='R O Htua'
109 export_them
111 sedScript='s|\(..\)|.git/objects/\1/|'
112 test_expect_success \
113 'using new author variables with git-commit-tree' \
114 'commit2=$(echo foo | git-commit-tree $tree) &&
115 test -f $(echo "$commit2" | sed -e "$sedScript")'
117 GIT_ALTERNATE_OBJECT_DIRECTORIES=.git/objects
118 GIT_DIR=nowhere
119 export GIT_DIR GIT_ALTERNATE_OBJECT_DIRECTORIES
121 test_expect_success \
122 'git-cat-file with GIT_DIR and GIT_ALTERNATE_OBJECT_DIRECTORIES' \
123 'git-cat-file commit $commit2 >current'
125 cat >expected <<\EOF
126 author R O Htua <rohtua@example.xz>
127 committer R O Htua <rohtua@example.xz>
129 test_expect_success \
130 'verify new AUTHOR variables were used correctly in commit.' \
131 'sed -ne '\''/^\(author\|committer\)/s|>.*|>|p'\'' current |
132 cmp - expected'
134 test_done