From c937d70bfb7661d5122e08758ae0531073a719ed Mon Sep 17 00:00:00 2001 From: Matheus Tavares Date: Mon, 22 Feb 2021 22:10:33 -0300 Subject: add --chmod: don't update index when --dry-run is used `git add --chmod` applies the mode changes even when `--dry-run` is used. Fix that and add some tests for this option combination. Helped-by: Junio C Hamano Signed-off-by: Matheus Tavares Reviewed-by: Taylor Blau Signed-off-by: Junio C Hamano --- t/t3700-add.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 't') diff --git a/t/t3700-add.sh b/t/t3700-add.sh index b7d4ba608c..fc81f2ef00 100755 --- a/t/t3700-add.sh +++ b/t/t3700-add.sh @@ -386,6 +386,26 @@ test_expect_success POSIXPERM 'git add --chmod=[+-]x does not change the working ! test -x foo4 ' +test_expect_success 'git add --chmod honors --dry-run' ' + git reset --hard && + echo foo >foo4 && + git add foo4 && + git add --chmod=+x --dry-run foo4 && + test_mode_in_index 100644 foo4 +' + +test_expect_success 'git add --chmod --dry-run reports error for non regular files' ' + git reset --hard && + test_ln_s_add foo foo4 && + git add --chmod=+x --dry-run foo4 2>stderr && + grep "cannot chmod +x .foo4." stderr +' + +test_expect_success 'git add --chmod --dry-run reports error for unmatched pathspec' ' + test_must_fail git add --chmod=+x --dry-run nonexistent 2>stderr && + test_i18ngrep "pathspec .nonexistent. did not match any files" stderr +' + test_expect_success 'no file status change if no pathspec is given' ' >foo5 && >foo6 && -- cgit v1.2.3