1#!/bin/sh 2 3test_description='basic sanity checks for git var' 4 5TEST_PASSES_SANITIZE_LEAK=true 6. ./test-lib.sh 7 8test_expect_success 'get GIT_AUTHOR_IDENT' ' 9 test_tick && 10 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect && 11 git var GIT_AUTHOR_IDENT >actual && 12 test_cmp expect actual 13' 14 15test_expect_success 'get GIT_COMMITTER_IDENT' ' 16 test_tick && 17 echo "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" >expect && 18 git var GIT_COMMITTER_IDENT >actual && 19 test_cmp expect actual 20' 21 22test_expect_success !FAIL_PREREQS,!AUTOIDENT 'requested identities are strict' ' 23 ( 24 sane_unset GIT_COMMITTER_NAME && 25 sane_unset GIT_COMMITTER_EMAIL && 26 test_must_fail git var GIT_COMMITTER_IDENT 27 ) 28' 29 30# For git var -l, we check only a representative variable; 31# testing the whole output would make our test too brittle with 32# respect to unrelated changes in the test suite's environment. 33test_expect_success 'git var -l lists variables' ' 34 git var -l >actual && 35 echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect && 36 sed -n s/GIT_AUTHOR_IDENT=//p <actual >actual.author && 37 test_cmp expect actual.author 38' 39 40test_expect_success 'git var -l lists config' ' 41 git var -l >actual && 42 echo false >expect && 43 sed -n s/core\\.bare=//p <actual >actual.bare && 44 test_cmp expect actual.bare 45' 46 47test_expect_success 'listing and asking for variables are exclusive' ' 48 test_must_fail git var -l GIT_COMMITTER_IDENT 49' 50 51test_done 52