(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'See why rewinding head breaks send-pack\n'> <'\n'>)} spids: [13] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (command.ShAssignment pairs: [(assign_pair lhs:(sh_lhs_expr.Name name:cnt) op:assign_op.Equal rhs:{<64>} spids:[24])] ) (C {<test_expect_success>} {<setup>} { (SQ <'\n'> <'\ttest_tick &&\n'> <'\tmkdir mozart mozart/is &&\n'> <'\techo "Commit #0" >mozart/is/pink &&\n'> <'\tgit update-index --add mozart/is/pink &&\n'> <'\ttree=$(git write-tree) &&\n'> <'\tcommit=$(echo "Commit #0" | git commit-tree $tree) &&\n'> <'\tzero=$commit &&\n'> <'\tparent=$zero &&\n'> <'\ti=0 &&\n'> <'\twhile test $i -le $cnt\n'> <'\tdo\n'> <'\t i=$(($i+1)) &&\n'> <'\t test_tick &&\n'> <'\t echo "Commit #$i" >mozart/is/pink &&\n'> <'\t git update-index --add mozart/is/pink &&\n'> <'\t tree=$(git write-tree) &&\n'> <'\t commit=$(echo "Commit #$i" | git commit-tree $tree -p $parent) &&\n'> <'\t git update-ref refs/tags/commit$i $commit &&\n'> <'\t parent=$commit || return 1\n'> <'\tdone &&\n'> <'\tgit update-ref HEAD "$commit" &&\n'> <'\tgit clone ./. victim &&\n'> <'\t( cd victim && git config receive.denyCurrentBranch warn && git log ) &&\n'> <'\tgit update-ref HEAD "$zero" &&\n'> <'\tparent=$zero &&\n'> <'\ti=0 &&\n'> <'\twhile test $i -le $cnt\n'> <'\tdo\n'> <'\t i=$(($i+1)) &&\n'> <'\t test_tick &&\n'> <'\t echo "Rebase #$i" >mozart/is/pink &&\n'> <'\t git update-index --add mozart/is/pink &&\n'> <'\t tree=$(git write-tree) &&\n'> <'\t commit=$(echo "Rebase #$i" | git commit-tree $tree -p $parent) &&\n'> <'\t git update-ref refs/tags/rebase$i $commit &&\n'> <'\t parent=$commit || return 1\n'> <'\tdone &&\n'> <'\tgit update-ref HEAD "$commit" &&\n'> <'\techo Rebase &&\n'> <'\tgit log'> ) } ) (C {<test_expect_success>} {(SQ <'pack the source repository'>)} {(SQ <'\n'> <'\tgit repack -a -d &&\n'> <'\tgit prune\n'>)} ) (C {<test_expect_success>} {(SQ <'pack the destination repository'>)} { (SQ <'\n'> <' (\n'> <'\tcd victim &&\n'> <'\tgit repack -a -d &&\n'> <'\tgit prune\n'> <' )\n'> ) } ) (C {<test_expect_success>} {(SQ <'refuse pushing rewound head without --force'>)} { (SQ <'\n'> <'\tpushed_head=$(git rev-parse --verify master) &&\n'> <'\tvictim_orig=$(cd victim && git rev-parse --verify master) &&\n'> <'\ttest_must_fail git send-pack ./victim master &&\n'> <'\tvictim_head=$(cd victim && git rev-parse --verify master) &&\n'> <'\ttest "$victim_head" = "$victim_orig" &&\n'> <'\t# this should update\n'> <'\tgit send-pack --force ./victim master &&\n'> <'\tvictim_head=$(cd victim && git rev-parse --verify master) &&\n'> <'\ttest "$victim_head" = "$pushed_head"\n'> ) } ) (C {<test_expect_success>} {(SQ <'push can be used to delete a ref'>)} { (SQ <'\n'> <'\t( cd victim && git branch extra master ) &&\n'> <'\tgit send-pack ./victim :extra master &&\n'> <'\t( cd victim &&\n'> <'\t test_must_fail git rev-parse --verify extra )\n'> ) } ) (C {<test_expect_success>} {(SQ <'refuse deleting push with denyDeletes'>)} { (SQ <'\n'> <'\t(\n'> <'\t cd victim &&\n'> <'\t ( git branch -D extra || : ) &&\n'> <'\t git config receive.denyDeletes true &&\n'> <'\t git branch extra master\n'> <'\t) &&\n'> <'\ttest_must_fail git send-pack ./victim :extra master\n'> ) } ) (C {<test_expect_success>} {(SQ <'cannot override denyDeletes with git -c send-pack'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd victim &&\n'> <'\t\ttest_might_fail git branch -D extra &&\n'> <'\t\tgit config receive.denyDeletes true &&\n'> <'\t\tgit branch extra master\n'> <'\t) &&\n'> <'\ttest_must_fail git -c receive.denyDeletes=false \\\n'> <'\t\t\t\t\tsend-pack ./victim :extra master\n'> ) } ) (C {<test_expect_success>} {(SQ <'override denyDeletes with git -c receive-pack'>)} { (SQ <'\n'> <'\t(\n'> <'\t\tcd victim &&\n'> <'\t\ttest_might_fail git branch -D extra &&\n'> <'\t\tgit config receive.denyDeletes true &&\n'> <'\t\tgit branch extra master\n'> <'\t) &&\n'> <'\tgit send-pack \\\n'> <'\t\t--receive-pack="git -c receive.denyDeletes=false receive-pack" \\\n'> <'\t\t./victim :extra master\n'> ) } ) (C {<test_expect_success>} {(SQ <'denyNonFastforwards trumps --force'>)} { (SQ <'\n'> <'\t(\n'> <'\t cd victim &&\n'> <'\t ( git branch -D extra || : ) &&\n'> <'\t git config receive.denyNonFastforwards true\n'> <'\t) &&\n'> <'\tvictim_orig=$(cd victim && git rev-parse --verify master) &&\n'> <'\ttest_must_fail git send-pack --force ./victim master^:master &&\n'> <'\tvictim_head=$(cd victim && git rev-parse --verify master) &&\n'> <'\ttest "$victim_orig" = "$victim_head"\n'> ) } ) (C {<test_expect_success>} {(SQ <'send-pack --all sends all branches'>)} { (SQ <'\n'> <'\t# make sure we have at least 2 branches with different\n'> <'\t# values, just to be thorough\n'> <'\tgit branch other-branch HEAD^ &&\n'> <'\n'> <'\tgit init --bare all.git &&\n'> <'\tgit send-pack --all all.git &&\n'> <'\tgit for-each-ref refs/heads >expect &&\n'> <'\tgit -C all.git for-each-ref refs/heads >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'push --all excludes remote-tracking hierarchy'>)} { (SQ <'\n'> <'\tmkdir parent &&\n'> <'\t(\n'> <'\t cd parent &&\n'> <'\t git init && : >file && git add file && git commit -m add\n'> <'\t) &&\n'> <'\tgit clone parent child &&\n'> <'\t(\n'> <'\t cd child && git push --all\n'> <'\t) &&\n'> <'\t(\n'> <'\t cd parent &&\n'> <'\t test -z "$(git for-each-ref refs/remotes/origin)"\n'> <'\t)\n'> ) } ) (C {<test_expect_success>} {(SQ <'receive-pack runs auto-gc in remote repo'>)} { (SQ <'\n'> <'\trm -rf parent child &&\n'> <'\tgit init parent &&\n'> <'\t(\n'> <'\t # Setup a repo with 2 packs\n'> <'\t cd parent &&\n'> <'\t echo "Some text" >file.txt &&\n'> <'\t git add . &&\n'> <'\t git commit -m "Initial commit" &&\n'> <'\t git repack -adl &&\n'> <'\t echo "Some more text" >>file.txt &&\n'> <'\t git commit -a -m "Second commit" &&\n'> <'\t git repack\n'> <'\t) &&\n'> <'\tcp -R parent child &&\n'> <'\t(\n'> <'\t # Set the child to auto-pack if more than one pack exists\n'> <'\t cd child &&\n'> <'\t git config gc.autopacklimit 1 &&\n'> <'\t git config gc.autodetach false &&\n'> <'\t git branch test_auto_gc &&\n'> <'\t # And create a file that follows the temporary object naming\n'> <'\t # convention for the auto-gc to remove\n'> <'\t : >.git/objects/tmp_test_object &&\n'> <'\t test-chmtime =-1209601 .git/objects/tmp_test_object\n'> <'\t) &&\n'> <'\t(\n'> <'\t cd parent &&\n'> <'\t echo "Even more text" >>file.txt &&\n'> <'\t git commit -a -m "Third commit" &&\n'> <'\t git send-pack ../child HEAD:refs/heads/test_auto_gc\n'> <'\t) &&\n'> <'\ttest ! -e child/.git/objects/tmp_test_object\n'> ) } ) (command.ShFunction name: rewound_push_setup body: (BraceGroup children: [ (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp] children: [ (C {<rm>} {<-rf>} {<parent>} {<child>}) (C {<mkdir>} {<parent>}) (command.Subshell child: (command.AndOr ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp] children: [ (C {<cd>} {<parent>}) (C {<git>} {<init>}) (command.Simple words: [{<echo>} {<one>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<file>} ) ] do_fork: T ) (C {<git>} {<add>} {<file>}) (C {<git>} {<commit>} {<-m>} {<one>}) (C {<git>} {<config>} {<receive.denyCurrentBranch>} {<warn>}) (command.Simple words: [{<echo>} {<two>}] redirects: [ (redir op: <Id.Redir_Great '>'> loc: (redir_loc.Fd fd:1) arg: {<file>} ) ] do_fork: T ) (C {<git>} {<commit>} {<-a>} {<-m>} {<two>}) ] ) ) (C {<git>} {<clone>} {<parent>} {<child>}) (command.Subshell child: (command.AndOr ops: [Id.Op_DAmp] children: [ (C {<cd>} {<child>}) (C {<git>} {<reset>} {<--hard>} {<HEAD> <Id.Lit_Other '^'>}) ] ) ) ] ) ] ) ) (C {<test_expect_success>} {(SQ <'pushing explicit refspecs respects forcing'>)} { (SQ <'\n'> <'\trewound_push_setup &&\n'> <'\tparent_orig=$(cd parent && git rev-parse --verify master) &&\n'> <'\t(\n'> <'\t cd child &&\n'> <'\t test_must_fail git send-pack ../parent \\\n'> <'\t\trefs/heads/master:refs/heads/master\n'> <'\t) &&\n'> <'\tparent_head=$(cd parent && git rev-parse --verify master) &&\n'> <'\ttest "$parent_orig" = "$parent_head" &&\n'> <'\t(\n'> <'\t cd child &&\n'> <'\t git send-pack ../parent \\\n'> <'\t +refs/heads/master:refs/heads/master\n'> <'\t) &&\n'> <'\tparent_head=$(cd parent && git rev-parse --verify master) &&\n'> <'\tchild_head=$(cd child && git rev-parse --verify master) &&\n'> <'\ttest "$parent_head" = "$child_head"\n'> ) } ) (C {<test_expect_success>} {(SQ <'pushing wildcard refspecs respects forcing'>)} { (SQ <'\n'> <'\trewound_push_setup &&\n'> <'\tparent_orig=$(cd parent && git rev-parse --verify master) &&\n'> <'\t(\n'> <'\t cd child &&\n'> <'\t test_must_fail git send-pack ../parent \\\n'> <'\t "refs/heads/*:refs/heads/*"\n'> <'\t) &&\n'> <'\tparent_head=$(cd parent && git rev-parse --verify master) &&\n'> <'\ttest "$parent_orig" = "$parent_head" &&\n'> <'\t(\n'> <'\t cd child &&\n'> <'\t git send-pack ../parent \\\n'> <'\t "+refs/heads/*:refs/heads/*"\n'> <'\t) &&\n'> <'\tparent_head=$(cd parent && git rev-parse --verify master) &&\n'> <'\tchild_head=$(cd child && git rev-parse --verify master) &&\n'> <'\ttest "$parent_head" = "$child_head"\n'> ) } ) (C {<test_expect_success>} {(SQ <'deny pushing to delete current branch'>)} { (SQ <'\n'> <'\trewound_push_setup &&\n'> <'\t(\n'> <'\t cd child &&\n'> <'\t test_must_fail git send-pack ../parent :refs/heads/master 2>errs\n'> <'\t)\n'> ) } ) (C {<test_done>}) ] )