#!/bin/sh global test_description := ''update-index with options'' source ./test-lib.sh test_expect_success basics ' >one && >two && >three && # need --add when adding test_must_fail git update-index one && test -z "$(git ls-files)" && git update-index --add one && test zone = "z$(git ls-files)" && # update-index is atomic echo 1 >one && test_must_fail git update-index one two && echo "M one" >expect && git diff-files --name-status >actual && test_cmp expect actual && git update-index --add one two three && for i in one three two; do echo $i; done >expect && git ls-files >actual && test_cmp expect actual && test_tick && ( test_create_repo xyzzy && cd xyzzy && >file && git add file git commit -m "sub initial" ) && git add xyzzy && test_tick && git commit -m initial && git tag initial ' test_expect_success '--ignore-missing --refresh' ' git reset --hard initial && echo 2 >one && test_must_fail git update-index --refresh && echo 1 >one && git update-index --refresh && rm -f two && test_must_fail git update-index --refresh && git update-index --ignore-missing --refresh ' test_expect_success '--unmerged --refresh' ' git reset --hard initial && info=$(git ls-files -s one | sed -e "s/ 0 / 1 /") && git rm --cached one && echo "$info" | git update-index --index-info && test_must_fail git update-index --refresh && git update-index --unmerged --refresh && echo 2 >two && test_must_fail git update-index --unmerged --refresh >actual && grep two actual && ! grep one actual && ! grep three actual ' test_expect_success '--ignore-submodules --refresh (1)' ' git reset --hard initial && rm -f two && test_must_fail git update-index --ignore-submodules --refresh ' test_expect_success '--ignore-submodules --refresh (2)' ' git reset --hard initial && test_tick && ( cd xyzzy && git commit -m "sub second" --allow-empty ) && test_must_fail git update-index --refresh && test_must_fail git update-index --ignore-missing --refresh && git update-index --ignore-submodules --refresh ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"update-index with options">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (C {(test_expect_success)} {(basics)} { (SQ <"\n"> <"\t>one &&\n"> <"\t>two &&\n"> <"\t>three &&\n"> <"\n"> <"\t# need --add when adding\n"> <"\ttest_must_fail git update-index one &&\n"> <"\ttest -z \"$(git ls-files)\" &&\n"> <"\tgit update-index --add one &&\n"> <"\ttest zone = \"z$(git ls-files)\" &&\n"> <"\n"> <"\t# update-index is atomic\n"> <"\techo 1 >one &&\n"> <"\ttest_must_fail git update-index one two &&\n"> <"\techo \"M\tone\" >expect &&\n"> <"\tgit diff-files --name-status >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\tgit update-index --add one two three &&\n"> <"\tfor i in one three two; do echo $i; done >expect &&\n"> <"\tgit ls-files >actual &&\n"> <"\ttest_cmp expect actual &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\t(\n"> <"\t\ttest_create_repo xyzzy &&\n"> <"\t\tcd xyzzy &&\n"> <"\t\t>file &&\n"> <"\t\tgit add file\n"> <"\t\tgit commit -m \"sub initial\"\n"> <"\t) &&\n"> <"\tgit add xyzzy &&\n"> <"\n"> <"\ttest_tick &&\n"> <"\tgit commit -m initial &&\n"> <"\tgit tag initial\n"> ) } ) (C {(test_expect_success)} {(SQ <"--ignore-missing --refresh">)} { (SQ <"\n"> <"\tgit reset --hard initial &&\n"> <"\techo 2 >one &&\n"> <"\ttest_must_fail git update-index --refresh &&\n"> <"\techo 1 >one &&\n"> <"\tgit update-index --refresh &&\n"> <"\trm -f two &&\n"> <"\ttest_must_fail git update-index --refresh &&\n"> <"\tgit update-index --ignore-missing --refresh\n"> <"\n"> ) } ) (C {(test_expect_success)} {(SQ <"--unmerged --refresh">)} { (SQ <"\n"> <"\tgit reset --hard initial &&\n"> <"\tinfo=$(git ls-files -s one | sed -e \"s/ 0\t/ 1\t/\") &&\n"> <"\tgit rm --cached one &&\n"> <"\techo \"$info\" | git update-index --index-info &&\n"> <"\ttest_must_fail git update-index --refresh &&\n"> <"\tgit update-index --unmerged --refresh &&\n"> <"\techo 2 >two &&\n"> <"\ttest_must_fail git update-index --unmerged --refresh >actual &&\n"> <"\tgrep two actual &&\n"> <"\t! grep one actual &&\n"> <"\t! grep three actual\n"> ) } ) (C {(test_expect_success)} {(SQ <"--ignore-submodules --refresh (1)">)} { (SQ <"\n"> <"\tgit reset --hard initial &&\n"> <"\trm -f two &&\n"> <"\ttest_must_fail git update-index --ignore-submodules --refresh\n"> ) } ) (C {(test_expect_success)} {(SQ <"--ignore-submodules --refresh (2)">)} { (SQ <"\n"> <"\tgit reset --hard initial &&\n"> <"\ttest_tick &&\n"> <"\t(\n"> <"\t\tcd xyzzy &&\n"> <"\t\tgit commit -m \"sub second\" --allow-empty\n"> <"\t) &&\n"> <"\ttest_must_fail git update-index --refresh &&\n"> <"\ttest_must_fail git update-index --ignore-missing --refresh &&\n"> <"\tgit update-index --ignore-submodules --refresh\n"> ) } ) (C {(test_done)}) ] )