(CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: { (SQ <"git status --porcelain=v2\n"> <"\n"> <"This test exercises porcelain V2 output for git status."> ) } spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(setup)} { (SQ <"\n"> <"\ttest_tick &&\n"> <"\tgit config core.autocrlf false &&\n"> <"\techo x >file_x &&\n"> <"\techo y >file_y &&\n"> <"\techo z >file_z &&\n"> <"\tmkdir dir1 &&\n"> <"\techo a >dir1/file_a &&\n"> <"\techo b >dir1/file_b\n"> ) } ) (C {(test_expect_success)} {(SQ <"before initial commit, nothing added, only untracked">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid (initial)\n"> <"\t# branch.head master\n"> <"\t? actual\n"> <"\t? dir1/\n"> <"\t? expect\n"> <"\t? file_x\n"> <"\t? file_y\n"> <"\t? file_z\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=normal >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"before initial commit, things added">)} { (SQ <"\n"> <"\tgit add file_x file_y file_z dir1 &&\n"> <"\tOID_A=$(git hash-object -t blob -- dir1/file_a) &&\n"> <"\tOID_B=$(git hash-object -t blob -- dir1/file_b) &&\n"> <"\tOID_X=$(git hash-object -t blob -- file_x) &&\n"> <"\tOID_Y=$(git hash-object -t blob -- file_y) &&\n"> <"\tOID_Z=$(git hash-object -t blob -- file_z) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid (initial)\n"> <"\t# branch.head master\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_A dir1/file_a\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_B dir1/file_b\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_X file_x\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_Y file_y\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_Z file_z\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"before initial commit, things added (-z)">)} { (SQ <"\n"> <"\tlf_to_nul >expect <<-EOF &&\n"> <"\t# branch.oid (initial)\n"> <"\t# branch.head master\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_A dir1/file_a\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_B dir1/file_b\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_X file_x\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_Y file_y\n"> <"\t1 A. N... 000000 100644 100644 $_z40 $OID_Z file_z\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status -z --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"make first commit, comfirm HEAD oid and branch">)} { (SQ <"\n"> <"\tgit commit -m initial &&\n"> <"\tH0=$(git rev-parse HEAD) &&\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $H0\n"> <"\t# branch.head master\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"after first commit, create unstaged changes">)} { (SQ <"\n"> <"\techo x >>file_x &&\n"> <"\tOID_X1=$(git hash-object -t blob -- file_x) &&\n"> <"\trm file_z &&\n"> <"\tH0=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $H0\n"> <"\t# branch.head master\n"> <"\t1 .M N... 100644 100644 100644 $OID_X $OID_X file_x\n"> <"\t1 .D N... 100644 100644 000000 $OID_Z $OID_Z file_z\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"after first commit but omit untracked files and branch">)} { (SQ <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t1 .M N... 100644 100644 100644 $OID_X $OID_X file_x\n"> <"\t1 .D N... 100644 100644 000000 $OID_Z $OID_Z file_z\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --untracked-files=no >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"after first commit, stage existing changes">)} { (SQ <"\n"> <"\tgit add file_x &&\n"> <"\tgit rm file_z &&\n"> <"\tH0=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $H0\n"> <"\t# branch.head master\n"> <"\t1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x\n"> <"\t1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rename causes 2 path lines">)} { (SQ <"\n"> <"\tgit mv file_y renamed_y &&\n"> <"\tH0=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tq_to_tab >expect <<-EOF &&\n"> <"\t# branch.oid $H0\n"> <"\t# branch.head master\n"> <"\t1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x\n"> <"\t1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z\n"> <"\t2 R. N... 100644 100644 100644 $OID_Y $OID_Y R100 renamed_yQfile_y\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"rename causes 2 path lines (-z)">)} { (SQ <"\n"> <"\tH0=$(git rev-parse HEAD) &&\n"> <"\n"> <"\t## Lines use NUL path separator and line terminator, so double transform here.\n"> <"\tq_to_nul <<-EOF | lf_to_nul >expect &&\n"> <"\t# branch.oid $H0\n"> <"\t# branch.head master\n"> <"\t1 M. N... 100644 100644 100644 $OID_X $OID_X1 file_x\n"> <"\t1 D. N... 100644 000000 000000 $OID_Z $_z40 file_z\n"> <"\t2 R. N... 100644 100644 100644 $OID_Y $OID_Y R100 renamed_yQfile_y\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all -z >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"make second commit, confirm clean and new HEAD oid">)} { (SQ <"\n"> <"\tgit commit -m second &&\n"> <"\tH1=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $H1\n"> <"\t# branch.head master\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"confirm ignored files are not printed">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -f x.ign .gitignore\" &&\n"> <"\techo x.ign >.gitignore &&\n"> <"\techo \"ignore me\" >x.ign &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t? .gitignore\n"> <"\t? actual\n"> <"\t? expect\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"ignored files are printed with --ignored">)} { (SQ <"\n"> <"\ttest_when_finished \"rm -f x.ign .gitignore\" &&\n"> <"\techo x.ign >.gitignore &&\n"> <"\techo \"ignore me\" >x.ign &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t? .gitignore\n"> <"\t? actual\n"> <"\t? expect\n"> <"\t! x.ign\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --ignored --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"create and commit permanent ignore file">)} { (SQ <"\n"> <"\tcat >.gitignore <<-EOF &&\n"> <"\tactual*\n"> <"\texpect*\n"> <"\tEOF\n"> <"\n"> <"\tgit add .gitignore &&\n"> <"\tgit commit -m ignore_trash &&\n"> <"\tH1=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $H1\n"> <"\t# branch.head master\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"verify --intent-to-add output">)} { (SQ <"\n"> <"\ttest_when_finished \"git rm -f intent1.add intent2.add\" &&\n"> <"\ttouch intent1.add &&\n"> <"\techo test >intent2.add &&\n"> <"\n"> <"\tgit add --intent-to-add intent1.add intent2.add &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t1 .A N... 000000 000000 100644 $_z40 $_z40 intent1.add\n"> <"\t1 .A N... 000000 000000 100644 $_z40 $_z40 intent2.add\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"verify AA (add-add) conflict">)} { (SQ <"\n"> <"\ttest_when_finished \"git reset --hard\" &&\n"> <"\n"> <"\tgit branch AA_A master &&\n"> <"\tgit checkout AA_A &&\n"> <"\techo \"Branch AA_A\" >conflict.txt &&\n"> <"\tOID_AA_A=$(git hash-object -t blob -- conflict.txt) &&\n"> <"\tgit add conflict.txt &&\n"> <"\tgit commit -m \"branch aa_a\" &&\n"> <"\n"> <"\tgit branch AA_B master &&\n"> <"\tgit checkout AA_B &&\n"> <"\techo \"Branch AA_B\" >conflict.txt &&\n"> <"\tOID_AA_B=$(git hash-object -t blob -- conflict.txt) &&\n"> <"\tgit add conflict.txt &&\n"> <"\tgit commit -m \"branch aa_b\" &&\n"> <"\n"> <"\tgit branch AA_M AA_B &&\n"> <"\tgit checkout AA_M &&\n"> <"\ttest_must_fail git merge AA_A &&\n"> <"\n"> <"\tHM=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $HM\n"> <"\t# branch.head AA_M\n"> <"\tu AA N... 000000 100644 100644 100644 $_z40 $OID_AA_B $OID_AA_A conflict.txt\n"> <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"verify UU (edit-edit) conflict">)} { (SQ <"\n"> <"\ttest_when_finished \"git reset --hard\" &&\n"> <"\n"> <"\tgit branch UU_ANC master &&\n"> <"\tgit checkout UU_ANC &&\n"> <"\techo \"Ancestor\" >conflict.txt &&\n"> <"\tOID_UU_ANC=$(git hash-object -t blob -- conflict.txt) &&\n"> <"\tgit add conflict.txt &&\n"> <"\tgit commit -m \"UU_ANC\" &&\n"> <"\n"> <"\tgit branch UU_A UU_ANC &&\n"> <"\tgit checkout UU_A &&\n"> <"\techo \"Branch UU_A\" >conflict.txt &&\n"> <"\tOID_UU_A=$(git hash-object -t blob -- conflict.txt) &&\n"> <"\tgit add conflict.txt &&\n"> <"\tgit commit -m \"branch uu_a\" &&\n"> <"\n"> <"\tgit branch UU_B UU_ANC &&\n"> <"\tgit checkout UU_B &&\n"> <"\techo \"Branch UU_B\" >conflict.txt &&\n"> <"\tOID_UU_B=$(git hash-object -t blob -- conflict.txt) &&\n"> <"\tgit add conflict.txt &&\n"> <"\tgit commit -m \"branch uu_b\" &&\n"> <"\n"> <"\tgit branch UU_M UU_B &&\n"> <"\tgit checkout UU_M &&\n"> <"\ttest_must_fail git merge UU_A &&\n"> <"\n"> <"\tHM=$(git rev-parse HEAD) &&\n"> <"\n"> <"\tcat >expect <<-EOF &&\n"> <"\t# branch.oid $HM\n"> <"\t# branch.head UU_M\n"> < "\tu UU N... 100644 100644 100644 100644 $OID_UU_ANC $OID_UU_B $OID_UU_A conflict.txt\n" > <"\tEOF\n"> <"\n"> <"\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\ttest_cmp expect actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"verify upstream fields in branch header">)} { (SQ <"\n"> <"\tgit checkout master &&\n"> <"\ttest_when_finished \"rm -rf sub_repo\" &&\n"> <"\tgit clone . sub_repo &&\n"> <"\t(\n"> <"\t\t## Confirm local master tracks remote master.\n"> <"\t\tcd sub_repo &&\n"> <"\t\tHUF=$(git rev-parse HEAD) &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HUF\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual &&\n"> <"\n"> <"\t\t## Test ahead/behind.\n"> <"\t\techo xyz >file_xyz &&\n"> <"\t\tgit add file_xyz &&\n"> <"\t\tgit commit -m xyz &&\n"> <"\n"> <"\t\tHUF=$(git rev-parse HEAD) &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HUF\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +1 -0\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual &&\n"> <"\n"> <"\t\t## Repeat the above but without --branch.\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual &&\n"> <"\n"> <"\t\t## Test upstream-gone case. Fake this by pointing origin/master at\n"> <"\t\t## a non-existing commit.\n"> <"\t\tOLD=$(git rev-parse origin/master) &&\n"> <"\t\tNEW=$_z40 &&\n"> <"\t\tmv .git/packed-refs .git/old-packed-refs &&\n"> <"\t\tsed \"s/$OLD/$NEW/g\" <.git/old-packed-refs >.git/packed-refs &&\n"> <"\n"> <"\t\tHUF=$(git rev-parse HEAD) &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HUF\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"create and add submodule, submodule appears clean (A. S...)">)} { (SQ <"\n"> <"\tgit checkout master &&\n"> <"\tgit clone . sub_repo &&\n"> <"\tgit clone . super_repo &&\n"> <"\t(\tcd super_repo &&\n"> <"\t\tgit submodule add ../sub_repo sub1 &&\n"> <"\n"> <"\t\t## Confirm stage/add of clean submodule.\n"> <"\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$HSUP &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n"> <"\t\t1 A. S... 000000 160000 160000 $_z40 $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"untracked changes in added submodule (AM S..U)">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t## create untracked file in the submodule.\n"> <"\t\t(\tcd sub1 &&\n"> <"\t\t\techo \"xxxx\" >file_in_sub\n"> <"\t\t) &&\n"> <"\n"> <"\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$HSUP &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n"> <"\t\t1 AM S..U 000000 160000 160000 $_z40 $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"staged changes in added submodule (AM S.M.)">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t## stage the changes in the submodule.\n"> <"\t\t(\tcd sub1 &&\n"> <"\t\t\tgit add file_in_sub\n"> <"\t\t) &&\n"> <"\n"> <"\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$HSUP &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n"> <"\t\t1 AM S.M. 000000 160000 160000 $_z40 $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"staged and unstaged changes in added (AM S.M.)">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t(\tcd sub1 &&\n"> <"\t\t\t## make additional unstaged changes (on the same file) in the submodule.\n"> <"\t\t\t## This does not cause us to get S.MU (because the submodule does not report\n"> <"\t\t\t## a \"?\" line for the unstaged changes).\n"> <"\t\t\techo \"more changes\" >>file_in_sub\n"> <"\t\t) &&\n"> <"\n"> <"\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$HSUP &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n"> <"\t\t1 AM S.M. 000000 160000 160000 $_z40 $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"staged and untracked changes in added submodule (AM S.MU)">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t(\tcd sub1 &&\n"> <"\t\t\t## stage new changes in tracked file.\n"> <"\t\t\tgit add file_in_sub &&\n"> <"\t\t\t## create new untracked file.\n"> <"\t\t\techo \"yyyy\" >>another_file_in_sub\n"> <"\t\t) &&\n"> <"\n"> <"\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$HSUP &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n"> <"\t\t1 AM S.MU 000000 160000 160000 $_z40 $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"commit within the submodule appears as new commit in super (AM SC..)">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t(\tcd sub1 &&\n"> <"\t\t\t## Make a new commit in the submodule.\n"> <"\t\t\tgit add file_in_sub &&\n"> <"\t\t\trm -f another_file_in_sub &&\n"> <"\t\t\tgit commit -m \"new commit\"\n"> <"\t\t) &&\n"> <"\n"> <"\t\tHMOD=$(git hash-object -t blob -- .gitmodules) &&\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$HSUP &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +0 -0\n"> <"\t\t1 A. N... 000000 100644 100644 $_z40 $HMOD .gitmodules\n"> <"\t\t1 AM SC.. 000000 160000 160000 $_z40 $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"stage submodule in super and commit">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t## Stage the new submodule commit in the super.\n"> <"\t\tgit add sub1 &&\n"> <"\t\t## Commit the super so that the sub no longer appears as added.\n"> <"\t\tgit commit -m \"super commit\" &&\n"> <"\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +1 -0\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_expect_success)} {(SQ <"make unstaged changes in existing submodule (.M S.M.)">)} { (SQ <"\n"> <"\t(\tcd super_repo &&\n"> <"\t\t(\tcd sub1 &&\n"> <"\t\t\techo \"zzzz\" >>file_in_sub\n"> <"\t\t) &&\n"> <"\n"> <"\t\tHSUP=$(git rev-parse HEAD) &&\n"> <"\t\tHSUB=$(cd sub1 && git rev-parse HEAD) &&\n"> <"\n"> <"\t\tcat >expect <<-EOF &&\n"> <"\t\t# branch.oid $HSUP\n"> <"\t\t# branch.head master\n"> <"\t\t# branch.upstream origin/master\n"> <"\t\t# branch.ab +1 -0\n"> <"\t\t1 .M S.M. 160000 160000 160000 $HSUB $HSUB sub1\n"> <"\t\tEOF\n"> <"\n"> <"\t\tgit status --porcelain=v2 --branch --untracked-files=all >actual &&\n"> <"\t\ttest_cmp expect actual\n"> <"\t)\n"> ) } ) (C {(test_done)}) ] )