(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <'Test git update-ref error handling'>)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (FuncDef name: test_update_rejected body: (BraceGroup children: [ (AndOr ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp Op_DAmp] children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:before) op: Equal rhs: {(DQ ($ VSub_Number '$1'))} spids: [52] ) ] spids: [52] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:pack) op: Equal rhs: {(DQ ($ VSub_Number '$2'))} spids: [60] ) ] spids: [60] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:create) op: Equal rhs: {(DQ ($ VSub_Number '$3'))} spids: [68] ) ] spids: [68] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:error) op: Equal rhs: {(DQ ($ VSub_Number '$4'))} spids: [76] ) ] spids: [76] ) (Pipeline children: [ (C {(printf)} { (DQ ('create ') ($ VSub_Name '$prefix') ('/%s ') ($ VSub_Name '$C') (Lit_Other '\\') (n) ) } {($ VSub_Name '$before')} ) (C {(git)} {(update-ref)} {(--stdin)}) ] negated: F ) (SimpleCommand words: [{(git)} {(for-each-ref)} {($ VSub_Name '$prefix')}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(unchanged)} spids: [115] ) ] ) (If arms: [ (if_arm cond: [(C {($ VSub_Name '$pack')})] action: [(C {(git)} {(pack-refs)} {(--all)})] spids: [16777215 126] ) ] spids: [16777215 136] ) (SimpleCommand words: [ {(printf)} { (DQ ('create ') ($ VSub_Name '$prefix') ('/%s ') ($ VSub_Name '$C') (Lit_Other '\\') (n) ) } {($ VSub_Name '$create')} ] redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(input)} spids:[154])] ) (SimpleCommand words: [{(test_must_fail)} {(git)} {(update-ref)} {(--stdin)}] redirects: [ (Redir op_id: Redir_Less fd: 16777215 arg_word: {(input)} spids: [168] ) (Redir op_id: Redir_Great fd: 2 arg_word: {(output.err)} spids: [171] ) ] ) (C {(grep)} {(-F)} {(DQ ($ VSub_Name '$error'))} {(output.err)}) (SimpleCommand words: [{(git)} {(for-each-ref)} {($ VSub_Name '$prefix')}] redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(actual)} spids:[196])] ) (C {(test_cmp)} {(unchanged)} {(actual)}) ] ) ] spids: [49] ) spids: [44 48] ) (Assignment keyword: Assign_None pairs: [(assign_pair lhs:(LhsName name:Q) op:Equal rhs:{(DQ ("'"))} spids:[211])] spids: [211] ) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <'\n'> <'\n'> <'\tgit commit --allow-empty -m Initial &&\n'> <'\tC=$(git rev-parse HEAD) &&\n'> <'\tgit commit --allow-empty -m Second &&\n'> <'\tD=$(git rev-parse HEAD) &&\n'> <'\tgit commit --allow-empty -m Third &&\n'> <'\tE=$(git rev-parse HEAD)\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing loose ref is a simple prefix of new'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/1l &&\n'> <'\ttest_update_rejected "a c e" false "b c/x d" \\\n'> <'\t\t"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing packed ref is a simple prefix of new'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/1p &&\n'> <'\ttest_update_rejected "a c e" true "b c/x d" \\\n'> <'\t\t"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing loose ref is a deeper prefix of new'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/2l &&\n'> <'\ttest_update_rejected "a c e" false "b c/x/y d" \\\n'> <'\t\t"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing packed ref is a deeper prefix of new'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/2p &&\n'> <'\ttest_update_rejected "a c e" true "b c/x/y d" \\\n'> <'\t\t"$Q$prefix/c$Q exists; cannot create $Q$prefix/c/x/y$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'new ref is a simple prefix of existing loose'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/3l &&\n'> <'\ttest_update_rejected "a c/x e" false "b c d" \\\n'> <'\t\t"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'new ref is a simple prefix of existing packed'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/3p &&\n'> <'\ttest_update_rejected "a c/x e" true "b c d" \\\n'> <'\t\t"$Q$prefix/c/x$Q exists; cannot create $Q$prefix/c$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'new ref is a deeper prefix of existing loose'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/4l &&\n'> <'\ttest_update_rejected "a c/x/y e" false "b c d" \\\n'> <'\t\t"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'new ref is a deeper prefix of existing packed'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/4p &&\n'> <'\ttest_update_rejected "a c/x/y e" true "b c d" \\\n'> <'\t\t"$Q$prefix/c/x/y$Q exists; cannot create $Q$prefix/c$Q"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'one new ref is a simple prefix of another'>)} { (SQ <'\n'> <'\n'> <'\tprefix=refs/5 &&\n'> <'\ttest_update_rejected "a e" false "b c c/x d" \\\n'> <'\t\t"cannot process $Q$prefix/c$Q and $Q$prefix/c/x$Q at the same time"\n'> <'\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool rev-parse'>)} { (SQ <'\n'> <'\tprefix=refs/e-rev-parse &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\techo "$C" >expected &&\n'> <'\tgit rev-parse $prefix/foo >actual &&\n'> <'\ttest_cmp expected actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool for-each-ref'>)} { (SQ <'\n'> <'\tprefix=refs/e-for-each-ref &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit for-each-ref $prefix >expected &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tgit for-each-ref $prefix >actual &&\n'> <'\ttest_cmp expected actual\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool create'>)} { (SQ <'\n'> <'\tprefix=refs/e-create &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tprintf "create %s $C\\n" $prefix/foo |\n'> <'\tgit update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool verify'>)} { (SQ <'\n'> <'\tprefix=refs/e-verify &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tprintf "verify %s $C\\n" $prefix/foo |\n'> <'\tgit update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool 1-arg update'>)} { (SQ <'\n'> <'\tprefix=refs/e-update-1 &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tprintf "update %s $D\\n" $prefix/foo |\n'> <'\tgit update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool 2-arg update'>)} { (SQ <'\n'> <'\tprefix=refs/e-update-2 &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tprintf "update %s $D $C\\n" $prefix/foo |\n'> <'\tgit update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool 0-arg delete'>)} { (SQ <'\n'> <'\tprefix=refs/e-delete-0 &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tprintf "delete %s\\n" $prefix/foo |\n'> <'\tgit update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'empty directory should not fool 1-arg delete'>)} { (SQ <'\n'> <'\tprefix=refs/e-delete-1 &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tgit pack-refs --all &&\n'> <'\tmkdir -p .git/$prefix/foo/bar/baz &&\n'> <'\tprintf "delete %s $C\\n" $prefix/foo |\n'> <'\tgit update-ref --stdin\n'> ) } ) (C {(test_expect_success)} {(SQ <'missing old value blocks update'>)} { (SQ <'\n'> <'\tprefix=refs/missing-update &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/foo $E $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'incorrect old value blocks update'>)} { (SQ <'\n'> <'\tprefix=refs/incorrect-update &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/foo $E $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing old value blocks create'>)} { (SQ <'\n'> <'\tprefix=refs/existing-create &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/foo$Q: reference already exists\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "create $prefix/foo $E" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'incorrect old value blocks delete'>)} { (SQ <'\n'> <'\tprefix=refs/incorrect-delete &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/foo$Q: is at $C but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "delete $prefix/foo $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'missing old value blocks indirect update'>)} { (SQ <'\n'> <'\tprefix=refs/missing-indirect-update &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/symref $E $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'incorrect old value blocks indirect update'>)} { (SQ <'\n'> <'\tprefix=refs/incorrect-indirect-update &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/symref $E $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing old value blocks indirect create'>)} { (SQ <'\n'> <'\tprefix=refs/existing-indirect-create &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: reference already exists\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "create $prefix/symref $E" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'incorrect old value blocks indirect delete'>)} { (SQ <'\n'> <'\tprefix=refs/incorrect-indirect-delete &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "delete $prefix/symref $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'missing old value blocks indirect no-deref update'>)} { (SQ <'\n'> <'\tprefix=refs/missing-noderef-update &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: reference is missing but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "option no-deref" "update $prefix/symref $E $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'incorrect old value blocks indirect no-deref update'>)} { (SQ <'\n'> <'\tprefix=refs/incorrect-noderef-update &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "option no-deref" "update $prefix/symref $E $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'existing old value blocks indirect no-deref create'>)} { (SQ <'\n'> <'\tprefix=refs/existing-noderef-create &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: reference already exists\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "option no-deref" "create $prefix/symref $E" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'incorrect old value blocks indirect no-deref delete'>)} { (SQ <'\n'> <'\tprefix=refs/incorrect-noderef-delete &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tgit update-ref $prefix/foo $C &&\n'> <'\tcat >expected <<-EOF &&\n'> <'\tfatal: cannot lock ref $Q$prefix/symref$Q: is at $C but expected $D\n'> <'\tEOF\n'> <'\tprintf "%s\\n" "option no-deref" "delete $prefix/symref $D" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'non-empty directory blocks create'>)} { (SQ <'\n'> <'\tprefix=refs/ne-create &&\n'> <'\tmkdir -p .git/$prefix/foo/bar &&\n'> <'\t: >.git/$prefix/foo/bar/baz.lock &&\n'> <'\ttest_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/foo$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/foo $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/foo $D $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'broken reference blocks create'>)} { (SQ <'\n'> <'\tprefix=refs/broken-create &&\n'> <'\tmkdir -p .git/$prefix &&\n'> <'\techo "gobbledigook" >.git/$prefix/foo &&\n'> <'\ttest_when_finished "rm -f .git/$prefix/foo" &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/foo $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/foo$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/foo $D $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'non-empty directory blocks indirect create'>)} { (SQ <'\n'> <'\tprefix=refs/ne-indirect-create &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\tmkdir -p .git/$prefix/foo/bar &&\n'> <'\t: >.git/$prefix/foo/bar/baz.lock &&\n'> <'\ttest_when_finished "rm -f .git/$prefix/foo/bar/baz.lock" &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/symref$Q: there is a non-empty directory $Q.git/$prefix/foo$Q blocking reference $Q$prefix/foo$Q\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/symref $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/symref $D $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_expect_success)} {(SQ <'broken reference blocks indirect create'>)} { (SQ <'\n'> <'\tprefix=refs/broken-indirect-create &&\n'> <'\tgit symbolic-ref $prefix/symref $prefix/foo &&\n'> <'\techo "gobbledigook" >.git/$prefix/foo &&\n'> <'\ttest_when_finished "rm -f .git/$prefix/foo" &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/symref $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err &&\n'> <'\tcat >expected <<-EOF &&\n'> < '\tfatal: cannot lock ref $Q$prefix/symref$Q: unable to resolve reference $Q$prefix/foo$Q: reference broken\n' > <'\tEOF\n'> <'\tprintf "%s\\n" "update $prefix/symref $D $C" |\n'> <'\ttest_must_fail git update-ref --stdin 2>output.err &&\n'> <'\ttest_cmp expected output.err\n'> ) } ) (C {(test_done)}) ] )