(command.CommandList children: [ (command.Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (lhs_expr.LhsName name:test_description) op: Equal rhs: {(SQ <'Test the post-checkout hook.'>)} ) ] ) (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'> ) } ) (command.ForEach iter_name: clone iter_words: [{(1)} {(2)}] do_arg_iter: F body: (command.DoGroup children: [ (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(clone) (${ VSub_Name clone) (/.git/hooks/post-checkout)} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 75 stdin_parts: [('#!/bin/sh\n') ('echo $@ > $GIT_DIR/post-checkout.args\n')] ) ] ) (C {(chmod)} {(u) (Lit_Other '+') (x)} {(clone) (${ VSub_Name clone) (/.git/hooks/post-checkout)} ) ] ) ) (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'> ) } ) (command.If arms: [ (if_arm cond: [ (command.Sentence child: (C {(test)} { (DQ (word_part.CommandSubPart command_list: (command.CommandList children: [(C {(git)} {(config)} {(--bool)} {(core.filemode)})] ) left_token: <Left_CommandSub '$('> ) ) } {(Lit_Other '=')} {(true)} ) terminator: <Op_Semi ';'> ) ] action: [ (C {(mkdir)} {(-p)} {(templates/hooks)}) (command.SimpleCommand words: [{(cat)}] redirects: [ (redir.Redir op: <Redir_Great '>'> fd: 16777215 arg_word: {(templates/hooks/post-checkout)} ) (redir.HereDoc op: <Redir_DLess '<<'> fd: 16777215 here_begin: {(SQ <EOF>)} here_end_span_id: 222 stdin_parts: [('#!/bin/sh\n') ('echo $@ > $GIT_DIR/post-checkout.args\n')] ) ] ) (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'> ) } ) ] ) ] ) (C {(test_done)}) ] )