#!/bin/sh global test_description := ''Various filesystem issues'' source ./test-lib.sh global auml := $[printf '\303\244] global aumlcdiar := $[printf '\141\314\210] if test_have_prereq CASE_INSENSITIVE_FS { say "will test on a case insensitive filesystem" global test_case := 'test_expect_failure' } else { global test_case := 'test_expect_success' } if test_have_prereq UTF8_NFD_TO_NFC { say "will test on a unicode corrupting filesystem" global test_unicode := 'test_expect_failure' } else { global test_unicode := 'test_expect_success' } test_have_prereq SYMLINKS || say "will test on a filesystem lacking symbolic links" if test_have_prereq CASE_INSENSITIVE_FS { test_expect_success "detection of case insensitive filesystem during repo init" ' test $(git config --bool core.ignorecase) = true ' } else { test_expect_success "detection of case insensitive filesystem during repo init" ' { test_must_fail git config --bool core.ignorecase >/dev/null || test $(git config --bool core.ignorecase) = false } ' } if test_have_prereq SYMLINKS { test_expect_success "detection of filesystem w/o symlink support during repo init" ' { test_must_fail git config --bool core.symlinks || test "$(git config --bool core.symlinks)" = true } ' } else { test_expect_success "detection of filesystem w/o symlink support during repo init" ' v=$(git config --bool core.symlinks) && test "$v" = false ' } test_expect_success "setup case tests" ' git config core.ignorecase true && touch camelcase && git add camelcase && git commit -m "initial" && git tag initial && git checkout -b topic && git mv camelcase tmp && git mv tmp CamelCase && git commit -m "rename" && git checkout -f master ' test_expect_success 'rename (case change)' ' git mv camelcase CamelCase && git commit -m "rename" ' test_expect_success 'merge (case change)' ' rm -f CamelCase && rm -f camelcase && git reset --hard initial && git merge topic ' test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' ' git reset --hard initial && rm camelcase && echo 1 >CamelCase && git add CamelCase && camel=$(git ls-files | grep -i camelcase) && test $(echo "$camel" | wc -l) = 1 && test "z$(git cat-file blob :$camel)" = z1 ' test_expect_success "setup unicode normalization tests" ' test_create_repo unicode && cd unicode && git config core.precomposeunicode false && touch "$aumlcdiar" && git add "$aumlcdiar" && git commit -m initial && git tag initial && git checkout -b topic && git mv $aumlcdiar tmp && git mv tmp "$auml" && git commit -m rename && git checkout -f master ' $test_unicode 'rename (silent unicode normalization)' ' git mv "$aumlcdiar" "$auml" && git commit -m rename ' $test_unicode 'merge (silent unicode normalization)' ' git reset --hard initial && git merge topic ' test_done (CommandList children: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_description) op: Equal rhs: {(SQ <"Various filesystem issues">)} spids: [4] ) ] spids: [4] ) (C {(.)} {(./test-lib.sh)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:auml) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(printf)} {(SQ <"\\303\\244">)})]) left_token: spids: [16 22] ) } spids: [15] ) ] spids: [15] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:aumlcdiar) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(printf)} {(SQ <"\\141\\314\\210">)})]) left_token: spids: [25 31] ) } spids: [24] ) ] spids: [24] ) (If arms: [ (if_arm cond: [(C {(test_have_prereq)} {(CASE_INSENSITIVE_FS)})] action: [ (C {(say)} {(DQ ("will test on a case insensitive filesystem"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_case) op: Equal rhs: {(test_expect_failure)} spids: [50] ) ] spids: [50] ) ] spids: [-1 40] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_case) op: Equal rhs: {(test_expect_success)} spids: [56] ) ] spids: [56] ) ] spids: [53 59] ) (If arms: [ (if_arm cond: [(C {(test_have_prereq)} {(UTF8_NFD_TO_NFC)})] action: [ (C {(say)} {(DQ ("will test on a unicode corrupting filesystem"))}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_unicode) op: Equal rhs: {(test_expect_failure)} spids: [78] ) ] spids: [78] ) ] spids: [-1 68] ) ] else_action: [ (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:test_unicode) op: Equal rhs: {(test_expect_success)} spids: [84] ) ] spids: [84] ) ] spids: [81 87] ) (AndOr children: [ (C {(test_have_prereq)} {(SYMLINKS)}) (C {(say)} {(DQ ("will test on a filesystem lacking symbolic links"))}) ] op_id: Op_DPipe ) (If arms: [ (if_arm cond: [(C {(test_have_prereq)} {(CASE_INSENSITIVE_FS)})] action: [ (C {(test_expect_success)} {(DQ ("detection of case insensitive filesystem during repo init"))} {(SQ <"\n"> <"\ttest $(git config --bool core.ignorecase) = true\n">)} ) ] spids: [-1 110] ) ] else_action: [ (C {(test_expect_success)} {(DQ ("detection of case insensitive filesystem during repo init"))} { (SQ <"\n"> <"\t{\n"> <"\t\ttest_must_fail git config --bool core.ignorecase >/dev/null ||\n"> <"\t\t\ttest $(git config --bool core.ignorecase) = false\n"> <"\t}\n"> ) } ) ] spids: [123 139] ) (If arms: [ (if_arm cond: [(C {(test_have_prereq)} {(SYMLINKS)})] action: [ (C {(test_expect_success)} {(DQ ("detection of filesystem w/o symlink support during repo init"))} { (SQ <"\n"> <"\t{\n"> <"\t\ttest_must_fail git config --bool core.symlinks ||\n"> <"\t\ttest \"$(git config --bool core.symlinks)\" = true\n"> <"\t}\n"> ) } ) ] spids: [-1 148] ) ] else_action: [ (C {(test_expect_success)} {(DQ ("detection of filesystem w/o symlink support during repo init"))} {(SQ <"\n"> <"\tv=$(git config --bool core.symlinks) &&\n"> <"\ttest \"$v\" = false\n">)} ) ] spids: [164 178] ) (C {(test_expect_success)} {(DQ ("setup case tests"))} { (SQ <"\n"> <"\tgit config core.ignorecase true &&\n"> <"\ttouch camelcase &&\n"> <"\tgit add camelcase &&\n"> <"\tgit commit -m \"initial\" &&\n"> <"\tgit tag initial &&\n"> <"\tgit checkout -b topic &&\n"> <"\tgit mv camelcase tmp &&\n"> <"\tgit mv tmp CamelCase &&\n"> <"\tgit commit -m \"rename\" &&\n"> <"\tgit checkout -f master\n"> ) } ) (C {(test_expect_success)} {(SQ <"rename (case change)">)} {(SQ <"\n"> <"\tgit mv camelcase CamelCase &&\n"> <"\tgit commit -m \"rename\"\n">)} ) (C {(test_expect_success)} {(SQ <"merge (case change)">)} { (SQ <"\n"> <"\trm -f CamelCase &&\n"> <"\trm -f camelcase &&\n"> <"\tgit reset --hard initial &&\n"> <"\tgit merge topic\n"> ) } ) (C {(test_expect_failure)} {(CASE_INSENSITIVE_FS)} {(SQ <"add (with different case)">)} { (SQ <"\n"> <"\tgit reset --hard initial &&\n"> <"\trm camelcase &&\n"> <"\techo 1 >CamelCase &&\n"> <"\tgit add CamelCase &&\n"> <"\tcamel=$(git ls-files | grep -i camelcase) &&\n"> <"\ttest $(echo \"$camel\" | wc -l) = 1 &&\n"> <"\ttest \"z$(git cat-file blob :$camel)\" = z1\n"> ) } ) (C {(test_expect_success)} {(DQ ("setup unicode normalization tests"))} { (SQ <"\n"> <"\ttest_create_repo unicode &&\n"> <"\tcd unicode &&\n"> <"\tgit config core.precomposeunicode false &&\n"> <"\ttouch \"$aumlcdiar\" &&\n"> <"\tgit add \"$aumlcdiar\" &&\n"> <"\tgit commit -m initial &&\n"> <"\tgit tag initial &&\n"> <"\tgit checkout -b topic &&\n"> <"\tgit mv $aumlcdiar tmp &&\n"> <"\tgit mv tmp \"$auml\" &&\n"> <"\tgit commit -m rename &&\n"> <"\tgit checkout -f master\n"> ) } ) (C {($ VSub_Name "$test_unicode")} {(SQ <"rename (silent unicode normalization)">)} {(SQ <"\n"> <"\tgit mv \"$aumlcdiar\" \"$auml\" &&\n"> <"\tgit commit -m rename\n">)} ) (C {($ VSub_Name "$test_unicode")} {(SQ <"merge (silent unicode normalization)">)} {(SQ <"\n"> <"\tgit reset --hard initial &&\n"> <"\tgit merge topic\n">)} ) (C {(test_done)}) ] )