(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'Test git update-ref and basic ref logging'>)} spids: [13] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:Z) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$_z40')} spids: [23] ) ] ) (C {<test_expect_success>} {<setup>} { (SQ <'\n'> <'\n'> <'\tfor name in A B C D E F\n'> <'\tdo\n'> <'\t\ttest_tick &&\n'> <'\t\tT=$(git write-tree) &&\n'> <'\t\tsha1=$(echo $name | git commit-tree $T) &&\n'> <'\t\teval $name=$sha1\n'> <'\tdone\n'> <'\n'> ) } ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:m) op: assign_op.Equal rhs: {<'refs/heads/master'>} spids: [45] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:n_dir) op: assign_op.Equal rhs: {<'refs/heads/gu'>} spids: [48] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:n) op: assign_op.Equal rhs: {($ Id.VSub_DollarName '$n_dir') <'/fixes'>} spids: [51] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:outside) op: assign_op.Equal rhs: {<'refs/foo'>} spids: [55] ) ] ) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m'))} { (DQ <'git update-ref '> ($ Id.VSub_DollarName '$m') <' '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$A') ) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m'))} { (DQ <'git update-ref '> ($ Id.VSub_DollarName '$m') <' '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$B') ) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'fail to delete '> ($ Id.VSub_DollarName '$m') <' with stale ref'>)} {(SQ <'\n'> <'\ttest_must_fail git update-ref -d $m $A &&\n'> <'\ttest $B = "$(cat .git/$m)"\n'>)} ) (C {<test_expect_success>} {(DQ <'delete '> ($ Id.VSub_DollarName '$m'))} {(SQ <'\n'> <'\tgit update-ref -d $m $B &&\n'> <'\t! test -f .git/$m\n'>)} ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')}) (C {<test_expect_success>} {(DQ <'delete '> ($ Id.VSub_DollarName '$m') <' without oldvalue verification'>)} { (DQ <'\n'> <'\tgit update-ref '> ($ Id.VSub_DollarName '$m') <' '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\ttest '> ($ Id.VSub_DollarName '$A') <' = '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\$'>) <'(cat .git/'> ($ Id.VSub_DollarName '$m') <') &&\n'> <'\tgit update-ref -d '> ($ Id.VSub_DollarName '$m') <' &&\n'> <'\t! test -f .git/'> ($ Id.VSub_DollarName '$m') <'\n'> ) } ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')}) (C {<test_expect_success>} {(DQ <'fail to create '> ($ Id.VSub_DollarName '$n'))} { (DQ <'touch .git/'> ($ Id.VSub_DollarName '$n_dir') <' &&\n'> <'\t test_must_fail git update-ref '> ($ Id.VSub_DollarName '$n') <' '> ($ Id.VSub_DollarName '$A') <' >out 2>err'> ) } ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$n_dir')} {<out>} {<err>}) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m') <' (by HEAD)'>)} { (DQ <'git update-ref HEAD '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$A') ) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m') <' (by HEAD)'>)} { (DQ <'git update-ref HEAD '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$B') ) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'fail to delete '> ($ Id.VSub_DollarName '$m') <' (by HEAD) with stale ref'>)} {(SQ <'\n'> <'\ttest_must_fail git update-ref -d HEAD $A &&\n'> <'\ttest $B = $(cat .git/$m)\n'>)} ) (C {<test_expect_success>} {(DQ <'delete '> ($ Id.VSub_DollarName '$m') <' (by HEAD)'>)} {(SQ <'\n'> <'\tgit update-ref -d HEAD $B &&\n'> <'\t! test -f .git/$m\n'>)} ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')}) (C {<test_expect_success>} {(SQ <'update-ref does not create reflogs by default'>)} { (SQ <'\n'> <'\ttest_when_finished "git update-ref -d $outside" &&\n'> <'\tgit update-ref $outside $A &&\n'> <'\tgit rev-parse $A >expect &&\n'> <'\tgit rev-parse $outside >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git reflog exists $outside\n'> ) } ) (C {<test_expect_success>} {(SQ <'update-ref creates reflogs with --create-reflog'>)} { (SQ <'\n'> <'\ttest_when_finished "git update-ref -d $outside" &&\n'> <'\tgit update-ref --create-reflog $outside $A &&\n'> <'\tgit rev-parse $A >expect &&\n'> <'\tgit rev-parse $outside >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit reflog exists $outside\n'> ) } ) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m') <' (by HEAD)'>)} { (DQ <'git update-ref HEAD '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$A') ) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'pack refs'>)} {(DQ <'git pack-refs --all'>)}) (C {<test_expect_success>} {(DQ <'move '> ($ Id.VSub_DollarName '$m') <' (by HEAD)'>)} { (DQ <'git update-ref HEAD '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$B') ) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} { (DQ <'delete '> ($ Id.VSub_DollarName '$m') <' (by HEAD) should remove both packed and loose '> ($ Id.VSub_DollarName '$m') ) } { (SQ <'\n'> <'\tgit update-ref -d HEAD $B &&\n'> <'\t! grep "$m" .git/packed-refs &&\n'> <'\t! test -f .git/$m\n'> ) } ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')}) (C {<cp>} {<-f>} {<'.git/HEAD'>} {<'.git/HEAD.orig'>}) (C {<test_expect_success>} {(DQ <'delete symref without dereference'>)} {(SQ <'\n'> <'\tgit update-ref --no-deref -d HEAD &&\n'> <'\t! test -f .git/HEAD\n'>)} ) (C {<cp>} {<-f>} {<'.git/HEAD.orig'>} {<'.git/HEAD'>}) (C {<test_expect_success>} {(DQ <'delete symref without dereference when the referred ref is packed'>)} { (SQ <'\n'> <'\techo foo >foo.c &&\n'> <'\tgit add foo.c &&\n'> <'\tgit commit -m foo &&\n'> <'\tgit pack-refs --all &&\n'> <'\tgit update-ref --no-deref -d HEAD &&\n'> <'\t! test -f .git/HEAD\n'> ) } ) (C {<cp>} {<-f>} {<'.git/HEAD.orig'>} {<'.git/HEAD'>}) (C {<git>} {<update-ref>} {<-d>} {($ Id.VSub_DollarName '$m')}) (C {<test_expect_success>} {(SQ <'update-ref -d is not confused by self-reference'>)} { (SQ <'\n'> <'\tgit symbolic-ref refs/heads/self refs/heads/self &&\n'> <'\ttest_when_finished "rm -f .git/refs/heads/self" &&\n'> <'\ttest_path_is_file .git/refs/heads/self &&\n'> <'\ttest_must_fail git update-ref -d refs/heads/self &&\n'> <'\ttest_path_is_file .git/refs/heads/self\n'> ) } ) (C {<test_expect_success>} {(SQ <'update-ref --no-deref -d can delete self-reference'>)} { (SQ <'\n'> <'\tgit symbolic-ref refs/heads/self refs/heads/self &&\n'> <'\ttest_when_finished "rm -f .git/refs/heads/self" &&\n'> <'\ttest_path_is_file .git/refs/heads/self &&\n'> <'\tgit update-ref --no-deref -d refs/heads/self &&\n'> <'\ttest_path_is_missing .git/refs/heads/self\n'> ) } ) (C {<test_expect_success>} {(SQ <'update-ref --no-deref -d can delete reference to bad ref'>)} { (SQ <'\n'> <'\t>.git/refs/heads/bad &&\n'> <'\ttest_when_finished "rm -f .git/refs/heads/bad" &&\n'> <'\tgit symbolic-ref refs/heads/ref-to-bad refs/heads/bad &&\n'> <'\ttest_when_finished "rm -f .git/refs/heads/ref-to-bad" &&\n'> <'\ttest_path_is_file .git/refs/heads/ref-to-bad &&\n'> <'\tgit update-ref --no-deref -d refs/heads/ref-to-bad &&\n'> <'\ttest_path_is_missing .git/refs/heads/ref-to-bad\n'> ) } ) (C {<test_expect_success>} {(SQ <'(not) create HEAD with old sha1'>)} { (DQ <'\n'> <'\ttest_must_fail git update-ref HEAD '> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$B') <'\n'> ) } ) (C {<test_expect_success>} {(DQ <'(not) prior created .git/'> ($ Id.VSub_DollarName '$m'))} {(DQ <'\n'> <'\t! test -f .git/'> ($ Id.VSub_DollarName '$m') <'\n'>)} ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')}) (C {<test_expect_success>} {(DQ <'create HEAD'>)} {(DQ <'git update-ref HEAD '> ($ Id.VSub_DollarName '$A'))} ) (C {<test_expect_success>} {(SQ <'(not) change HEAD with wrong SHA1'>)} { (DQ <'\n'> <'\ttest_must_fail git update-ref HEAD '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$Z') <'\n'> ) } ) (C {<test_expect_success>} {(DQ <'(not) changed .git/'> ($ Id.VSub_DollarName '$m'))} {(DQ <'\n'> <'\t! test '> ($ Id.VSub_DollarName '$B')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')\n'>) } ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')}) (C {<rm>} {<-f>} {<'.git/logs/refs/heads/master'>}) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m') <' (logged by touch)'>)} { (SQ <'GIT_COMMITTER_DATE="2005-05-26 23:30" \\\n'> <'\t git update-ref --create-reflog HEAD '>) (DQ ($ Id.VSub_DollarName '$A')) (SQ <' -m "Initial Creation" &&\n'> <'\t test '>) (DQ ($ Id.VSub_DollarName '$A')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'update '> ($ Id.VSub_DollarName '$m') <' (logged by touch)'>)} {(SQ <'GIT_COMMITTER_DATE="2005-05-26 23:31" \\\n'> <'\t git update-ref HEAD'>) (DQ <' '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' '>) (SQ <'-m "Switch" &&\n'> <'\t test '>) (DQ ($ Id.VSub_DollarName '$B')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'set '> ($ Id.VSub_DollarName '$m') <' (logged by touch)'>)} {(SQ <'GIT_COMMITTER_DATE="2005-05-26 23:41" \\\n'> <'\t git update-ref HEAD'>) (DQ <' '> ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$A')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {<EOF>} here_end_span_id: 814 stdin_parts: [ ($ Id.VSub_DollarName '$Z') <' '> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150200 +0000\tInitial Creation\n'> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150260 +0000\tSwitch\n'> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150860 +0000\n'> ] ) ) ] do_fork: T ) (C {<test_expect_success>} {(DQ <'verifying '> ($ Id.VSub_DollarName '$m') <'\'s log'>)} {(DQ <'test_cmp expect .git/logs/'> ($ Id.VSub_DollarName '$m'))} ) (C {<rm>} {<-rf>} {<'.git/'> ($ Id.VSub_DollarName '$m')} {<'.git/logs'>} {<expect>}) (C {<test_expect_success>} {(SQ <'enable core.logAllRefUpdates'>)} { (SQ <'git config core.logAllRefUpdates true &&\n'> <'\t test true = $(git config --bool --get core.logAllRefUpdates)'> ) } ) (C {<test_expect_success>} {(DQ <'create '> ($ Id.VSub_DollarName '$m') <' (logged by config)'>)} {(SQ <'GIT_COMMITTER_DATE="2005-05-26 23:32" \\\n'> <'\t git update-ref HEAD'>) (DQ <' '> ($ Id.VSub_DollarName '$A') <' '>) (SQ <'-m "Initial Creation" &&\n'> <'\t test '>) (DQ ($ Id.VSub_DollarName '$A')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'update '> ($ Id.VSub_DollarName '$m') <' (logged by config)'>)} {(SQ <'GIT_COMMITTER_DATE="2005-05-26 23:33" \\\n'> <'\t git update-ref HEAD'>) (DQ <' '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' '>) (SQ <'-m "Switch" &&\n'> <'\t test '>) (DQ ($ Id.VSub_DollarName '$B')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (C {<test_expect_success>} {(DQ <'set '> ($ Id.VSub_DollarName '$m') <' (logged by config)'>)} {(SQ <'GIT_COMMITTER_DATE="2005-05-26 23:43" \\\n'> <'\t git update-ref HEAD '>) (DQ ($ Id.VSub_DollarName '$A') <' &&\n'> <'\t test '> ($ Id.VSub_DollarName '$A')) (SQ <' = $(cat .git/'>) (DQ ($ Id.VSub_DollarName '$m')) (SQ <')'>) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {<EOF>} here_end_span_id: 1004 stdin_parts: [ ($ Id.VSub_DollarName '$Z') <' '> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150320 +0000\tInitial Creation\n'> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150380 +0000\tSwitch\n'> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150980 +0000\n'> ] ) ) ] do_fork: T ) (C {<test_expect_success>} {(DQ <'verifying '> ($ Id.VSub_DollarName '$m') <'\'s log'>)} {(SQ <'test_cmp expect .git/logs/$m'>)} ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')} {<'.git/logs/'> ($ Id.VSub_DollarName '$m')} {<expect>} ) (C {<git>} {<update-ref>} {($ Id.VSub_DollarName '$m')} {($ Id.VSub_DollarName '$D')}) (command.Simple words: [{<cat>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<'.git/logs/'> ($ Id.VSub_DollarName '$m')} ) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {<EOF>} here_end_span_id: 1091 stdin_parts: [ <'0000000000000000000000000000000000000000 '> ($ Id.VSub_DollarName '$C') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150320 -0500\n'> ($ Id.VSub_DollarName '$C') <' '> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150350 -0500\n'> ($ Id.VSub_DollarName '$A') <' '> ($ Id.VSub_DollarName '$B') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150380 -0500\n'> ($ Id.VSub_DollarName '$F') <' '> ($ Id.VSub_DollarName '$Z') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150680 -0500\n'> ($ Id.VSub_DollarName '$Z') <' '> ($ Id.VSub_DollarName '$E') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150980 -0500\n'> ] ) ) ] do_fork: T ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ed) op: assign_op.Equal rhs: {(DQ <'Thu, 26 May 2005 18:32:00 -0500'>)} spids: [1093] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:gd) op: assign_op.Equal rhs: {(DQ <'Thu, 26 May 2005 18:33:00 -0500'>)} spids: [1098] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:ld) op: assign_op.Equal rhs: {(DQ <'Thu, 26 May 2005 18:43:00 -0500'>)} spids: [1103] ) ] ) (C {<test_expect_success>} {(SQ <'Query "master@{May 25 2005}" (before history)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{May 25 2005}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$C')) (SQ <' = $(cat o) &&\n'> <'\t test "warning: Log for '>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) <master> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <' only goes back to $ed." = "$(cat e)"'>) } ) (C {<test_expect_success>} {(DQ <'Query master@{2005-05-25} (before history)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify master@{2005-05-25} >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$C')) (SQ <' = $(cat o) &&\n'> <'\t echo test "warning: Log for '>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) <master> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <' only goes back to $ed." = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{May 26 2005 23:31:59}" (1 second before history)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{May 26 2005 23:31:59}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$C')) (SQ <' = $(cat o) &&\n'> <'\t test "warning: Log for '>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <master>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <' only goes back to $ed." = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{May 26 2005 23:32:00}" (exactly history start)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{May 26 2005 23:32:00}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$C')) (SQ <' = $(cat o) &&\n'> <'\t test "" = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{May 26 2005 23:32:30}" (first non-creation change)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{May 26 2005 23:32:30}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$A')) (SQ <' = $(cat o) &&\n'> <'\t test "" = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{2005-05-26 23:33:01}" (middle of history with gap)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{2005-05-26 23:33:01}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$B')) (SQ <' = $(cat o) &&\n'> <'\t test "warning: Log for ref '>) (DQ ($ Id.VSub_DollarName '$m') <' has gap after '> ($ Id.VSub_DollarName '$gd')) (SQ <'." = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{2005-05-26 23:38:00}" (middle of history)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{2005-05-26 23:38:00}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$Z')) (SQ <' = $(cat o) &&\n'> <'\t test "" = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{2005-05-26 23:43:00}" (exact end of history)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{2005-05-26 23:43:00}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$E')) (SQ <' = $(cat o) &&\n'> <'\t test "" = "$(cat e)"'>) } ) (C {<test_expect_success>} {(SQ <'Query "master@{2005-05-28}" (past end of history)'>)} { (SQ <'rm -f o e &&\n'> <'\t git rev-parse --verify "master@{2005-05-28}" >o 2>e &&\n'> <'\t test '> ) (DQ ($ Id.VSub_DollarName '$D')) (SQ <' = $(cat o) &&\n'> <'\t test "warning: Log for ref '>) (DQ ($ Id.VSub_DollarName '$m') <' unexpectedly ended on '> ($ Id.VSub_DollarName '$ld')) (SQ <'." = "$(cat e)"'>) } ) (C {<rm>} {<-f>} {<'.git/'> ($ Id.VSub_DollarName '$m')} {<'.git/logs/'> ($ Id.VSub_DollarName '$m')} {<expect>} ) (C {<test_expect_success>} {(SQ <'creating initial files'>)} { (SQ <'echo TEST >F &&\n'> <' git add F &&\n'> <'\t GIT_AUTHOR_DATE="2005-05-26 23:30" \\\n'> <'\t GIT_COMMITTER_DATE="2005-05-26 23:30" git commit -m add -a &&\n'> <'\t h_TEST=$(git rev-parse --verify HEAD) &&\n'> <'\t echo The other day this did not work. >M &&\n'> <'\t echo And then Bob told me how to fix it. >>M &&\n'> <'\t echo OTHER >F &&\n'> <'\t GIT_AUTHOR_DATE="2005-05-26 23:41" \\\n'> <'\t GIT_COMMITTER_DATE="2005-05-26 23:41" git commit -F M -a &&\n'> <'\t h_OTHER=$(git rev-parse --verify HEAD) &&\n'> <'\t GIT_AUTHOR_DATE="2005-05-26 23:44" \\\n'> <'\t GIT_COMMITTER_DATE="2005-05-26 23:44" git commit --amend &&\n'> <'\t h_FIXED=$(git rev-parse --verify HEAD) &&\n'> <'\t echo Merged initial commit and a later commit. >M &&\n'> <'\t echo $h_TEST >.git/MERGE_HEAD &&\n'> <'\t GIT_AUTHOR_DATE="2005-05-26 23:45" \\\n'> <'\t GIT_COMMITTER_DATE="2005-05-26 23:45" git commit -F M &&\n'> <'\t h_MERGED=$(git rev-parse --verify HEAD) &&\n'> <'\t rm -f M'> ) } ) (command.Simple words: [{<cat>}] redirects: [ (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>}) (redir op: <Id.Redir_DLess '<<'> loc: (redir_loc.Fd fd:0) arg: (redir_param.MultiLine here_begin: {<EOF>} here_end_span_id: 1441 stdin_parts: [ ($ Id.VSub_DollarName '$Z') <' '> ($ Id.VSub_DollarName '$h_TEST') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150200 +0000\tcommit (initial): add\n'> ($ Id.VSub_DollarName '$h_TEST') <' '> ($ Id.VSub_DollarName '$h_OTHER') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117150860 +0000\tcommit: The other day this did not work.\n'> ($ Id.VSub_DollarName '$h_OTHER') <' '> ($ Id.VSub_DollarName '$h_FIXED') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117151040 +0000\tcommit (amend): The other day this did not work.\n'> ($ Id.VSub_DollarName '$h_FIXED') <' '> ($ Id.VSub_DollarName '$h_MERGED') <' '> ($ Id.VSub_DollarName '$GIT_COMMITTER_NAME') <' <'> ($ Id.VSub_DollarName '$GIT_COMMITTER_EMAIL') <'> 1117151100 +0000\tcommit (merge): Merged initial commit and a later commit.\n'> ] ) ) ] do_fork: T ) (C {<test_expect_success>} {(SQ <'git commit logged updates'>)} {(DQ <'test_cmp expect .git/logs/'> ($ Id.VSub_DollarName '$m'))} ) (C {<unset>} {<h_TEST>} {<h_OTHER>} {<h_FIXED>} {<h_MERGED>}) (C {<test_expect_success>} {(SQ <'git cat-file blob master:F (expect OTHER)'>)} {(SQ <'test OTHER = $(git cat-file blob master:F)'>)} ) (C {<test_expect_success>} {(SQ <'git cat-file blob master@{2005-05-26 23:30}:F (expect TEST)'>)} {(SQ <'test TEST = $(git cat-file blob "master@{2005-05-26 23:30}:F")'>)} ) (C {<test_expect_success>} {(SQ <'git cat-file blob master@{2005-05-26 23:42}:F (expect OTHER)'>)} {(SQ <'test OTHER = $(git cat-file blob "master@{2005-05-26 23:42}:F")'>)} ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:a) op: assign_op.Equal rhs: {<'refs/heads/a'>} spids: [1511] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:b) op: assign_op.Equal rhs: {<'refs/heads/b'>} spids: [1514] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:c) op: assign_op.Equal rhs: {<'refs/heads/c'>} spids: [1517] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:E) op: assign_op.Equal rhs: {(SQ <'""'>)} spids: [1520] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:F) op: assign_op.Equal rhs: {(SQ <'%s\\0'>)} spids: [1525] ) ] ) (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:pws) op: assign_op.Equal rhs: {(SQ <'path with space'>)} spids: [1530] ) ] ) (C {<test_expect_success>} {(SQ <'stdin test setup'>)} { (SQ <'\n'> <'\techo "$pws" >"$pws" &&\n'> <'\tgit add -- "$pws" &&\n'> <'\tgit commit -m "$pws"\n'> ) } ) (C {<test_expect_success>} {(SQ <'-z fails without --stdin'>)} { (SQ <'\n'> <'\ttest_must_fail git update-ref -z $m $m $m 2>err &&\n'> <'\ttest_i18ngrep "usage: git update-ref" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin works with no input'>)} { (SQ <'\n'> <'\t>stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse --verify -q $m\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on empty line'>)} { (SQ <'\n'> <'\techo "" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: empty command in input" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on only whitespace'>)} { (SQ <'\n'> <'\techo " " >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: whitespace before command: " err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on leading whitespace'>)} { (SQ <'\n'> <'\techo " create $a $m" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: whitespace before command: create $a $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on unknown command'>)} { (SQ <'\n'> <'\techo "unknown $a" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unknown command: unknown $a" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on unbalanced quotes'>)} { (SQ <'\n'> <'\techo "create $a \\"master" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: badly quoted argument: \\\\\\"master" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on invalid escape'>)} { (SQ <'\n'> <'\techo "create $a \\"ma\\zter\\"" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: badly quoted argument: \\\\\\"ma\\\\\\\\zter\\\\\\"" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails on junk after quoted argument'>)} { (SQ <'\n'> <'\techo "create \\"$a\\"master" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unexpected character after quoted argument: \\\\\\"$a\\\\\\"master" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails create with no ref'>)} { (SQ <'\n'> <'\techo "create " >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create: missing <ref>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails create with no new value'>)} { (SQ <'\n'> <'\techo "create $a" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $a: missing <newvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails create with too many arguments'>)} { (SQ <'\n'> <'\techo "create $a $m $m" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $a: extra input: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails update with no ref'>)} { (SQ <'\n'> <'\techo "update " >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update: missing <ref>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails update with no new value'>)} { (SQ <'\n'> <'\techo "update $a" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $a: missing <newvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails update with too many arguments'>)} { (SQ <'\n'> <'\techo "update $a $m $m $m" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $a: extra input: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails delete with no ref'>)} { (SQ <'\n'> <'\techo "delete " >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: delete: missing <ref>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails delete with too many arguments'>)} { (SQ <'\n'> <'\techo "delete $a $m $m" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: delete $a: extra input: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails verify with too many arguments'>)} { (SQ <'\n'> <'\techo "verify $a $m $m" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: verify $a: extra input: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails option with unknown name'>)} { (SQ <'\n'> <'\techo "option unknown" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: option unknown: unknown" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin fails with duplicate refs'>)} { (SQ <'\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tcreate $a $m\n'> <'\tcreate $b $m\n'> <'\tcreate $a $m\n'> <'\tEOF\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: multiple updates for ref '> ) (DQ <'\''>) (SQ <'$a'>) (DQ <'\''>) (SQ <' not allowed." err\n'>) } ) (C {<test_expect_success>} {(SQ <'stdin create ref works'>)} { (SQ <'\n'> <'\techo "create $a $m" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin does not create reflogs by default'>)} { (SQ <'\n'> <'\ttest_when_finished "git update-ref -d $outside" &&\n'> <'\techo "create $outside $m" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $outside >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git reflog exists $outside\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin creates reflogs with --create-reflog'>)} { (SQ <'\n'> <'\techo "create $outside $m" >stdin &&\n'> <'\tgit update-ref --create-reflog --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $outside >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit reflog exists $outside\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin succeeds with quoted argument'>)} { (SQ <'\n'> <'\tgit update-ref -d $a &&\n'> <'\techo "create $a \\"$m\\"" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin succeeds with escaped character'>)} { (SQ <'\n'> <'\tgit update-ref -d $a &&\n'> <'\techo "create $a \\"ma\\\\163ter\\"" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update ref creates with zero old value'>)} { (SQ <'\n'> <'\techo "update $b $m $Z" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit update-ref -d $b\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update ref creates with empty old value'>)} { (SQ <'\n'> <'\techo "update $b $m $E" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin create ref works with path with space to blob'>)} { (SQ <'\n'> <'\techo "create refs/blobs/pws \\"$m:$pws\\"" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse "$m:$pws" >expect &&\n'> <'\tgit rev-parse refs/blobs/pws >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit update-ref -d refs/blobs/pws\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update ref fails with wrong old value'>)} { (SQ <'\n'> <'\techo "update $c $m $m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$c'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'>) } ) (C {<test_expect_success>} {(SQ <'stdin update ref fails with bad old value'>)} { (SQ <'\n'> <'\techo "update $c $m does-not-exist" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin create ref fails with bad new value'>)} { (SQ <'\n'> <'\techo "create $c does-not-exist" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin create ref fails with zero new value'>)} { (SQ <'\n'> <'\techo "create $c " >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $c: zero <newvalue>" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update ref works with right old value'>)} { (SQ <'\n'> <'\techo "update $b $m~1 $m" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m~1 >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin delete ref fails with wrong old value'>)} { (SQ <'\n'> <'\techo "delete $a $m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$a'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin delete ref fails with zero old value'>)} { (SQ <'\n'> <'\techo "delete $a " >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: delete $a: zero <oldvalue>" err &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update symref works option no-deref'>)} { (SQ <'\n'> <'\tgit symbolic-ref TESTSYMREF $b &&\n'> <'\tcat >stdin <<-EOF &&\n'> <'\toption no-deref\n'> <'\tupdate TESTSYMREF $a $b\n'> <'\tEOF\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse TESTSYMREF >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $m~1 >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin delete symref works option no-deref'>)} { (SQ <'\n'> <'\tgit symbolic-ref TESTSYMREF $b &&\n'> <'\tcat >stdin <<-EOF &&\n'> <'\toption no-deref\n'> <'\tdelete TESTSYMREF $b\n'> <'\tEOF\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q TESTSYMREF &&\n'> <'\tgit rev-parse $m~1 >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin delete ref works with right old value'>)} { (SQ <'\n'> <'\techo "delete $b $m~1" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q $b\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update/create/verify combination works'>)} { (SQ <'\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tupdate $a $m\n'> <'\tcreate $b $m\n'> <'\tverify $c\n'> <'\tEOF\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin verify succeeds for correct value'>)} { (SQ <'\n'> <'\tgit rev-parse $m >expect &&\n'> <'\techo "verify $m $m" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin verify succeeds for missing reference'>)} { (SQ <'\n'> <'\techo "verify refs/heads/missing $Z" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q refs/heads/missing\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin verify treats no value as missing'>)} { (SQ <'\n'> <'\techo "verify refs/heads/missing" >stdin &&\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q refs/heads/missing\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin verify fails for wrong value'>)} { (SQ <'\n'> <'\tgit rev-parse $m >expect &&\n'> <'\techo "verify $m $m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin verify fails for mistaken null value'>)} { (SQ <'\n'> <'\tgit rev-parse $m >expect &&\n'> <'\techo "verify $m $Z" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin verify fails for mistaken empty value'>)} { (SQ <'\n'> <'\tM=$(git rev-parse $m) &&\n'> <'\ttest_when_finished "git update-ref $m $M" &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\techo "verify $m" >stdin &&\n'> <'\ttest_must_fail git update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update refs works with identity updates'>)} { (SQ <'\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tupdate $a $m $m\n'> <'\tupdate $b $m $m\n'> <'\tupdate $c $Z $E\n'> <'\tEOF\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin update refs fails with wrong old value'>)} { (SQ <'\n'> <'\tgit update-ref $c $m &&\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tupdate $a $m $m\n'> <'\tupdate $b $m $m\n'> <'\tupdate $c '> ) (SQ <'\n'> <'\tEOF\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$c'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $c >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin delete refs works with packed and loose refs'>)} { (SQ <'\n'> <'\tgit pack-refs --all &&\n'> <'\tgit update-ref $c $m~1 &&\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tdelete $a $m\n'> <'\tupdate $b $Z $m\n'> <'\tupdate $c $E $m~1\n'> <'\tEOF\n'> <'\tgit update-ref --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q $a &&\n'> <'\ttest_must_fail git rev-parse --verify -q $b &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z works on empty input'>)} { (SQ <'\n'> <'\t>stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse --verify -q $m\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails on empty line'>)} { (SQ <'\n'> <'\techo "" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: whitespace before command: " err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails on empty command'>)} { (SQ <'\n'> <'\tprintf $F "" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: empty command in input" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails on only whitespace'>)} { (SQ <'\n'> <'\tprintf $F " " >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: whitespace before command: " err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails on leading whitespace'>)} { (SQ <'\n'> <'\tprintf $F " create $a" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: whitespace before command: create $a" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails on unknown command'>)} { (SQ <'\n'> <'\tprintf $F "unknown $a" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unknown command: unknown $a" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails create with no ref'>)} { (SQ <'\n'> <'\tprintf $F "create " >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create: missing <ref>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails create with no new value'>)} { (SQ <'\n'> <'\tprintf $F "create $a" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $a: unexpected end of input when reading <newvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails create with too many arguments'>)} { (SQ <'\n'> <'\tprintf $F "create $a" "$m" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unknown command: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails update with no ref'>)} { (SQ <'\n'> <'\tprintf $F "update " >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update: missing <ref>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails update with too few args'>)} { (SQ <'\n'> <'\tprintf $F "update $a" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $a: unexpected end of input when reading <oldvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z emits warning with empty new value'>)} { (SQ <'\n'> <'\tgit update-ref $a $m &&\n'> <'\tprintf $F "update $a" "" "" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "warning: update $a: missing <newvalue>, treating as zero" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $a\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails update with no new value'>)} { (SQ <'\n'> <'\tprintf $F "update $a" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $a: unexpected end of input when reading <newvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails update with no old value'>)} { (SQ <'\n'> <'\tprintf $F "update $a" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $a: unexpected end of input when reading <oldvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails update with too many arguments'>)} { (SQ <'\n'> <'\tprintf $F "update $a" "$m" "$m" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unknown command: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails delete with no ref'>)} { (SQ <'\n'> <'\tprintf $F "delete " >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: delete: missing <ref>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails delete with no old value'>)} { (SQ <'\n'> <'\tprintf $F "delete $a" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: delete $a: unexpected end of input when reading <oldvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails delete with too many arguments'>)} { (SQ <'\n'> <'\tprintf $F "delete $a" "$m" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unknown command: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails verify with too many arguments'>)} { (SQ <'\n'> <'\tprintf $F "verify $a" "$m" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: unknown command: $m" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails verify with no old value'>)} { (SQ <'\n'> <'\tprintf $F "verify $a" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: verify $a: unexpected end of input when reading <oldvalue>" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails option with unknown name'>)} { (SQ <'\n'> <'\tprintf $F "option unknown" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: option unknown: unknown" err\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z fails with duplicate refs'>)} { (SQ <'\n'> <'\tprintf $F "create $a" "$m" "create $b" "$m" "create $a" "$m" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: multiple updates for ref '> ) (DQ <'\''>) (SQ <'$a'>) (DQ <'\''>) (SQ <' not allowed." err\n'>) } ) (C {<test_expect_success>} {(SQ <'stdin -z create ref works'>)} { (SQ <'\n'> <'\tprintf $F "create $a" "$m" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update ref creates with zero old value'>)} { (SQ <'\n'> <'\tprintf $F "update $b" "$m" "$Z" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit update-ref -d $b\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update ref creates with empty old value'>)} { (SQ <'\n'> <'\tprintf $F "update $b" "$m" "" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z create ref works with path with space to blob'>)} { (SQ <'\n'> <'\tprintf $F "create refs/blobs/pws" "$m:$pws" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse "$m:$pws" >expect &&\n'> <'\tgit rev-parse refs/blobs/pws >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit update-ref -d refs/blobs/pws\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update ref fails with wrong old value'>)} { (SQ <'\n'> <'\tprintf $F "update $c" "$m" "$m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$c'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'>) } ) (C {<test_expect_success>} {(SQ <'stdin -z update ref fails with bad old value'>)} { (SQ <'\n'> <'\tprintf $F "update $c" "$m" "does-not-exist" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: update $c: invalid <oldvalue>: does-not-exist" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z create ref fails when ref exists'>)} { (SQ <'\n'> <'\tgit update-ref $c $m &&\n'> <'\tgit rev-parse "$c" >expect &&\n'> <'\tprintf $F "create $c" "$m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$c'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\tgit rev-parse "$c" >actual &&\n'> <'\ttest_cmp expect actual\n'>) } ) (C {<test_expect_success>} {(SQ <'stdin -z create ref fails with bad new value'>)} { (SQ <'\n'> <'\tgit update-ref -d "$c" &&\n'> <'\tprintf $F "create $c" "does-not-exist" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $c: invalid <newvalue>: does-not-exist" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z create ref fails with empty new value'>)} { (SQ <'\n'> <'\tprintf $F "create $c" "" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: create $c: missing <newvalue>" err &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update ref works with right old value'>)} { (SQ <'\n'> <'\tprintf $F "update $b" "$m~1" "$m" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m~1 >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z delete ref fails with wrong old value'>)} { (SQ <'\n'> <'\tprintf $F "delete $a" "$m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$a'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z delete ref fails with zero old value'>)} { (SQ <'\n'> <'\tprintf $F "delete $a" "$Z" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: delete $a: zero <oldvalue>" err &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update symref works option no-deref'>)} { (SQ <'\n'> <'\tgit symbolic-ref TESTSYMREF $b &&\n'> <'\tprintf $F "option no-deref" "update TESTSYMREF" "$a" "$b" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse TESTSYMREF >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $m~1 >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z delete symref works option no-deref'>)} { (SQ <'\n'> <'\tgit symbolic-ref TESTSYMREF $b &&\n'> <'\tprintf $F "option no-deref" "delete TESTSYMREF" "$b" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q TESTSYMREF &&\n'> <'\tgit rev-parse $m~1 >expect &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z delete ref works with right old value'>)} { (SQ <'\n'> <'\tprintf $F "delete $b" "$m~1" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q $b\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update/create/verify combination works'>)} { (SQ <'\n'> <'\tprintf $F "update $a" "$m" "" "create $b" "$m" "verify $c" "" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z verify succeeds for correct value'>)} { (SQ <'\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tprintf $F "verify $m" "$m" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z verify succeeds for missing reference'>)} { (SQ <'\n'> <'\tprintf $F "verify refs/heads/missing" "$Z" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q refs/heads/missing\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z verify treats no value as missing'>)} { (SQ <'\n'> <'\tprintf $F "verify refs/heads/missing" "" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q refs/heads/missing\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z verify fails for wrong value'>)} { (SQ <'\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tprintf $F "verify $m" "$m~1" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z verify fails for mistaken null value'>)} { (SQ <'\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tprintf $F "verify $m" "$Z" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z verify fails for mistaken empty value'>)} { (SQ <'\n'> <'\tM=$(git rev-parse $m) &&\n'> <'\ttest_when_finished "git update-ref $m $M" &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tprintf $F "verify $m" "" >stdin &&\n'> <'\ttest_must_fail git update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update refs works with identity updates'>)} { (SQ <'\n'> < '\tprintf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$Z" "" >stdin &&\n' > <'\tgit update-ref -z --stdin <stdin &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z update refs fails with wrong old value'>)} { (SQ <'\n'> <'\tgit update-ref $c $m &&\n'> < '\tprintf $F "update $a" "$m" "$m" "update $b" "$m" "$m" "update $c" "$m" "$Z" >stdin &&\n' > <'\ttest_must_fail git update-ref -z --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: cannot lock ref '> ) (DQ <'\''>) (SQ <'$c'>) (DQ <'\''>) (SQ <'" err &&\n'> <'\tgit rev-parse $m >expect &&\n'> <'\tgit rev-parse $a >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $b >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\tgit rev-parse $c >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'stdin -z delete refs works with packed and loose refs'>)} { (SQ <'\n'> <'\tgit pack-refs --all &&\n'> <'\tgit update-ref $c $m~1 &&\n'> <'\tprintf $F "delete $a" "$m" "update $b" "$Z" "$m" "update $c" "" "$m~1" >stdin &&\n'> <'\tgit update-ref -z --stdin <stdin &&\n'> <'\ttest_must_fail git rev-parse --verify -q $a &&\n'> <'\ttest_must_fail git rev-parse --verify -q $b &&\n'> <'\ttest_must_fail git rev-parse --verify -q $c\n'> ) } ) (C {<test_expect_success>} {(SQ <'fails with duplicate HEAD update'>)} { (SQ <'\n'> <'\tgit branch target1 $A &&\n'> <'\tgit checkout target1 &&\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tupdate refs/heads/target1 $C\n'> <'\toption no-deref\n'> <'\tupdate HEAD $B\n'> <'\tEOF\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: multiple updates for '> ) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <HEAD>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <' (including one via its referent .refs/heads/target1.) are not allowed" err &&\n'> <'\techo "refs/heads/target1" >expect &&\n'> <'\tgit symbolic-ref HEAD >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\techo "$A" >expect &&\n'> <'\tgit rev-parse refs/heads/target1 >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'fails with duplicate ref update via symref'>)} { (SQ <'\n'> <'\tgit branch target2 $A &&\n'> <'\tgit symbolic-ref refs/heads/symref2 refs/heads/target2 &&\n'> <'\tcat >stdin <<-EOF &&\n'> <'\tupdate refs/heads/target2 $C\n'> <'\tupdate refs/heads/symref2 $B\n'> <'\tEOF\n'> <'\ttest_must_fail git update-ref --stdin <stdin 2>err &&\n'> <'\tgrep "fatal: multiple updates for '> ) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <'refs/heads/target2'>) (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\\''>) (SQ <' (including one via symref .refs/heads/symref2.) are not allowed" err &&\n'> <'\techo "refs/heads/target2" >expect &&\n'> <'\tgit symbolic-ref refs/heads/symref2 >actual &&\n'> <'\ttest_cmp expect actual &&\n'> <'\techo "$A" >expect &&\n'> <'\tgit rev-parse refs/heads/target2 >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (command.ShFunction name: run_with_limited_open_files body: (BraceGroup children: [ (command.Subshell child: (command.AndOr ops: [Id.Op_DAmp] children: [(C {<ulimit>} {<-n>} {<32>}) (C {(DQ ($ Id.VSub_At '$@'))})] ) ) ] ) ) (C {<test_lazy_prereq>} {<ULIMIT_FILE_DESCRIPTORS>} {(SQ <'run_with_limited_open_files true'>)}) (C {<test_expect_success>} {<ULIMIT_FILE_DESCRIPTORS>} {(SQ <'large transaction creating branches does not burst open file limit'>)} { (SQ <'\n'> <'(\n'> <'\tfor i in $(test_seq 33)\n'> <'\tdo\n'> <'\t\techo "create refs/heads/$i HEAD"\n'> <'\tdone >large_input &&\n'> <'\trun_with_limited_open_files git update-ref --stdin <large_input &&\n'> <'\tgit rev-parse --verify -q refs/heads/33\n'> <')\n'> ) } ) (C {<test_expect_success>} {<ULIMIT_FILE_DESCRIPTORS>} {(SQ <'large transaction deleting branches does not burst open file limit'>)} { (SQ <'\n'> <'(\n'> <'\tfor i in $(test_seq 33)\n'> <'\tdo\n'> <'\t\techo "delete refs/heads/$i HEAD"\n'> <'\tdone >large_input &&\n'> <'\trun_with_limited_open_files git update-ref --stdin <large_input &&\n'> <'\ttest_must_fail git rev-parse --verify -q refs/heads/33\n'> <')\n'> ) } ) (C {<test_expect_success>} {(SQ <'handle per-worktree refs in refs/bisect'>)} { (SQ <'\n'> <'\tgit commit --allow-empty -m "initial commit" &&\n'> <'\tgit worktree add -b branch worktree &&\n'> <'\t(\n'> <'\t\tcd worktree &&\n'> <'\t\tgit commit --allow-empty -m "test commit" &&\n'> <'\t\tgit for-each-ref >for-each-ref.out &&\n'> <'\t\t! grep refs/bisect for-each-ref.out &&\n'> <'\t\tgit update-ref refs/bisect/something HEAD &&\n'> <'\t\tgit rev-parse refs/bisect/something >../worktree-head &&\n'> <'\t\tgit for-each-ref | grep refs/bisect/something\n'> <'\t) &&\n'> <'\ttest_path_is_missing .git/refs/bisect &&\n'> <'\ttest_must_fail git rev-parse refs/bisect/something &&\n'> <'\tgit update-ref refs/bisect/something HEAD &&\n'> <'\tgit rev-parse refs/bisect/something >main-head &&\n'> <'\t! test_cmp main-head worktree-head\n'> ) } ) (C {<test_done>}) ] )