(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"git-merge\n"> <"\n"> <"Do not overwrite changes.">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ <setup>)} { (SQ <"\n"> <"\ttest_commit c0 c0.c &&\n"> <"\ttest_commit c1 c1.c &&\n"> <"\ttest_commit c1a c1.c \"c1 a\" &&\n"> <"\tgit reset --hard c0 &&\n"> <"\ttest_commit c2 c2.c &&\n"> <"\tgit reset --hard c0 &&\n"> <"\tmkdir sub &&\n"> <"\techo \"sub/f\" > sub/f &&\n"> <"\tmkdir sub2 &&\n"> <"\techo \"sub2/f\" > sub2/f &&\n"> <"\tgit add sub/f sub2/f &&\n"> <"\tgit commit -m sub &&\n"> <"\tgit tag sub &&\n"> <"\techo \"VERY IMPORTANT CHANGES\" > important\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite untracked file">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tcp important c2.c &&\n"> <"\ttest_must_fail git merge c2 &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\ttest_cmp important c2.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"will overwrite tracked file">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tcp important c2.c &&\n"> <"\tgit add c2.c &&\n"> <"\tgit commit -m important &&\n"> <"\tgit checkout c2\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite new file">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tcp important c2.c &&\n"> <"\tgit add c2.c &&\n"> <"\ttest_must_fail git merge c2 &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\ttest_cmp important c2.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite staged changes">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tcp important c2.c &&\n"> <"\tgit add c2.c &&\n"> <"\trm c2.c &&\n"> <"\ttest_must_fail git merge c2 &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\tgit checkout c2.c &&\n"> <"\ttest_cmp important c2.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite removed file">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit rm c1.c &&\n"> <"\tgit commit -m \"rm c1.c\" &&\n"> <"\tcp important c1.c &&\n"> <"\ttest_must_fail git merge c1a &&\n"> <"\ttest_cmp important c1.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite re-added file">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit rm c1.c &&\n"> <"\tgit commit -m \"rm c1.c\" &&\n"> <"\tcp important c1.c &&\n"> <"\tgit add c1.c &&\n"> <"\ttest_must_fail git merge c1a &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\ttest_cmp important c1.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite removed file with staged changes">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit rm c1.c &&\n"> <"\tgit commit -m \"rm c1.c\" &&\n"> <"\tcp important c1.c &&\n"> <"\tgit add c1.c &&\n"> <"\trm c1.c &&\n"> <"\ttest_must_fail git merge c1a &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\tgit checkout c1.c &&\n"> <"\ttest_cmp important c1.c\n"> ) } ) (C {(test_expect_failure)} {(SQ <"will not overwrite unstaged changes in renamed file">)} { (SQ <"\n"> <"\tgit reset --hard c1 &&\n"> <"\tgit mv c1.c other.c &&\n"> <"\tgit commit -m rename &&\n"> <"\tcp important other.c &&\n"> <"\tgit merge c1a &&\n"> <"\ttest_cmp important other.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite untracked subtree">)} { (SQ <"\n"> <"\tgit reset --hard c0 &&\n"> <"\trm -rf sub &&\n"> <"\tmkdir -p sub/f &&\n"> <"\tcp important sub/f/important &&\n"> <"\ttest_must_fail git merge sub &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\ttest_cmp important sub/f/important\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[204]) (HereDoc op_id: Redir_DLess fd: -1 body: {("error: The following untracked working tree files would be overwritten by merge:\n") ("\tsub\n") ("\tsub2\n") ("Please move or remove them before you merge.\n") ("Aborting\n") } do_expansion: False here_end: EOF was_filled: True spids: [207] ) ] ) (C {(test_expect_success)} {(SQ <"will not overwrite untracked file in leading path">)} { (SQ <"\n"> <"\tgit reset --hard c0 &&\n"> <"\trm -rf sub &&\n"> <"\tcp important sub &&\n"> <"\tcp important sub2 &&\n"> <"\ttest_must_fail git merge sub 2>out &&\n"> <"\ttest_i18ncmp out expect &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\ttest_cmp important sub &&\n"> <"\ttest_cmp important sub2 &&\n"> <"\trm -f sub sub2\n"> ) } ) (C {(test_expect_success)} {(SYMLINKS)} {(SQ <"will not overwrite untracked symlink in leading path">)} { (SQ <"\n"> <"\tgit reset --hard c0 &&\n"> <"\trm -rf sub &&\n"> <"\tmkdir sub2 &&\n"> <"\tln -s sub2 sub &&\n"> <"\ttest_must_fail git merge sub &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not be confused by symlink in leading path">)} { (SQ <"\n"> <"\tgit reset --hard c0 &&\n"> <"\trm -rf sub &&\n"> <"\ttest_ln_s_add sub2 sub &&\n"> <"\tgit commit -m ln &&\n"> <"\tgit checkout sub\n"> ) } ) (SimpleCommand words: [{(cat)}] redirects: [ (Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[270]) (HereDoc op_id: Redir_DLess fd: -1 body: {("error: Untracked working tree file 'c0.c' would be overwritten by merge.\n") ("fatal: read-tree failed\n") } do_expansion: False here_end: EOF was_filled: True spids: [273] ) ] ) (C {(test_expect_success)} {(SQ <"will not overwrite untracked file on unborn branch">)} { (SQ <"\n"> <"\tgit reset --hard c0 &&\n"> <"\tgit rm -fr . &&\n"> <"\tgit checkout --orphan new &&\n"> <"\tcp important c0.c &&\n"> <"\ttest_must_fail git merge c0 2>out &&\n"> <"\ttest_i18ncmp out expect\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not overwrite untracked file on unborn branch .git/MERGE_HEAD sanity etc.">)} { (SQ <"\n"> <"\ttest_when_finished \"rm c0.c\" &&\n"> <"\ttest_path_is_missing .git/MERGE_HEAD &&\n"> <"\ttest_cmp important c0.c\n"> ) } ) (C {(test_expect_success)} {(SQ <"failed merge leaves unborn branch in the womb">)} {(SQ <"\n"> <"\ttest_must_fail git rev-parse --verify HEAD\n">)} ) (C {(test_expect_success)} {(SQ <"set up unborn branch and content">)} { (SQ <"\n"> <"\tgit symbolic-ref HEAD refs/heads/unborn &&\n"> <"\trm -f .git/index &&\n"> <"\techo foo > tracked-file &&\n"> <"\tgit add tracked-file &&\n"> <"\techo bar > untracked-file\n"> ) } ) (C {(test_expect_success)} {(SQ <"will not clobber WT/index when merging into unborn">)} { (SQ <"\n"> <"\tgit merge master &&\n"> <"\tgrep foo tracked-file &&\n"> <"\tgit show :tracked-file >expect &&\n"> <"\tgrep foo expect &&\n"> <"\tgrep bar untracked-file\n"> ) } ) (C {(test_done)}) ] )