summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-26 23:09:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-26 23:09:20 (GMT)
commitebc63580a1287325eef85e96c436de494406fd0a (patch)
tree16f8b85f47ff2f47b1eaba5b55902196590ed7f1 /t
parent6a67695268562f67babdb7d5195c8a43cc4015fa (diff)
parent40e0dc17ce6f8b699c0f9426438362ed658293dc (diff)
downloadgit-ebc63580a1287325eef85e96c436de494406fd0a.zip
git-ebc63580a1287325eef85e96c436de494406fd0a.tar.gz
git-ebc63580a1287325eef85e96c436de494406fd0a.tar.bz2
Merge branch 'tg/add-chmod+x-fix'
"git add --chmod=+x <pathspec>" added recently only toggled the executable bit for paths that are either new or modified. This has been corrected to flip the executable bit for all paths that match the given pathspec. * tg/add-chmod+x-fix: t3700-add: do not check working tree file mode without POSIXPERM t3700-add: create subdirectory gently add: modify already added files when --chmod is given read-cache: introduce chmod_index_entry update-index: add test for chmod flags
Diffstat (limited to 't')
-rwxr-xr-xt/t2107-update-index-basic.sh13
-rwxr-xr-xt/t3700-add.sh48
2 files changed, 61 insertions, 0 deletions
diff --git a/t/t2107-update-index-basic.sh b/t/t2107-update-index-basic.sh
index dfe02f4..32ac6e0 100755
--- a/t/t2107-update-index-basic.sh
+++ b/t/t2107-update-index-basic.sh
@@ -80,4 +80,17 @@ test_expect_success '.lock files cleaned up' '
)
'
+test_expect_success '--chmod=+x and chmod=-x in the same argument list' '
+ >A &&
+ >B &&
+ git add A B &&
+ git update-index --chmod=+x A --chmod=-x B &&
+ cat >expect <<-\EOF &&
+ 100755 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 A
+ 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0 B
+ EOF
+ git ls-files --stage A B >actual &&
+ test_cmp expect actual
+'
+
test_done
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index 2978cb9..924a266 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -349,4 +349,52 @@ test_expect_success POSIXPERM,SYMLINKS 'git add --chmod=+x with symlinks' '
test_mode_in_index 100755 foo2
'
+test_expect_success 'git add --chmod=[+-]x changes index with already added file' '
+ echo foo >foo3 &&
+ git add foo3 &&
+ git add --chmod=+x foo3 &&
+ test_mode_in_index 100755 foo3 &&
+ echo foo >xfoo3 &&
+ chmod 755 xfoo3 &&
+ git add xfoo3 &&
+ git add --chmod=-x xfoo3 &&
+ test_mode_in_index 100644 xfoo3
+'
+
+test_expect_success POSIXPERM 'git add --chmod=[+-]x does not change the working tree' '
+ echo foo >foo4 &&
+ git add foo4 &&
+ git add --chmod=+x foo4 &&
+ ! test -x foo4
+'
+
+test_expect_success 'no file status change if no pathspec is given' '
+ >foo5 &&
+ >foo6 &&
+ git add foo5 foo6 &&
+ git add --chmod=+x &&
+ test_mode_in_index 100644 foo5 &&
+ test_mode_in_index 100644 foo6
+'
+
+test_expect_success 'no file status change if no pathspec is given in subdir' '
+ mkdir -p sub &&
+ (
+ cd sub &&
+ >sub-foo1 &&
+ >sub-foo2 &&
+ git add . &&
+ git add --chmod=+x &&
+ test_mode_in_index 100644 sub-foo1 &&
+ test_mode_in_index 100644 sub-foo2
+ )
+'
+
+test_expect_success 'all statuses changed in folder if . is given' '
+ git add --chmod=+x . &&
+ test $(git ls-files --stage | grep ^100644 | wc -l) -eq 0 &&
+ git add --chmod=-x . &&
+ test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
+'
+
test_done