Show which branch you are on in git-status output.
[git/dkf.git] / t / t0100-environment-names.sh
blob9f851bc114a6f2b4ee351732c76b763e55338fb8
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='general environment name warning test.
8 This test makes sure that use of deprecated environment variables
9 trigger the warnings from gitenv().'
11 env_vars='GIT_AUTHOR_DATE:AUTHOR_DATE
12 GIT_AUTHOR_EMAIL:AUTHOR_EMAIL
13 GIT_AUTHOR_NAME:AUTHOR_NAME
14 GIT_COMMITTER_EMAIL:COMMIT_AUTHOR_EMAIL
15 GIT_COMMITTER_NAME:COMMIT_AUTHOR_NAME
16 GIT_ALTERNATE_OBJECT_DIRECTORIES:SHA1_FILE_DIRECTORIES
17 GIT_OBJECT_DIRECTORY:SHA1_FILE_DIRECTORY
20 . ./test-lib.sh
22 export_them () {
23 for ev in $env_vars
25 new=$(expr "$ev" : '\(.*\):')
26 old=$(expr "$ev" : '.*:\(.*\)')
27 # Build and eval the following:
28 # case "${VAR+set}" in set) export VAR;; esac
29 evstr='case "${'$new'+set}" in set) export '$new';; esac'
30 eval "$evstr"
31 evstr='case "${'$old'+set}" in set) export '$old';; esac'
32 eval "$evstr"
33 done
36 date >path0
37 git-update-cache --add path0
38 tree=$(git-write-tree)
40 AUTHOR_DATE='Wed May 11 23:55:18 2005'
41 AUTHOR_EMAIL='author@example.xz'
42 AUTHOR_NAME='A U Thor'
43 COMMIT_AUTHOR_EMAIL='author@example.xz'
44 COMMIT_AUTHOR_NAME='A U Thor'
45 SHA1_FILE_DIRECTORY=.git/objects
47 export_them
49 echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg
50 cat >expected-err <<\EOF
51 warning: Attempting to use SHA1_FILE_DIRECTORY
52 warning: GIT environment variables have been renamed.
53 warning: Please adjust your scripts and environment.
54 warning: old AUTHOR_DATE => new GIT_AUTHOR_DATE
55 warning: old AUTHOR_EMAIL => new GIT_AUTHOR_EMAIL
56 warning: old AUTHOR_NAME => new GIT_AUTHOR_NAME
57 warning: old COMMIT_AUTHOR_EMAIL => new GIT_COMMITTER_EMAIL
58 warning: old COMMIT_AUTHOR_NAME => new GIT_COMMITTER_NAME
59 warning: old SHA1_FILE_DIRECTORY => new GIT_OBJECT_DIRECTORY
60 EOF
61 sed -ne '/^warning: /p' <errmsg >generated-err
63 test_expect_success \
64 'using old names should issue warnings.' \
65 'cmp generated-err expected-err'
67 for ev in $env_vars
69 new=$(expr "$ev" : '\(.*\):')
70 old=$(expr "$ev" : '.*:\(.*\)')
71 # Build and eval the following:
72 # NEWENV=$OLDENV
73 evstr="$new=\$$old"
74 eval "$evstr"
75 done
76 export_them
77 echo 'foo' | git-commit-tree $tree >/dev/null 2>errmsg
78 sed -ne '/^warning: /p' <errmsg >generated-err
80 test_expect_success \
81 'using old names but having new names should not issue warnings.' \
82 'cmp generated-err /dev/null'
84 test_done