#!/bin/sh global test_description := ''revert can handle submodules'' source ./test-lib.sh source "$TEST_DIRECTORY"/lib-submodule-update.sh # Create a revert that moves from HEAD (including any test modifications to # the work tree) to $1 by first checking out $1 and reverting it. Reverting # the revert is the transition we test for. We tar the current work tree # first so we can restore the work tree test setup after doing the checkout # and revert. We test here that the restored work tree content is identical # to that at the beginning. The last revert is then tested by the framework. proc git_revert { git status -su >expect && ls -1pR * >>expect && tar cf "$TRASH_DIRECTORY/tmp.tar" * && git checkout $1 && git revert HEAD && rm -rf * && tar xf "$TRASH_DIRECTORY/tmp.tar" && git status -su >actual && ls -1pR * >>actual && test_cmp expect actual && git revert HEAD } global KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT := '1' global KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR := '1' test_submodule_switch "git_revert" test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"revert can handle submodules">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(.)} {(DQ ($ VSub_Name "$TEST_DIRECTORY")) (/lib-submodule-update.sh)}) (FuncDef name: git_revert body: (BraceGroup children: [ (AndOr children: [ (SimpleCommand words: [{(git)} {(status)} {(-su)}] redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[54])] ) (AndOr children: [ (SimpleCommand words: [{(ls)} {(-1pR)} {(Lit_Other "*")}] redirects: [(Redir op_id:Redir_DGreat fd:-1 arg_word:{(expect)} spids:[66])] ) (AndOr children: [ (C {(tar)} {(cf)} {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/tmp.tar))} {(Lit_Other "*")} ) (AndOr children: [ (C {(git)} {(checkout)} {(DQ ($ VSub_Number "$1"))}) (AndOr children: [ (C {(git)} {(revert)} {(HEAD)}) (AndOr children: [ (C {(rm)} {(-rf)} {(Lit_Other "*")}) (AndOr children: [ (C {(tar)} {(xf)} {(DQ ($ VSub_Name "$TRASH_DIRECTORY") (/tmp.tar))} ) (AndOr children: [ (SimpleCommand words: [{(git)} {(status)} {(-su)}] redirects: [ (Redir op_id: Redir_Great fd: -1 arg_word: {(actual)} spids: [133] ) ] ) (AndOr children: [ (SimpleCommand words: [{(ls)} {(-1pR)} {(Lit_Other "*")}] redirects: [ (Redir op_id: Redir_DGreat fd: -1 arg_word: {(actual)} spids: [145] ) ] ) (AndOr children: [ (C {(test_cmp)} {(expect)} {(actual)}) (C {(git)} {(revert)} {(HEAD)}) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] op_id: Op_DAmp ) ] spids: [45] ) spids: [40 44] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KNOWN_FAILURE_CHERRY_PICK_SEES_EMPTY_COMMIT) op: Equal rhs: {(1)} spids: [169] ) ] spids: [169] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:KNOWN_FAILURE_NOFF_MERGE_DOESNT_CREATE_EMPTY_SUBMODULE_DIR) op: Equal rhs: {(1)} spids: [172] ) ] spids: [172] ) (C {(test_submodule_switch)} {(DQ (git_revert))}) (C {(test_done)}) ] )