#!/bin/sh global test_description := ''sparse checkout scope tests'' source ./test-lib.sh test_expect_success 'setup' ' echo "initial" >a && echo "initial" >b && echo "initial" >c && git add a b c && git commit -m "initial commit" ' test_expect_success 'create feature branch' ' git checkout -b feature && echo "modified" >b && echo "modified" >c && git add b c && git commit -m "modification" ' test_expect_success 'perform sparse checkout of master' ' git config --local --bool core.sparsecheckout true && echo "!/*" >.git/info/sparse-checkout && echo "/a" >>.git/info/sparse-checkout && echo "/c" >>.git/info/sparse-checkout && git checkout master && test_path_is_file a && test_path_is_missing b && test_path_is_file c ' test_expect_success 'merge feature branch into sparse checkout of master' ' git merge feature && test_path_is_file a && test_path_is_missing b && test_path_is_file c && test "$(cat c)" = "modified" ' test_expect_success 'return to full checkout of master' ' git checkout feature && echo "/*" >.git/info/sparse-checkout && git checkout master && test_path_is_file a && test_path_is_file b && test_path_is_file c && test "$(cat b)" = "modified" ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"sparse checkout scope tests">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(SQ )} { (SQ <"\n"> <"\techo \"initial\" >a &&\n"> <"\techo \"initial\" >b &&\n"> <"\techo \"initial\" >c &&\n"> <"\tgit add a b c &&\n"> <"\tgit commit -m \"initial commit\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"create feature branch">)} { (SQ <"\n"> <"\tgit checkout -b feature &&\n"> <"\techo \"modified\" >b &&\n"> <"\techo \"modified\" >c &&\n"> <"\tgit add b c &&\n"> <"\tgit commit -m \"modification\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"perform sparse checkout of master">)} { (SQ <"\n"> <"\tgit config --local --bool core.sparsecheckout true &&\n"> <"\techo \"!/*\" >.git/info/sparse-checkout &&\n"> <"\techo \"/a\" >>.git/info/sparse-checkout &&\n"> <"\techo \"/c\" >>.git/info/sparse-checkout &&\n"> <"\tgit checkout master &&\n"> <"\ttest_path_is_file a &&\n"> <"\ttest_path_is_missing b &&\n"> <"\ttest_path_is_file c\n"> ) } ) (C {(test_expect_success)} {(SQ <"merge feature branch into sparse checkout of master">)} { (SQ <"\n"> <"\tgit merge feature &&\n"> <"\ttest_path_is_file a &&\n"> <"\ttest_path_is_missing b &&\n"> <"\ttest_path_is_file c &&\n"> <"\ttest \"$(cat c)\" = \"modified\"\n"> ) } ) (C {(test_expect_success)} {(SQ <"return to full checkout of master">)} { (SQ <"\n"> <"\tgit checkout feature &&\n"> <"\techo \"/*\" >.git/info/sparse-checkout &&\n"> <"\tgit checkout master &&\n"> <"\ttest_path_is_file a &&\n"> <"\ttest_path_is_file b &&\n"> <"\ttest_path_is_file c &&\n"> <"\ttest \"$(cat b)\" = \"modified\"\n"> ) } ) (C {(test_done)}) ] )