зеркало из https://github.com/microsoft/git.git
Merge branch 'ib/t3700-add-chmod-x-updates'
The t3700 test about "add --chmod=-x" have been made a bit more robust and generally cleaned up. * ib/t3700-add-chmod-x-updates: t3700: add a test_mode_in_index helper function t3700: merge two tests into one t3700: remove unwanted leftover files before running new tests
This commit is contained in:
Коммит
09ee6444f2
|
@ -7,6 +7,20 @@ test_description='Test of git add, including the -- option.'
|
||||||
|
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
# Test the file mode "$1" of the file "$2" in the index.
|
||||||
|
test_mode_in_index () {
|
||||||
|
case "$(git ls-files -s "$2")" in
|
||||||
|
"$1 "*" $2")
|
||||||
|
echo pass
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo fail
|
||||||
|
git ls-files -s "$2"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'Test of git add' \
|
'Test of git add' \
|
||||||
'touch foo && git add foo'
|
'touch foo && git add foo'
|
||||||
|
@ -25,18 +39,12 @@ test_expect_success \
|
||||||
echo foo >xfoo1 &&
|
echo foo >xfoo1 &&
|
||||||
chmod 755 xfoo1 &&
|
chmod 755 xfoo1 &&
|
||||||
git add xfoo1 &&
|
git add xfoo1 &&
|
||||||
case "$(git ls-files --stage xfoo1)" in
|
test_mode_in_index 100644 xfoo1'
|
||||||
100644" "*xfoo1) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage xfoo1; (exit 1);;
|
|
||||||
esac'
|
|
||||||
|
|
||||||
test_expect_success 'git add: filemode=0 should not get confused by symlink' '
|
test_expect_success 'git add: filemode=0 should not get confused by symlink' '
|
||||||
rm -f xfoo1 &&
|
rm -f xfoo1 &&
|
||||||
test_ln_s_add foo xfoo1 &&
|
test_ln_s_add foo xfoo1 &&
|
||||||
case "$(git ls-files --stage xfoo1)" in
|
test_mode_in_index 120000 xfoo1
|
||||||
120000" "*xfoo1) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage xfoo1; (exit 1);;
|
|
||||||
esac
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
|
@ -45,28 +53,19 @@ test_expect_success \
|
||||||
echo foo >xfoo2 &&
|
echo foo >xfoo2 &&
|
||||||
chmod 755 xfoo2 &&
|
chmod 755 xfoo2 &&
|
||||||
git update-index --add xfoo2 &&
|
git update-index --add xfoo2 &&
|
||||||
case "$(git ls-files --stage xfoo2)" in
|
test_mode_in_index 100644 xfoo2'
|
||||||
100644" "*xfoo2) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage xfoo2; (exit 1);;
|
|
||||||
esac'
|
|
||||||
|
|
||||||
test_expect_success 'git add: filemode=0 should not get confused by symlink' '
|
test_expect_success 'git add: filemode=0 should not get confused by symlink' '
|
||||||
rm -f xfoo2 &&
|
rm -f xfoo2 &&
|
||||||
test_ln_s_add foo xfoo2 &&
|
test_ln_s_add foo xfoo2 &&
|
||||||
case "$(git ls-files --stage xfoo2)" in
|
test_mode_in_index 120000 xfoo2
|
||||||
120000" "*xfoo2) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage xfoo2; (exit 1);;
|
|
||||||
esac
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success \
|
test_expect_success \
|
||||||
'git update-index --add: Test that executable bit is not used...' \
|
'git update-index --add: Test that executable bit is not used...' \
|
||||||
'git config core.filemode 0 &&
|
'git config core.filemode 0 &&
|
||||||
test_ln_s_add xfoo2 xfoo3 && # runs git update-index --add
|
test_ln_s_add xfoo2 xfoo3 && # runs git update-index --add
|
||||||
case "$(git ls-files --stage xfoo3)" in
|
test_mode_in_index 120000 xfoo3'
|
||||||
120000" "*xfoo3) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage xfoo3; (exit 1);;
|
|
||||||
esac'
|
|
||||||
|
|
||||||
test_expect_success '.gitignore test setup' '
|
test_expect_success '.gitignore test setup' '
|
||||||
echo "*.ig" >.gitignore &&
|
echo "*.ig" >.gitignore &&
|
||||||
|
@ -332,34 +331,22 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
|
||||||
test_i18ncmp expect.err actual.err
|
test_i18ncmp expect.err actual.err
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
|
test_expect_success 'git add --chmod=[+-]x stages correctly' '
|
||||||
|
rm -f foo1 &&
|
||||||
echo foo >foo1 &&
|
echo foo >foo1 &&
|
||||||
git add --chmod=+x foo1 &&
|
git add --chmod=+x foo1 &&
|
||||||
case "$(git ls-files --stage foo1)" in
|
test_mode_in_index 100755 foo1 &&
|
||||||
100755" "*foo1) echo pass;;
|
git add --chmod=-x foo1 &&
|
||||||
*) echo fail; git ls-files --stage foo1; (exit 1);;
|
test_mode_in_index 100644 foo1
|
||||||
esac
|
|
||||||
'
|
|
||||||
|
|
||||||
test_expect_success 'git add --chmod=-x stages an executable file with -x' '
|
|
||||||
echo foo >xfoo1 &&
|
|
||||||
chmod 755 xfoo1 &&
|
|
||||||
git add --chmod=-x xfoo1 &&
|
|
||||||
case "$(git ls-files --stage xfoo1)" in
|
|
||||||
100644" "*xfoo1) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage xfoo1; (exit 1);;
|
|
||||||
esac
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
|
test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
|
||||||
git config core.filemode 1 &&
|
git config core.filemode 1 &&
|
||||||
git config core.symlinks 1 &&
|
git config core.symlinks 1 &&
|
||||||
|
rm -f foo2 &&
|
||||||
echo foo >foo2 &&
|
echo foo >foo2 &&
|
||||||
git add --chmod=+x foo2 &&
|
git add --chmod=+x foo2 &&
|
||||||
case "$(git ls-files --stage foo2)" in
|
test_mode_in_index 100755 foo2
|
||||||
100755" "*foo2) echo pass;;
|
|
||||||
*) echo fail; git ls-files --stage foo2; (exit 1);;
|
|
||||||
esac
|
|
||||||
'
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|
Загрузка…
Ссылка в новой задаче