summaryrefslogtreecommitdiff
path: root/t/t3700-add.sh
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2016-05-31 22:08:18 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-06-08 00:43:39 (GMT)
commit4e55ed32db81d06a4f618e2cc0f9da0e223ae304 (patch)
tree3316fb763bd68cde0303b6ef964a1dac214d3668 /t/t3700-add.sh
parent60bd4b1c513bb652cdffad44382046ca872140eb (diff)
downloadgit-4e55ed32db81d06a4f618e2cc0f9da0e223ae304.zip
git-4e55ed32db81d06a4f618e2cc0f9da0e223ae304.tar.gz
git-4e55ed32db81d06a4f618e2cc0f9da0e223ae304.tar.bz2
add: add --chmod=+x / --chmod=-x options
The executable bit will not be detected (and therefore will not be set) for paths in a repository with `core.filemode` set to false, though the users may still wish to add files as executable for compatibility with other users who _do_ have `core.filemode` functionality. For example, Windows users adding shell scripts may wish to add them as executable for compatibility with users on non-Windows. Although this can be done with a plumbing command (`git update-index --add --chmod=+x foo`), teaching the `git-add` command allows users to set a file executable with a command that they're already familiar with. Signed-off-by: Edward Thomson <ethomson@edwardthomson.com> Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3700-add.sh')
-rwxr-xr-xt/t3700-add.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/t/t3700-add.sh b/t/t3700-add.sh
index f14a665..4865304 100755
--- a/t/t3700-add.sh
+++ b/t/t3700-add.sh
@@ -332,4 +332,34 @@ test_expect_success 'git add --dry-run --ignore-missing of non-existing file out
test_i18ncmp expect.err actual.err
'
+test_expect_success 'git add --chmod=+x stages a non-executable file with +x' '
+ echo foo >foo1 &&
+ git add --chmod=+x foo1 &&
+ case "$(git ls-files --stage foo1)" in
+ 100755" "*foo1) echo pass;;
+ *) echo fail; git ls-files --stage foo1; (exit 1);;
+ 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' '
+ git config core.filemode 1 &&
+ git config core.symlinks 1 &&
+ echo foo >foo2 &&
+ git add --chmod=+x foo2 &&
+ case "$(git ls-files --stage foo2)" in
+ 100755" "*foo2) echo pass;;
+ *) echo fail; git ls-files --stage foo2; (exit 1);;
+ esac
+'
+
test_done