#!/bin/sh global test_description := ''git blame'' source ./test-lib.sh global PROG := ''git blame -c'' source "$TEST_DIRECTORY"/annotate-tests.sh test_expect_success 'blame untracked file in empty repo' ' >untracked && test_must_fail git blame untracked ' global PROG := ''git blame -c -e'' test_expect_success 'blame --show-email' ' check_count \ "" 1 \ "" 1 \ "" 1 \ "" 1 \ "" 1 \ "" 1 \ "" 1 \ "" 1 ' test_expect_success 'setup showEmail tests' ' echo "bin: test number 1" >one && git add one && GIT_AUTHOR_NAME=name1 \ GIT_AUTHOR_EMAIL=email1@test.git \ git commit -m First --date="2010-01-01 01:00:00" && cat >expected_n <<-\EOF && (name1 2010-01-01 01:00:00 +0000 1) bin: test number 1 EOF cat >expected_e <<-\EOF ( 2010-01-01 01:00:00 +0000 1) bin: test number 1 EOF ' proc find_blame { sed -e 's/^[^(]*//' } test_expect_success 'blame with no options and no config' ' git blame one >blame && find_blame result && test_cmp expected_n result ' test_expect_success 'blame with showemail options' ' git blame --show-email one >blame1 && find_blame result && test_cmp expected_e result && git blame -e one >blame2 && find_blame result && test_cmp expected_e result && git blame --no-show-email one >blame3 && find_blame result && test_cmp expected_n result ' test_expect_success 'blame with showEmail config false' ' git config blame.showEmail false && git blame one >blame1 && find_blame result && test_cmp expected_n result && git blame --show-email one >blame2 && find_blame result && test_cmp expected_e result && git blame -e one >blame3 && find_blame result && test_cmp expected_e result && git blame --no-show-email one >blame4 && find_blame result && test_cmp expected_n result ' test_expect_success 'blame with showEmail config true' ' git config blame.showEmail true && git blame one >blame1 && find_blame result && test_cmp expected_e result && git blame --no-show-email one >blame2 && find_blame result && test_cmp expected_n result ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git blame">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:PROG) op:Equal rhs:{(SQ <"git blame -c">)} spids:[14])] spids: [14] ) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/annotate-tests.sh)}) (C {(test_expect_success)} {(SQ <"blame untracked file in empty repo">)} {(SQ <"\n"> <"\t>untracked &&\n"> <"\ttest_must_fail git blame untracked\n">)} ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:PROG) op: Equal rhs: {(SQ <"git blame -c -e">)} spids: [40] ) ] spids: [40] ) (C {(test_expect_success)} {(SQ <"blame --show-email">)} { (SQ <"\n"> <"\tcheck_count \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1 \\\n"> <"\t\t\"\" 1\n"> ) } ) (C {(test_expect_success)} {(SQ <"setup showEmail tests">)} { (SQ <"\n"> <"\techo \"bin: test number 1\" >one &&\n"> <"\tgit add one &&\n"> <"\tGIT_AUTHOR_NAME=name1 \\\n"> <"\tGIT_AUTHOR_EMAIL=email1@test.git \\\n"> <"\tgit commit -m First --date=\"2010-01-01 01:00:00\" &&\n"> <"\tcat >expected_n <<-\\EOF &&\n"> <"\t(name1 2010-01-01 01:00:00 +0000 1) bin: test number 1\n"> <"\tEOF\n"> <"\tcat >expected_e <<-\\EOF\n"> <"\t( 2010-01-01 01:00:00 +0000 1) bin: test number 1\n"> <"\tEOF\n"> ) } ) (FuncDef name: find_blame body: (BraceGroup children:[(C {(sed)} {(-e)} {(SQ <"s/^[^(]*//">)})] spids:[92]) spids: [87 91] ) (C {(test_expect_success)} {(SQ <"blame with no options and no config">)} { (SQ <"\n"> <"\tgit blame one >blame &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_n result\n"> ) } ) (C {(test_expect_success)} {(SQ <"blame with showemail options">)} { (SQ <"\n"> <"\tgit blame --show-email one >blame1 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_e result &&\n"> <"\tgit blame -e one >blame2 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_e result &&\n"> <"\tgit blame --no-show-email one >blame3 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_n result\n"> ) } ) (C {(test_expect_success)} {(SQ <"blame with showEmail config false">)} { (SQ <"\n"> <"\tgit config blame.showEmail false &&\n"> <"\tgit blame one >blame1 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_n result &&\n"> <"\tgit blame --show-email one >blame2 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_e result &&\n"> <"\tgit blame -e one >blame3 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_e result &&\n"> <"\tgit blame --no-show-email one >blame4 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_n result\n"> ) } ) (C {(test_expect_success)} {(SQ <"blame with showEmail config true">)} { (SQ <"\n"> <"\tgit config blame.showEmail true &&\n"> <"\tgit blame one >blame1 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_e result &&\n"> <"\tgit blame --no-show-email one >blame2 &&\n"> <"\tfind_blame result &&\n"> <"\ttest_cmp expected_n result\n"> ) } ) (C {(test_done)}) ] )