(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <'Test the post-checkout hook.'>)} spids: [13] ) ] spids: [13] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <'\n'> <'\techo Data for commit0. >a &&\n'> <'\techo Data for commit0. >b &&\n'> <'\tgit update-index --add a &&\n'> <'\tgit update-index --add b &&\n'> <'\ttree0=$(git write-tree) &&\n'> <'\tcommit0=$(echo setup | git commit-tree $tree0) &&\n'> <'\tgit update-ref refs/heads/master $commit0 &&\n'> <'\tgit clone ./. clone1 &&\n'> <'\tgit clone ./. clone2 &&\n'> <'\tGIT_DIR=clone2/.git git branch new2 &&\n'> <'\techo Data for commit1. >clone2/b &&\n'> <'\tGIT_DIR=clone2/.git git add clone2/b &&\n'> <'\tGIT_DIR=clone2/.git git commit -m new2\n'> ) } ) (ForEach iter_name: clone iter_words: [{(1)} {(2)}] do_arg_iter: F body: (DoGroup children: [ (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(clone) (${ VSub_Name clone) (/.git/hooks/post-checkout)} spids: [61] ) (HereDoc op_id: Redir_DLess fd: 16777215 body: {('#!/bin/sh\n') ('echo $@ > $GIT_DIR/post-checkout.args\n')} do_expansion: False here_end: EOF was_filled: T spids: [68] ) ] ) (C {(chmod)} {(u) (Lit_Other '+') (x)} {(clone) (${ VSub_Name clone) (/.git/hooks/post-checkout)} ) ] spids: [56 86] ) spids: [50 54] ) (C {(test_expect_success)} {(SQ <'post-checkout runs as expected '>)} { (SQ <'\n'> <'\tGIT_DIR=clone1/.git git checkout master &&\n'> <'\ttest -e clone1/.git/post-checkout.args\n'> ) } ) (C {(test_expect_success)} {(SQ <'post-checkout receives the right arguments with HEAD unchanged '>)} { (SQ <'\n'> <'\told=$(awk "{print \\$1}" clone1/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone1/.git/post-checkout.args) &&\n'> <'\tflag=$(awk "{print \\$3}" clone1/.git/post-checkout.args) &&\n'> <'\ttest $old = $new && test $flag = 1\n'> ) } ) (C {(test_expect_success)} {(SQ <'post-checkout runs as expected '>)} { (SQ <'\n'> <'\tGIT_DIR=clone1/.git git checkout master &&\n'> <'\ttest -e clone1/.git/post-checkout.args\n'> ) } ) (C {(test_expect_success)} {(SQ <'post-checkout args are correct with git checkout -b '>)} { (SQ <'\n'> <'\tGIT_DIR=clone1/.git git checkout -b new1 &&\n'> <'\told=$(awk "{print \\$1}" clone1/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone1/.git/post-checkout.args) &&\n'> <'\tflag=$(awk "{print \\$3}" clone1/.git/post-checkout.args) &&\n'> <'\ttest $old = $new && test $flag = 1\n'> ) } ) (C {(test_expect_success)} {(SQ <'post-checkout receives the right args with HEAD changed '>)} { (SQ <'\n'> <'\tGIT_DIR=clone2/.git git checkout new2 &&\n'> <'\told=$(awk "{print \\$1}" clone2/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone2/.git/post-checkout.args) &&\n'> <'\tflag=$(awk "{print \\$3}" clone2/.git/post-checkout.args) &&\n'> <'\ttest $old != $new && test $flag = 1\n'> ) } ) (C {(test_expect_success)} {(SQ <'post-checkout receives the right args when not switching branches '>)} { (SQ <'\n'> <'\tGIT_DIR=clone2/.git git checkout master b &&\n'> <'\told=$(awk "{print \\$1}" clone2/.git/post-checkout.args) &&\n'> <'\tnew=$(awk "{print \\$2}" clone2/.git/post-checkout.args) &&\n'> <'\tflag=$(awk "{print \\$3}" clone2/.git/post-checkout.args) &&\n'> <'\ttest $old = $new && test $flag = 0\n'> ) } ) (If arms: [ (if_arm cond: [ (Sentence child: (C {(test)} { (DQ (CommandSubPart command_list: (CommandList children: [(C {(git)} {(config)} {(--bool)} {(core.filemode)})] ) left_token: <Left_CommandSub '$('> spids: [183 191] ) ) } {(Lit_Other '=')} {(true)} ) terminator: <Op_Semi ';'> ) ] action: [ (C {(mkdir)} {(-p)} {(templates/hooks)}) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id: Redir_Great fd: 16777215 arg_word: {(templates/hooks/post-checkout)} spids: [209] ) (HereDoc op_id: Redir_DLess fd: 16777215 body: {('#!/bin/sh\n') ('echo $@ > $GIT_DIR/post-checkout.args\n')} do_expansion: False here_end: EOF was_filled: T spids: [212] ) ] ) (C {(chmod)} {(Lit_Other '+') (x)} {(templates/hooks/post-checkout)}) (C {(test_expect_success)} {(SQ <'post-checkout hook is triggered by clone'>)} { (SQ <'\n'> <'\tgit clone --template=templates . clone3 &&\n'> <'\ttest -f clone3/.git/post-checkout.args\n'> ) } ) ] spids: [16777215 199] ) ] spids: [16777215 237] ) (C {(test_done)}) ] )